From 7260daf67ccc3fd6d002acbb072a8c3e07f3da61 Mon Sep 17 00:00:00 2001 From: Scott Cotton Date: Wed, 25 Oct 2023 12:09:55 +0200 Subject: [PATCH] sync with upstream sync-status --- generate/swagger.json | 28 ++++-- models/clusters_last_sync.go | 163 +++++++++++++++++++++++++++++++++ models/clusters_sync_status.go | 88 ++++-------------- 3 files changed, 198 insertions(+), 81 deletions(-) create mode 100644 models/clusters_last_sync.go diff --git a/generate/swagger.json b/generate/swagger.json index 0b25dbd..f266f8f 100644 --- a/generate/swagger.json +++ b/generate/swagger.json @@ -188,6 +188,21 @@ }, "type": "object" }, + "clusters.LastSync": { + "properties": { + "routegroups": { + "$ref": "#/definitions/clusters.SyncCollectionStatus" + }, + "sandboxes": { + "$ref": "#/definitions/clusters.SyncCollectionStatus" + }, + "time": { + "description": "The time at which the last sync occured.", + "type": "string" + } + }, + "type": "object" + }, "clusters.ReadinessStats": { "properties": { "count": { @@ -240,18 +255,11 @@ "type": "string" }, "lastErrorTime": { - "description": "The time of the last global error of a sync", + "description": "The time of the last global error of a sync.", "type": "string" }, - "lastSyncTime": { - "description": "The time of the last successful sync.", - "type": "string" - }, - "routegroups": { - "$ref": "#/definitions/clusters.SyncCollectionStatus" - }, - "sandboxes": { - "$ref": "#/definitions/clusters.SyncCollectionStatus" + "lastSync": { + "$ref": "#/definitions/clusters.LastSync" } }, "type": "object" diff --git a/models/clusters_last_sync.go b/models/clusters_last_sync.go new file mode 100644 index 0000000..0ce22e1 --- /dev/null +++ b/models/clusters_last_sync.go @@ -0,0 +1,163 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ClustersLastSync clusters last sync +// +// swagger:model clusters.LastSync +type ClustersLastSync struct { + + // routegroups + Routegroups *ClustersSyncCollectionStatus `json:"routegroups,omitempty"` + + // sandboxes + Sandboxes *ClustersSyncCollectionStatus `json:"sandboxes,omitempty"` + + // The time at which the last sync occured. + Time string `json:"time,omitempty"` +} + +// Validate validates this clusters last sync +func (m *ClustersLastSync) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRoutegroups(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSandboxes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ClustersLastSync) validateRoutegroups(formats strfmt.Registry) error { + if swag.IsZero(m.Routegroups) { // not required + return nil + } + + if m.Routegroups != nil { + if err := m.Routegroups.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("routegroups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("routegroups") + } + return err + } + } + + return nil +} + +func (m *ClustersLastSync) validateSandboxes(formats strfmt.Registry) error { + if swag.IsZero(m.Sandboxes) { // not required + return nil + } + + if m.Sandboxes != nil { + if err := m.Sandboxes.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sandboxes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sandboxes") + } + return err + } + } + + return nil +} + +// ContextValidate validate this clusters last sync based on the context it is used +func (m *ClustersLastSync) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateRoutegroups(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSandboxes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ClustersLastSync) contextValidateRoutegroups(ctx context.Context, formats strfmt.Registry) error { + + if m.Routegroups != nil { + + if swag.IsZero(m.Routegroups) { // not required + return nil + } + + if err := m.Routegroups.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("routegroups") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("routegroups") + } + return err + } + } + + return nil +} + +func (m *ClustersLastSync) contextValidateSandboxes(ctx context.Context, formats strfmt.Registry) error { + + if m.Sandboxes != nil { + + if swag.IsZero(m.Sandboxes) { // not required + return nil + } + + if err := m.Sandboxes.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sandboxes") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sandboxes") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ClustersLastSync) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ClustersLastSync) UnmarshalBinary(b []byte) error { + var res ClustersLastSync + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/clusters_sync_status.go b/models/clusters_sync_status.go index 9075d57..3f0aec7 100644 --- a/models/clusters_sync_status.go +++ b/models/clusters_sync_status.go @@ -22,28 +22,18 @@ type ClustersSyncStatus struct { // from occuring. LastError string `json:"lastError,omitempty"` - // The time of the last global error of a sync + // The time of the last global error of a sync. LastErrorTime string `json:"lastErrorTime,omitempty"` - // The time of the last successful sync. - LastSyncTime string `json:"lastSyncTime,omitempty"` - - // routegroups - Routegroups *ClustersSyncCollectionStatus `json:"routegroups,omitempty"` - - // sandboxes - Sandboxes *ClustersSyncCollectionStatus `json:"sandboxes,omitempty"` + // last sync + LastSync *ClustersLastSync `json:"lastSync,omitempty"` } // Validate validates this clusters sync status func (m *ClustersSyncStatus) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateRoutegroups(formats); err != nil { - res = append(res, err) - } - - if err := m.validateSandboxes(formats); err != nil { + if err := m.validateLastSync(formats); err != nil { res = append(res, err) } @@ -53,36 +43,17 @@ func (m *ClustersSyncStatus) Validate(formats strfmt.Registry) error { return nil } -func (m *ClustersSyncStatus) validateRoutegroups(formats strfmt.Registry) error { - if swag.IsZero(m.Routegroups) { // not required - return nil - } - - if m.Routegroups != nil { - if err := m.Routegroups.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("routegroups") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("routegroups") - } - return err - } - } - - return nil -} - -func (m *ClustersSyncStatus) validateSandboxes(formats strfmt.Registry) error { - if swag.IsZero(m.Sandboxes) { // not required +func (m *ClustersSyncStatus) validateLastSync(formats strfmt.Registry) error { + if swag.IsZero(m.LastSync) { // not required return nil } - if m.Sandboxes != nil { - if err := m.Sandboxes.Validate(formats); err != nil { + if m.LastSync != nil { + if err := m.LastSync.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("sandboxes") + return ve.ValidateName("lastSync") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("sandboxes") + return ce.ValidateName("lastSync") } return err } @@ -95,11 +66,7 @@ func (m *ClustersSyncStatus) validateSandboxes(formats strfmt.Registry) error { func (m *ClustersSyncStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error - if err := m.contextValidateRoutegroups(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateSandboxes(ctx, formats); err != nil { + if err := m.contextValidateLastSync(ctx, formats); err != nil { res = append(res, err) } @@ -109,40 +76,19 @@ func (m *ClustersSyncStatus) ContextValidate(ctx context.Context, formats strfmt return nil } -func (m *ClustersSyncStatus) contextValidateRoutegroups(ctx context.Context, formats strfmt.Registry) error { - - if m.Routegroups != nil { - - if swag.IsZero(m.Routegroups) { // not required - return nil - } - - if err := m.Routegroups.ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("routegroups") - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("routegroups") - } - return err - } - } - - return nil -} - -func (m *ClustersSyncStatus) contextValidateSandboxes(ctx context.Context, formats strfmt.Registry) error { +func (m *ClustersSyncStatus) contextValidateLastSync(ctx context.Context, formats strfmt.Registry) error { - if m.Sandboxes != nil { + if m.LastSync != nil { - if swag.IsZero(m.Sandboxes) { // not required + if swag.IsZero(m.LastSync) { // not required return nil } - if err := m.Sandboxes.ContextValidate(ctx, formats); err != nil { + if err := m.LastSync.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("sandboxes") + return ve.ValidateName("lastSync") } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("sandboxes") + return ce.ValidateName("lastSync") } return err }