diff --git a/cmd/start.go b/cmd/start.go index 06d1fb9593..cc7e6d19f0 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -232,7 +232,7 @@ func startControllers(ctx *controllerContext) error { componentNamespace, componentName, rootOpts.releaseImage, ctx.InformerFactory.Clusterversion().V1().CVOConfigs(), - ctx.InformerFactory.Operatorstatus().V1().OperatorStatuses(), + ctx.InformerFactory.Operatorstatus().V1().ClusterOperators(), ctx.APIExtInformerFactory.Apiextensions().V1beta1().CustomResourceDefinitions(), ctx.KubeInformerFactory.Apps().V1().Deployments(), ctx.ClientBuilder.RestConfig(), @@ -245,7 +245,7 @@ func startControllers(ctx *controllerContext) error { go autoupdate.New( componentNamespace, componentName, ctx.InformerFactory.Clusterversion().V1().CVOConfigs(), - ctx.InformerFactory.Operatorstatus().V1().OperatorStatuses(), + ctx.InformerFactory.Operatorstatus().V1().ClusterOperators(), ctx.ClientBuilder.ClientOrDie(componentName), ctx.ClientBuilder.KubeClientOrDie(componentName), ).Run(2, ctx.Stop) diff --git a/install/0000_00_cluster-version-operator_01_cvoconfig.crd.yaml b/install/0000_00_cluster-version-operator_01_cvoconfig.crd.yaml index 8a7bff6aaa..c9f65274ea 100644 --- a/install/0000_00_cluster-version-operator_01_cvoconfig.crd.yaml +++ b/install/0000_00_cluster-version-operator_01_cvoconfig.crd.yaml @@ -15,6 +15,9 @@ spec: storage: true # either Namespaced or Cluster scope: Namespaced + subresources: + # enable spec/status + status: {} names: # plural name to be used in the URL: /apis/// plural: cvoconfigs diff --git a/lib/resourceapply/cv.go b/lib/resourceapply/cv.go index 6c82fdb1ba..f4168c71ca 100644 --- a/lib/resourceapply/cv.go +++ b/lib/resourceapply/cv.go @@ -15,13 +15,13 @@ import ( "k8s.io/utils/pointer" ) -func ApplyOperatorStatus(client osclientv1.OperatorStatusesGetter, required *osv1.OperatorStatus) (*osv1.OperatorStatus, bool, error) { - if required.Extension.Raw != nil && required.Extension.Object != nil { +func ApplyOperatorStatus(client osclientv1.ClusterOperatorsGetter, required *osv1.ClusterOperator) (*osv1.ClusterOperator, bool, error) { + if required.Status.Extension.Raw != nil && required.Status.Extension.Object != nil { return nil, false, fmt.Errorf("both extension.Raw and extension.Object should not be set") } - existing, err := client.OperatorStatuses(required.Namespace).Get(required.Name, metav1.GetOptions{}) + existing, err := client.ClusterOperators(required.Namespace).Get(required.Name, metav1.GetOptions{}) if errors.IsNotFound(err) { - actual, err := client.OperatorStatuses(required.Namespace).Create(required) + actual, err := client.ClusterOperators(required.Namespace).Create(required) return actual, true, err } if err != nil { @@ -34,17 +34,17 @@ func ApplyOperatorStatus(client osclientv1.OperatorStatusesGetter, required *osv return existing, false, nil } - actual, err := client.OperatorStatuses(required.Namespace).Update(existing) + actual, err := client.ClusterOperators(required.Namespace).Update(existing) return actual, true, err } -func ApplyOperatorStatusFromCache(lister oslistersv1.OperatorStatusLister, client osclientv1.OperatorStatusesGetter, required *osv1.OperatorStatus) (*osv1.OperatorStatus, bool, error) { - if required.Extension.Raw != nil && required.Extension.Object != nil { +func ApplyOperatorStatusFromCache(lister oslistersv1.ClusterOperatorLister, client osclientv1.ClusterOperatorsGetter, required *osv1.ClusterOperator) (*osv1.ClusterOperator, bool, error) { + if required.Status.Extension.Raw != nil && required.Status.Extension.Object != nil { return nil, false, fmt.Errorf("both extension.Raw and extension.Object should not be set") } - existing, err := lister.OperatorStatuses(required.Namespace).Get(required.Name) + existing, err := lister.ClusterOperators(required.Namespace).Get(required.Name) if errors.IsNotFound(err) { - actual, err := client.OperatorStatuses(required.Namespace).Create(required) + actual, err := client.ClusterOperators(required.Namespace).Create(required) return actual, true, err } if err != nil { @@ -59,7 +59,7 @@ func ApplyOperatorStatusFromCache(lister oslistersv1.OperatorStatusLister, clien return existing, false, nil } - actual, err := client.OperatorStatuses(required.Namespace).Update(existing) + actual, err := client.ClusterOperators(required.Namespace).Update(existing) return actual, true, err } diff --git a/lib/resourcemerge/os.go b/lib/resourcemerge/os.go index 893d78b570..fa9efac3ba 100644 --- a/lib/resourcemerge/os.go +++ b/lib/resourcemerge/os.go @@ -1,24 +1,28 @@ package resourcemerge import ( - osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" + "time" + "k8s.io/apimachinery/pkg/api/equality" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" ) -func EnsureOperatorStatus(modified *bool, existing *osv1.OperatorStatus, required osv1.OperatorStatus) { +func EnsureOperatorStatus(modified *bool, existing *osv1.ClusterOperator, required osv1.ClusterOperator) { EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta) - if !equality.Semantic.DeepEqual(existing.Condition, required.Condition) { + ensureOperatorStatusStatus(modified, &existing.Status, required.Status) +} + +func ensureOperatorStatusStatus(modified *bool, existing *osv1.ClusterOperatorStatus, required osv1.ClusterOperatorStatus) { + if !equality.Semantic.DeepEqual(existing.Conditions, required.Conditions) { *modified = true - existing.Condition = required.Condition + existing.Conditions = required.Conditions } if existing.Version != required.Version { *modified = true existing.Version = required.Version } - if !existing.LastUpdate.Equal(&required.LastUpdate) { - *modified = true - existing.LastUpdate = required.LastUpdate - } if !equality.Semantic.DeepEqual(existing.Extension.Raw, required.Extension.Raw) { *modified = true existing.Extension.Raw = required.Extension.Raw @@ -28,3 +32,64 @@ func EnsureOperatorStatus(modified *bool, existing *osv1.OperatorStatus, require existing.Extension.Object = required.Extension.Object } } + +func SetOperatorStatusCondition(conditions *[]osv1.ClusterOperatorStatusCondition, newCondition osv1.ClusterOperatorStatusCondition) { + if conditions == nil { + conditions = &[]osv1.ClusterOperatorStatusCondition{} + } + existingCondition := FindOperatorStatusCondition(*conditions, newCondition.Type) + if existingCondition == nil { + newCondition.LastTransitionTime = metav1.NewTime(time.Now()) + *conditions = append(*conditions, newCondition) + return + } + + if existingCondition.Status != newCondition.Status { + existingCondition.Status = newCondition.Status + existingCondition.LastTransitionTime = newCondition.LastTransitionTime + } + + existingCondition.Reason = newCondition.Reason + existingCondition.Message = newCondition.Message +} + +func RemoveOperatorStatusCondition(conditions *[]osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) { + if conditions == nil { + conditions = &[]osv1.ClusterOperatorStatusCondition{} + } + newConditions := []osv1.ClusterOperatorStatusCondition{} + for _, condition := range *conditions { + if condition.Type != conditionType { + newConditions = append(newConditions, condition) + } + } + + *conditions = newConditions +} + +func FindOperatorStatusCondition(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) *osv1.ClusterOperatorStatusCondition { + for i := range conditions { + if conditions[i].Type == conditionType { + return &conditions[i] + } + } + + return nil +} + +func IsOperatorStatusConditionTrue(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) bool { + return IsOperatorStatusConditionPresentAndEqual(conditions, conditionType, osv1.ConditionTrue) +} + +func IsOperatorStatusConditionFalse(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) bool { + return IsOperatorStatusConditionPresentAndEqual(conditions, conditionType, osv1.ConditionFalse) +} + +func IsOperatorStatusConditionPresentAndEqual(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType, status osv1.ConditionStatus) bool { + for _, condition := range conditions { + if condition.Type == conditionType { + return condition.Status == status + } + } + return false +} diff --git a/pkg/apis/operatorstatus.openshift.io/v1/register.go b/pkg/apis/operatorstatus.openshift.io/v1/register.go index b3ac773517..c3d1c82e00 100644 --- a/pkg/apis/operatorstatus.openshift.io/v1/register.go +++ b/pkg/apis/operatorstatus.openshift.io/v1/register.go @@ -36,8 +36,8 @@ func init() { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &OperatorStatus{}, - &OperatorStatusList{}, + &ClusterOperator{}, + &ClusterOperatorList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/apis/operatorstatus.openshift.io/v1/types.go b/pkg/apis/operatorstatus.openshift.io/v1/types.go index 8ec547e17f..75083bfad2 100644 --- a/pkg/apis/operatorstatus.openshift.io/v1/types.go +++ b/pkg/apis/operatorstatus.openshift.io/v1/types.go @@ -5,72 +5,102 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) -// OperatorStatusList is a list of OperatorStatus resources. +// ClusterOperatorList is a list of OperatorStatus resources. // +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type OperatorStatusList struct { +type ClusterOperatorList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` - Items []OperatorStatus `json:"items"` + Items []ClusterOperator `json:"items"` } -// OperatorStatus is the Custom Resource object which holds the current state +// ClusterOperator is the Custom Resource object which holds the current state // of an operator. This object is used by operators to convey their state to // the rest of the cluster. // +genclient // +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type OperatorStatus struct { +type ClusterOperator struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` - // Condition describes the state of the operator's reconciliation - // functionality. - Condition OperatorStatusCondition `json:"condition"` + // Spec hold the intent of how this operator should behave. + Spec ClusterOperatorSpec `json:"spec"` - // Version indicates which version of the operator updated the current + // status holds the information about the state of an operator. It is consistent with status information across + // the kube ecosystem. + Status ClusterOperatorStatus `json:"status"` +} + +// ClusterOperatorSpec is empty for now, but you could imagine holding information like "pause". +type ClusterOperatorSpec struct { +} + +// ClusterOperatorStatus provides information about the status of the operator. +// +k8s:deepcopy-gen=true +type ClusterOperatorStatus struct { + // conditions describes the state of the operator's reconciliation functionality. + // +patchMergeKey=type + // +patchStrategy=merge + Conditions []ClusterOperatorStatusCondition `json:"conditions"` + + // version indicates which version of the operator updated the current // status object. Version string `json:"version"` - // LasteUpdate is the time of the last update to the current status object. - LastUpdate metav1.Time `json:"lastUpdate"` - - // Extension contains any additional status information specific to the + // extension contains any additional status information specific to the // operator which owns this status object. - Extension runtime.RawExtension `json:"extension"` + Extension runtime.RawExtension `json:"extension,omitempty"` } -// OperatorStatusCondition represents the state of the operator's +type ConditionStatus string + +// These are valid condition statuses. "ConditionTrue" means a resource is in the condition. +// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes +// can't decide if a resource is in the condition or not. In the future, we could add other +// intermediate conditions, e.g. ConditionDegraded. +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// ClusterOperatorStatusCondition represents the state of the operator's // reconciliation functionality. -type OperatorStatusCondition struct { - // Type specifies the state of the operator's reconciliation functionality. - Type OperatorStatusConditionType `json:"type"` +// +k8s:deepcopy-gen=true +type ClusterOperatorStatusCondition struct { + // type specifies the state of the operator's reconciliation functionality. + Type ClusterStatusConditionType `json:"type"` + + // Status of the condition, one of True, False, Unknown. + Status ConditionStatus `json:"status"` - // Message provides any additional information about the current condition. + // LastTransitionTime is the time of the last update to the current status object. + LastTransitionTime metav1.Time `json:"lastTransitionTime"` + + // reason is the reason for the condition's last transition. Reasons are CamelCase + Reason string `json:"reason,omitempty"` + + // message provides additional information about the current condition. // This is only to be consumed by humans. - Message string `json:"message"` + Message string `json:"message,omitempty"` } -// OperatorStatusConditionType is the state of the operator's reconciliation -// functionality. -type OperatorStatusConditionType string +// ClusterStatusConditionType is the state of the operator's reconciliation functionality. +type ClusterStatusConditionType string const ( - // OperatorStatusConditionTypeWaiting indicates that the operator isn't - // running its reconciliation functionality. This may be because a - // dependency or other prerequisite hasn't been satisfied. - OperatorStatusConditionTypeWaiting OperatorStatusConditionType = "Waiting" - - // OperatorStatusConditionTypeWorking indicates that the operator is - // actively reconciling its operands. - OperatorStatusConditionTypeWorking OperatorStatusConditionType = "Working" - - // OperatorStatusConditionTypeDone indicates that the operator has finished - // reconciling its operands and is waiting for changes. - OperatorStatusConditionTypeDone OperatorStatusConditionType = "Done" - - // OperatorStatusConditionTypeDegraded indicates that the operator has - // encountered an error that is preventing it from working properly. - OperatorStatusConditionTypeDegraded OperatorStatusConditionType = "Degraded" + // OperatorAvailable indicates that the binary maintained by the operator (eg: openshift-apiserver for the + // openshift-apiserver-operator), is functional and available in the cluster. + OperatorAvailable ClusterStatusConditionType = "Available" + + // OperatorProgressing indicates that the operator is actively making changes to the binary maintained by the + // operator (eg: openshift-apiserver for the openshift-apiserver-operator). + OperatorProgressing ClusterStatusConditionType = "Progressing" + + // OperatorFailing indicates that the operator has encountered an error that is preventing it from working properly. + // The binary maintained by the operator (eg: openshift-apiserver for the openshift-apiserver-operator) may still be + // available, but the user intent cannot be fulfilled. + OperatorFailing ClusterStatusConditionType = "Failing" ) diff --git a/pkg/apis/operatorstatus.openshift.io/v1/zz_generated.deepcopy.go b/pkg/apis/operatorstatus.openshift.io/v1/zz_generated.deepcopy.go index bf90988003..400e0e54b6 100644 --- a/pkg/apis/operatorstatus.openshift.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/operatorstatus.openshift.io/v1/zz_generated.deepcopy.go @@ -25,28 +25,27 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorStatus) DeepCopyInto(out *OperatorStatus) { +func (in *ClusterOperator) DeepCopyInto(out *ClusterOperator) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Condition = in.Condition - in.LastUpdate.DeepCopyInto(&out.LastUpdate) - in.Extension.DeepCopyInto(&out.Extension) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatus. -func (in *OperatorStatus) DeepCopy() *OperatorStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOperator. +func (in *ClusterOperator) DeepCopy() *ClusterOperator { if in == nil { return nil } - out := new(OperatorStatus) + out := new(ClusterOperator) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorStatus) DeepCopyObject() runtime.Object { +func (in *ClusterOperator) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -54,13 +53,13 @@ func (in *OperatorStatus) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorStatusList) DeepCopyInto(out *OperatorStatusList) { +func (in *ClusterOperatorList) DeepCopyInto(out *ClusterOperatorList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]OperatorStatus, len(*in)) + *out = make([]ClusterOperator, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -68,20 +67,61 @@ func (in *OperatorStatusList) DeepCopyInto(out *OperatorStatusList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatusList. -func (in *OperatorStatusList) DeepCopy() *OperatorStatusList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOperatorList. +func (in *ClusterOperatorList) DeepCopy() *ClusterOperatorList { if in == nil { return nil } - out := new(OperatorStatusList) + out := new(ClusterOperatorList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OperatorStatusList) DeepCopyObject() runtime.Object { +func (in *ClusterOperatorList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterOperatorStatus) DeepCopyInto(out *ClusterOperatorStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ClusterOperatorStatusCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.Extension.DeepCopyInto(&out.Extension) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOperatorStatus. +func (in *ClusterOperatorStatus) DeepCopy() *ClusterOperatorStatus { + if in == nil { + return nil + } + out := new(ClusterOperatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterOperatorStatusCondition) DeepCopyInto(out *ClusterOperatorStatusCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOperatorStatusCondition. +func (in *ClusterOperatorStatusCondition) DeepCopy() *ClusterOperatorStatusCondition { + if in == nil { + return nil + } + out := new(ClusterOperatorStatusCondition) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index 1475e38500..8689bbdf96 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -38,7 +38,7 @@ const ( // Controller defines autoupdate controller. type Controller struct { - // namespace and name are used to find the CVOConfig, OperatorStatus. + // namespace and name are used to find the CVOConfig, ClusterOperator. namespace, name string client clientset.Interface @@ -46,8 +46,8 @@ type Controller struct { syncHandler func(key string) error - cvoConfigLister cvlistersv1.CVOConfigLister - operatorStatusLister oslistersv1.OperatorStatusLister + cvoConfigLister cvlistersv1.CVOConfigLister + clusterOperatorLister oslistersv1.ClusterOperatorLister cvoConfigListerSynced cache.InformerSynced operatorStatusSynced cache.InformerSynced @@ -60,7 +60,7 @@ type Controller struct { func New( namespace, name string, cvoConfigInformer cvinformersv1.CVOConfigInformer, - operatorStatusInformer osinformersv1.OperatorStatusInformer, + clusterOperatorInformer osinformersv1.ClusterOperatorInformer, client clientset.Interface, kubeClient kubernetes.Interface, ) *Controller { @@ -77,15 +77,15 @@ func New( } cvoConfigInformer.Informer().AddEventHandler(ctrl.eventHandler()) - operatorStatusInformer.Informer().AddEventHandler(ctrl.eventHandler()) + clusterOperatorInformer.Informer().AddEventHandler(ctrl.eventHandler()) ctrl.syncHandler = ctrl.sync ctrl.cvoConfigLister = cvoConfigInformer.Lister() - ctrl.operatorStatusLister = operatorStatusInformer.Lister() + ctrl.clusterOperatorLister = clusterOperatorInformer.Lister() ctrl.cvoConfigListerSynced = cvoConfigInformer.Informer().HasSynced - ctrl.operatorStatusSynced = operatorStatusInformer.Informer().HasSynced + ctrl.operatorStatusSynced = clusterOperatorInformer.Informer().HasSynced return ctrl } @@ -168,9 +168,9 @@ func (ctrl *Controller) sync(key string) error { return err } - operatorstatus, err := ctrl.operatorStatusLister.OperatorStatuses(namespace).Get(name) + operatorstatus, err := ctrl.clusterOperatorLister.ClusterOperators(namespace).Get(name) if errors.IsNotFound(err) { - glog.V(2).Infof("OperatorStatus %v has been deleted", key) + glog.V(2).Infof("ClusterOperator %v has been deleted", key) return nil } if err != nil { @@ -192,7 +192,7 @@ func (ctrl *Controller) sync(key string) error { config := new(v1.CVOConfig) cvoconfig.DeepCopyInto(config) - obji, _, err := scheme.Codecs.UniversalDecoder().Decode(ops.Extension.Raw, nil, &v1.CVOStatus{}) + obji, _, err := scheme.Codecs.UniversalDecoder().Decode(ops.Status.Extension.Raw, nil, &v1.CVOStatus{}) if err != nil { return fmt.Errorf("unable to decode CVOStatus from extension.Raw: %v", err) } diff --git a/pkg/cvo/cvo.go b/pkg/cvo/cvo.go index 2c082cfd6d..e41da786b1 100644 --- a/pkg/cvo/cvo.go +++ b/pkg/cvo/cvo.go @@ -26,7 +26,6 @@ import ( "github.com/openshift/cluster-version-operator/lib/resourceapply" cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1" - osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" clientset "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned" cvinformersv1 "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1" osinformersv1 "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1" @@ -65,7 +64,7 @@ type Operator struct { syncHandler func(key string) error - operatorStatusLister oslistersv1.OperatorStatusLister + clusterOperatorLister oslistersv1.ClusterOperatorLister crdLister apiextlistersv1beta1.CustomResourceDefinitionLister deployLister appslisterv1.DeploymentLister @@ -84,7 +83,7 @@ func New( namespace, name string, releaseImage string, cvoConfigInformer cvinformersv1.CVOConfigInformer, - operatorStatusInformer osinformersv1.OperatorStatusInformer, + clusterOperatorInformer osinformersv1.ClusterOperatorInformer, crdInformer apiextinformersv1beta1.CustomResourceDefinitionInformer, deployInformer appsinformersv1.DeploymentInformer, restConfig *rest.Config, @@ -114,7 +113,7 @@ func New( optr.syncHandler = optr.sync - optr.operatorStatusLister = operatorStatusInformer.Lister() + optr.clusterOperatorLister = clusterOperatorInformer.Lister() optr.crdLister = crdInformer.Lister() optr.crdListerSynced = crdInformer.Informer().HasSynced @@ -223,7 +222,7 @@ func (optr *Operator) sync(key string) error { config := &cvv1.CVOConfig{} obj.DeepCopyInto(config) - if err := optr.syncStatus(config, osv1.OperatorStatusCondition{Type: osv1.OperatorStatusConditionTypeWorking, Message: fmt.Sprintf("Working towards %s", config)}); err != nil { + if err := optr.syncProgressingStatus(config); err != nil { return err } @@ -244,7 +243,7 @@ func (optr *Operator) sync(key string) error { return err } - return optr.syncStatus(config, osv1.OperatorStatusCondition{Type: osv1.OperatorStatusConditionTypeDone, Message: fmt.Sprintf("Done applying %s", config)}) + return optr.syncAvailableStatus(config) } func (optr *Operator) getConfig() (*cvv1.CVOConfig, error) { diff --git a/pkg/cvo/internal/operatorstatus.go b/pkg/cvo/internal/operatorstatus.go index 45b07d4545..81d6704b0b 100644 --- a/pkg/cvo/internal/operatorstatus.go +++ b/pkg/cvo/internal/operatorstatus.go @@ -3,6 +3,8 @@ package internal import ( "time" + "github.com/davecgh/go-spew/spew" + "github.com/golang/glog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -33,12 +35,12 @@ func init() { } // readOperatorStatusV1OrDie reads operatorstatus object from bytes. Panics on error. -func readOperatorStatusV1OrDie(objBytes []byte) *osv1.OperatorStatus { +func readOperatorStatusV1OrDie(objBytes []byte) *osv1.ClusterOperator { requiredObj, err := runtime.Decode(osCodecs.UniversalDecoder(osv1.SchemeGroupVersion), objBytes) if err != nil { panic(err) } - return requiredObj.(*osv1.OperatorStatus) + return requiredObj.(*osv1.ClusterOperator) } type operatorStatusBuilder struct { @@ -73,21 +75,41 @@ const ( osPollTimeout = 1 * time.Minute ) -func waitForOperatorStatusToBeDone(client osclientv1.OperatorStatusesGetter, os *osv1.OperatorStatus) error { +func waitForOperatorStatusToBeDone(client osclientv1.ClusterOperatorsGetter, os *osv1.ClusterOperator) error { return wait.Poll(osPollInternal, osPollTimeout, func() (bool, error) { - eos, err := client.OperatorStatuses(os.Namespace).Get(os.Name, metav1.GetOptions{}) + eos, err := client.ClusterOperators(os.Namespace).Get(os.Name, metav1.GetOptions{}) if err != nil { return false, err } + glog.V(4).Infof("OperatorStatus %s/%s is reporting %v", + eos.Namespace, eos.Name, spew.Sdump(eos.Status)) + + if eos.Status.Version != os.Status.Version { + return false, nil + } - if eos.Version == os.Version && eos.Condition.Type == osv1.OperatorStatusConditionTypeDone { + available := false + progressing := true + failing := true + for _, condition := range eos.Status.Conditions { + switch { + case condition.Type == osv1.OperatorAvailable && condition.Status == osv1.ConditionTrue: + available = true + case condition.Type == osv1.OperatorProgressing && condition.Status == osv1.ConditionFalse: + progressing = false + case condition.Type == osv1.OperatorFailing && condition.Status == osv1.ConditionFalse: + failing = false + } + } + + // if we're at the correct version, and available, not progressing, and not failing, we are done + if available && !progressing && !failing { return true, nil } - glog.V(4).Infof("OperatorStatus %s/%s is not reporting %s for version %s; it is reporting %s for version %s", - eos.Namespace, eos.Name, - osv1.OperatorStatusConditionTypeDone, os.Version, - eos.Condition.Type, eos.Version, - ) + glog.V(3).Infof("OperatorStatus %s/%s is not done for version %s; it is version=%v, available=%v, progressing=%v, failing=%v", + eos.Namespace, eos.Name, os.Status.Version, + eos.Status.Version, available, progressing, failing) + return false, nil }) } diff --git a/pkg/cvo/status.go b/pkg/cvo/status.go index 0ca3d01f92..c10d15ee80 100644 --- a/pkg/cvo/status.go +++ b/pkg/cvo/status.go @@ -5,20 +5,55 @@ import ( "github.com/google/uuid" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "github.com/openshift/cluster-version-operator/lib/resourceapply" + "github.com/openshift/cluster-version-operator/lib/resourcemerge" cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1" osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" "github.com/openshift/cluster-version-operator/pkg/cincinnati" "github.com/openshift/cluster-version-operator/pkg/version" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" ) -func (optr *Operator) syncStatus(config *cvv1.CVOConfig, cond osv1.OperatorStatusCondition) error { - if cond.Type == osv1.OperatorStatusConditionTypeDegraded { - return fmt.Errorf("invalid cond %s", cond.Type) +func (optr *Operator) syncProgressingStatus(config *cvv1.CVOConfig) error { + var cvoUpdates []cvv1.Update + if updates, err := checkForUpdate(*config); err == nil { + for _, update := range updates { + cvoUpdates = append(cvoUpdates, cvv1.Update{ + Version: update.Version.String(), + Payload: update.Payload, + }) + } + } + + status := &osv1.ClusterOperator{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: optr.namespace, + Name: optr.name, + }, + Status: osv1.ClusterOperatorStatus{ + Version: version.Raw, + Extension: runtime.RawExtension{ + Raw: nil, + Object: &cvv1.CVOStatus{ + AvailableUpdates: cvoUpdates, + }, + }, + }, } + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{Type: osv1.OperatorAvailable, Status: osv1.ConditionFalse}) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{ + Type: osv1.OperatorProgressing, Status: osv1.ConditionTrue, + Message: fmt.Sprintf("Working towards %s", config), + }) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{Type: osv1.OperatorFailing, Status: osv1.ConditionFalse}) + _, _, err := resourceapply.ApplyOperatorStatusFromCache(optr.clusterOperatorLister, optr.client.OperatorstatusV1(), status) + return err +} + +func (optr *Operator) syncAvailableStatus(config *cvv1.CVOConfig) error { var cvoUpdates []cvv1.Update if updates, err := checkForUpdate(*config); err == nil { for _, update := range updates { @@ -29,22 +64,29 @@ func (optr *Operator) syncStatus(config *cvv1.CVOConfig, cond osv1.OperatorStatu } } - status := &osv1.OperatorStatus{ + status := &osv1.ClusterOperator{ ObjectMeta: metav1.ObjectMeta{ Namespace: optr.namespace, Name: optr.name, }, - Condition: cond, - Version: version.Raw, - LastUpdate: metav1.Now(), - Extension: runtime.RawExtension{ - Raw: nil, - Object: &cvv1.CVOStatus{ - AvailableUpdates: cvoUpdates, + Status: osv1.ClusterOperatorStatus{ + Version: version.Raw, + Extension: runtime.RawExtension{ + Raw: nil, + Object: &cvv1.CVOStatus{ + AvailableUpdates: cvoUpdates, + }, }, }, } - _, _, err := resourceapply.ApplyOperatorStatusFromCache(optr.operatorStatusLister, optr.client.OperatorstatusV1(), status) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{ + Type: osv1.OperatorAvailable, Status: osv1.ConditionTrue, + Message: fmt.Sprintf("Done applying %s", config), + }) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{Type: osv1.OperatorProgressing, Status: osv1.ConditionFalse}) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{Type: osv1.OperatorFailing, Status: osv1.ConditionFalse}) + + _, _, err := resourceapply.ApplyOperatorStatusFromCache(optr.clusterOperatorLister, optr.client.OperatorstatusV1(), status) return err } @@ -55,22 +97,25 @@ func (optr *Operator) syncDegradedStatus(ierr error) error { if ierr == nil { return nil } - cond := osv1.OperatorStatusCondition{ - Type: osv1.OperatorStatusConditionTypeDegraded, - Message: fmt.Sprintf("error syncing: %v", ierr), - } - status := &osv1.OperatorStatus{ + status := &osv1.ClusterOperator{ ObjectMeta: metav1.ObjectMeta{ Namespace: optr.namespace, Name: optr.name, }, - Condition: cond, - Version: version.Raw, - LastUpdate: metav1.Now(), - Extension: runtime.RawExtension{}, + Status: osv1.ClusterOperatorStatus{ + Version: version.Raw, + Extension: runtime.RawExtension{}, + }, } - _, _, err := resourceapply.ApplyOperatorStatusFromCache(optr.operatorStatusLister, optr.client.OperatorstatusV1(), status) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{Type: osv1.OperatorAvailable, Status: osv1.ConditionFalse}) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{Type: osv1.OperatorProgressing, Status: osv1.ConditionFalse}) + resourcemerge.SetOperatorStatusCondition(&status.Status.Conditions, osv1.ClusterOperatorStatusCondition{ + Type: osv1.OperatorFailing, Status: osv1.ConditionTrue, + Message: fmt.Sprintf("error syncing: %v", ierr), + }) + + _, _, err := resourceapply.ApplyOperatorStatusFromCache(optr.clusterOperatorLister, optr.client.OperatorstatusV1(), status) if err != nil { return err } diff --git a/pkg/cvo/sync.go b/pkg/cvo/sync.go index 729826a301..dfbf68ddfa 100644 --- a/pkg/cvo/sync.go +++ b/pkg/cvo/sync.go @@ -83,23 +83,42 @@ func ownerRefModifier(config *cvv1.CVOConfig) resourcebuilder.MetaV1ObjectModifi } func (optr *Operator) syncCustomResourceDefinitions() error { - crds := []*apiextv1beta1.CustomResourceDefinition{{ - ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("operatorstatuses.%s", apis.OperatorStatusGroupName), - Namespace: metav1.NamespaceDefault, + crds := []*apiextv1beta1.CustomResourceDefinition{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("operatorstatuses.%s", apis.OperatorStatusGroupName), + Namespace: metav1.NamespaceDefault, + }, + Spec: apiextv1beta1.CustomResourceDefinitionSpec{ + Group: apis.OperatorStatusGroupName, + Version: "v1", + Scope: "Namespaced", + Names: apiextv1beta1.CustomResourceDefinitionNames{ + Plural: "operatorstatuses", + Singular: "operatorstatus", + Kind: "OperatorStatus", + ListKind: "OperatorStatusList", + }, + }, }, - Spec: apiextv1beta1.CustomResourceDefinitionSpec{ - Group: apis.OperatorStatusGroupName, - Version: "v1", - Scope: "Namespaced", - Names: apiextv1beta1.CustomResourceDefinitionNames{ - Plural: "operatorstatuses", - Singular: "operatorstatus", - Kind: "OperatorStatus", - ListKind: "OperatorStatusList", + { + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("clusteroperators.%s", apis.OperatorStatusGroupName), + Namespace: metav1.NamespaceDefault, + }, + Spec: apiextv1beta1.CustomResourceDefinitionSpec{ + Group: apis.OperatorStatusGroupName, + Version: "v1", + Scope: "Namespaced", + Names: apiextv1beta1.CustomResourceDefinitionNames{ + Plural: "clusteroperators", + Singular: "clusteroperator", + Kind: "ClusterOperator", + ListKind: "ClusterOperatorList", + }, }, }, - }} + } for _, crd := range crds { _, updated, err := resourceapply.ApplyCustomResourceDefinitionFromCache(optr.crdLister, optr.apiExtClient.ApiextensionsV1beta1(), crd) diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/clusteroperator.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/clusteroperator.go new file mode 100644 index 0000000000..5694c3f747 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/clusteroperator.go @@ -0,0 +1,174 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" + scheme "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ClusterOperatorsGetter has a method to return a ClusterOperatorInterface. +// A group's client should implement this interface. +type ClusterOperatorsGetter interface { + ClusterOperators(namespace string) ClusterOperatorInterface +} + +// ClusterOperatorInterface has methods to work with ClusterOperator resources. +type ClusterOperatorInterface interface { + Create(*v1.ClusterOperator) (*v1.ClusterOperator, error) + Update(*v1.ClusterOperator) (*v1.ClusterOperator, error) + UpdateStatus(*v1.ClusterOperator) (*v1.ClusterOperator, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.ClusterOperator, error) + List(opts metav1.ListOptions) (*v1.ClusterOperatorList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterOperator, err error) + ClusterOperatorExpansion +} + +// clusterOperators implements ClusterOperatorInterface +type clusterOperators struct { + client rest.Interface + ns string +} + +// newClusterOperators returns a ClusterOperators +func newClusterOperators(c *OperatorstatusV1Client, namespace string) *clusterOperators { + return &clusterOperators{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the clusterOperator, and returns the corresponding clusterOperator object, and an error if there is any. +func (c *clusterOperators) Get(name string, options metav1.GetOptions) (result *v1.ClusterOperator, err error) { + result = &v1.ClusterOperator{} + err = c.client.Get(). + Namespace(c.ns). + Resource("clusteroperators"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterOperators that match those selectors. +func (c *clusterOperators) List(opts metav1.ListOptions) (result *v1.ClusterOperatorList, err error) { + result = &v1.ClusterOperatorList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("clusteroperators"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterOperators. +func (c *clusterOperators) Watch(opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("clusteroperators"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a clusterOperator and creates it. Returns the server's representation of the clusterOperator, and an error, if there is any. +func (c *clusterOperators) Create(clusterOperator *v1.ClusterOperator) (result *v1.ClusterOperator, err error) { + result = &v1.ClusterOperator{} + err = c.client.Post(). + Namespace(c.ns). + Resource("clusteroperators"). + Body(clusterOperator). + Do(). + Into(result) + return +} + +// Update takes the representation of a clusterOperator and updates it. Returns the server's representation of the clusterOperator, and an error, if there is any. +func (c *clusterOperators) Update(clusterOperator *v1.ClusterOperator) (result *v1.ClusterOperator, err error) { + result = &v1.ClusterOperator{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusteroperators"). + Name(clusterOperator.Name). + Body(clusterOperator). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *clusterOperators) UpdateStatus(clusterOperator *v1.ClusterOperator) (result *v1.ClusterOperator, err error) { + result = &v1.ClusterOperator{} + err = c.client.Put(). + Namespace(c.ns). + Resource("clusteroperators"). + Name(clusterOperator.Name). + SubResource("status"). + Body(clusterOperator). + Do(). + Into(result) + return +} + +// Delete takes name of the clusterOperator and deletes it. Returns an error if one occurs. +func (c *clusterOperators) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("clusteroperators"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterOperators) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("clusteroperators"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched clusterOperator. +func (c *clusterOperators) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ClusterOperator, err error) { + result = &v1.ClusterOperator{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("clusteroperators"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_clusteroperator.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_clusteroperator.go new file mode 100644 index 0000000000..4f3079510f --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_clusteroperator.go @@ -0,0 +1,140 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + operatorstatusopenshiftiov1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeClusterOperators implements ClusterOperatorInterface +type FakeClusterOperators struct { + Fake *FakeOperatorstatusV1 + ns string +} + +var clusteroperatorsResource = schema.GroupVersionResource{Group: "operatorstatus.openshift.io", Version: "v1", Resource: "clusteroperators"} + +var clusteroperatorsKind = schema.GroupVersionKind{Group: "operatorstatus.openshift.io", Version: "v1", Kind: "ClusterOperator"} + +// Get takes name of the clusterOperator, and returns the corresponding clusterOperator object, and an error if there is any. +func (c *FakeClusterOperators) Get(name string, options v1.GetOptions) (result *operatorstatusopenshiftiov1.ClusterOperator, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(clusteroperatorsResource, c.ns, name), &operatorstatusopenshiftiov1.ClusterOperator{}) + + if obj == nil { + return nil, err + } + return obj.(*operatorstatusopenshiftiov1.ClusterOperator), err +} + +// List takes label and field selectors, and returns the list of ClusterOperators that match those selectors. +func (c *FakeClusterOperators) List(opts v1.ListOptions) (result *operatorstatusopenshiftiov1.ClusterOperatorList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(clusteroperatorsResource, clusteroperatorsKind, c.ns, opts), &operatorstatusopenshiftiov1.ClusterOperatorList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &operatorstatusopenshiftiov1.ClusterOperatorList{ListMeta: obj.(*operatorstatusopenshiftiov1.ClusterOperatorList).ListMeta} + for _, item := range obj.(*operatorstatusopenshiftiov1.ClusterOperatorList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested clusterOperators. +func (c *FakeClusterOperators) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(clusteroperatorsResource, c.ns, opts)) + +} + +// Create takes the representation of a clusterOperator and creates it. Returns the server's representation of the clusterOperator, and an error, if there is any. +func (c *FakeClusterOperators) Create(clusterOperator *operatorstatusopenshiftiov1.ClusterOperator) (result *operatorstatusopenshiftiov1.ClusterOperator, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(clusteroperatorsResource, c.ns, clusterOperator), &operatorstatusopenshiftiov1.ClusterOperator{}) + + if obj == nil { + return nil, err + } + return obj.(*operatorstatusopenshiftiov1.ClusterOperator), err +} + +// Update takes the representation of a clusterOperator and updates it. Returns the server's representation of the clusterOperator, and an error, if there is any. +func (c *FakeClusterOperators) Update(clusterOperator *operatorstatusopenshiftiov1.ClusterOperator) (result *operatorstatusopenshiftiov1.ClusterOperator, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(clusteroperatorsResource, c.ns, clusterOperator), &operatorstatusopenshiftiov1.ClusterOperator{}) + + if obj == nil { + return nil, err + } + return obj.(*operatorstatusopenshiftiov1.ClusterOperator), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeClusterOperators) UpdateStatus(clusterOperator *operatorstatusopenshiftiov1.ClusterOperator) (*operatorstatusopenshiftiov1.ClusterOperator, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(clusteroperatorsResource, "status", c.ns, clusterOperator), &operatorstatusopenshiftiov1.ClusterOperator{}) + + if obj == nil { + return nil, err + } + return obj.(*operatorstatusopenshiftiov1.ClusterOperator), err +} + +// Delete takes name of the clusterOperator and deletes it. Returns an error if one occurs. +func (c *FakeClusterOperators) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(clusteroperatorsResource, c.ns, name), &operatorstatusopenshiftiov1.ClusterOperator{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterOperators) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(clusteroperatorsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &operatorstatusopenshiftiov1.ClusterOperatorList{}) + return err +} + +// Patch applies the patch and returns the patched clusterOperator. +func (c *FakeClusterOperators) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *operatorstatusopenshiftiov1.ClusterOperator, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(clusteroperatorsResource, c.ns, name, data, subresources...), &operatorstatusopenshiftiov1.ClusterOperator{}) + + if obj == nil { + return nil, err + } + return obj.(*operatorstatusopenshiftiov1.ClusterOperator), err +} diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.go deleted file mode 100644 index c3d1ad4688..0000000000 --- a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.go +++ /dev/null @@ -1,128 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - operatorstatusopenshiftiov1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeOperatorStatuses implements OperatorStatusInterface -type FakeOperatorStatuses struct { - Fake *FakeOperatorstatusV1 - ns string -} - -var operatorstatusesResource = schema.GroupVersionResource{Group: "operatorstatus.openshift.io", Version: "v1", Resource: "operatorstatuses"} - -var operatorstatusesKind = schema.GroupVersionKind{Group: "operatorstatus.openshift.io", Version: "v1", Kind: "OperatorStatus"} - -// Get takes name of the operatorStatus, and returns the corresponding operatorStatus object, and an error if there is any. -func (c *FakeOperatorStatuses) Get(name string, options v1.GetOptions) (result *operatorstatusopenshiftiov1.OperatorStatus, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(operatorstatusesResource, c.ns, name), &operatorstatusopenshiftiov1.OperatorStatus{}) - - if obj == nil { - return nil, err - } - return obj.(*operatorstatusopenshiftiov1.OperatorStatus), err -} - -// List takes label and field selectors, and returns the list of OperatorStatuses that match those selectors. -func (c *FakeOperatorStatuses) List(opts v1.ListOptions) (result *operatorstatusopenshiftiov1.OperatorStatusList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(operatorstatusesResource, operatorstatusesKind, c.ns, opts), &operatorstatusopenshiftiov1.OperatorStatusList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &operatorstatusopenshiftiov1.OperatorStatusList{ListMeta: obj.(*operatorstatusopenshiftiov1.OperatorStatusList).ListMeta} - for _, item := range obj.(*operatorstatusopenshiftiov1.OperatorStatusList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested operatorStatuses. -func (c *FakeOperatorStatuses) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(operatorstatusesResource, c.ns, opts)) - -} - -// Create takes the representation of a operatorStatus and creates it. Returns the server's representation of the operatorStatus, and an error, if there is any. -func (c *FakeOperatorStatuses) Create(operatorStatus *operatorstatusopenshiftiov1.OperatorStatus) (result *operatorstatusopenshiftiov1.OperatorStatus, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(operatorstatusesResource, c.ns, operatorStatus), &operatorstatusopenshiftiov1.OperatorStatus{}) - - if obj == nil { - return nil, err - } - return obj.(*operatorstatusopenshiftiov1.OperatorStatus), err -} - -// Update takes the representation of a operatorStatus and updates it. Returns the server's representation of the operatorStatus, and an error, if there is any. -func (c *FakeOperatorStatuses) Update(operatorStatus *operatorstatusopenshiftiov1.OperatorStatus) (result *operatorstatusopenshiftiov1.OperatorStatus, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(operatorstatusesResource, c.ns, operatorStatus), &operatorstatusopenshiftiov1.OperatorStatus{}) - - if obj == nil { - return nil, err - } - return obj.(*operatorstatusopenshiftiov1.OperatorStatus), err -} - -// Delete takes name of the operatorStatus and deletes it. Returns an error if one occurs. -func (c *FakeOperatorStatuses) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(operatorstatusesResource, c.ns, name), &operatorstatusopenshiftiov1.OperatorStatus{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeOperatorStatuses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(operatorstatusesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &operatorstatusopenshiftiov1.OperatorStatusList{}) - return err -} - -// Patch applies the patch and returns the patched operatorStatus. -func (c *FakeOperatorStatuses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *operatorstatusopenshiftiov1.OperatorStatus, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(operatorstatusesResource, c.ns, name, data, subresources...), &operatorstatusopenshiftiov1.OperatorStatus{}) - - if obj == nil { - return nil, err - } - return obj.(*operatorstatusopenshiftiov1.OperatorStatus), err -} diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.openshift.io_client.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.openshift.io_client.go index f397dd9eae..835fcddc6d 100644 --- a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.openshift.io_client.go +++ b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/fake/fake_operatorstatus.openshift.io_client.go @@ -28,8 +28,8 @@ type FakeOperatorstatusV1 struct { *testing.Fake } -func (c *FakeOperatorstatusV1) OperatorStatuses(namespace string) v1.OperatorStatusInterface { - return &FakeOperatorStatuses{c, namespace} +func (c *FakeOperatorstatusV1) ClusterOperators(namespace string) v1.ClusterOperatorInterface { + return &FakeClusterOperators{c, namespace} } // RESTClient returns a RESTClient that is used to communicate diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/generated_expansion.go index 7730d680eb..468407f3f9 100644 --- a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/generated_expansion.go @@ -18,4 +18,4 @@ limitations under the License. package v1 -type OperatorStatusExpansion interface{} +type ClusterOperatorExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.go deleted file mode 100644 index 9140761a69..0000000000 --- a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.go +++ /dev/null @@ -1,157 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - v1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" - scheme "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// OperatorStatusesGetter has a method to return a OperatorStatusInterface. -// A group's client should implement this interface. -type OperatorStatusesGetter interface { - OperatorStatuses(namespace string) OperatorStatusInterface -} - -// OperatorStatusInterface has methods to work with OperatorStatus resources. -type OperatorStatusInterface interface { - Create(*v1.OperatorStatus) (*v1.OperatorStatus, error) - Update(*v1.OperatorStatus) (*v1.OperatorStatus, error) - Delete(name string, options *metav1.DeleteOptions) error - DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error - Get(name string, options metav1.GetOptions) (*v1.OperatorStatus, error) - List(opts metav1.ListOptions) (*v1.OperatorStatusList, error) - Watch(opts metav1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.OperatorStatus, err error) - OperatorStatusExpansion -} - -// operatorStatuses implements OperatorStatusInterface -type operatorStatuses struct { - client rest.Interface - ns string -} - -// newOperatorStatuses returns a OperatorStatuses -func newOperatorStatuses(c *OperatorstatusV1Client, namespace string) *operatorStatuses { - return &operatorStatuses{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the operatorStatus, and returns the corresponding operatorStatus object, and an error if there is any. -func (c *operatorStatuses) Get(name string, options metav1.GetOptions) (result *v1.OperatorStatus, err error) { - result = &v1.OperatorStatus{} - err = c.client.Get(). - Namespace(c.ns). - Resource("operatorstatuses"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of OperatorStatuses that match those selectors. -func (c *operatorStatuses) List(opts metav1.ListOptions) (result *v1.OperatorStatusList, err error) { - result = &v1.OperatorStatusList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("operatorstatuses"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested operatorStatuses. -func (c *operatorStatuses) Watch(opts metav1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("operatorstatuses"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a operatorStatus and creates it. Returns the server's representation of the operatorStatus, and an error, if there is any. -func (c *operatorStatuses) Create(operatorStatus *v1.OperatorStatus) (result *v1.OperatorStatus, err error) { - result = &v1.OperatorStatus{} - err = c.client.Post(). - Namespace(c.ns). - Resource("operatorstatuses"). - Body(operatorStatus). - Do(). - Into(result) - return -} - -// Update takes the representation of a operatorStatus and updates it. Returns the server's representation of the operatorStatus, and an error, if there is any. -func (c *operatorStatuses) Update(operatorStatus *v1.OperatorStatus) (result *v1.OperatorStatus, err error) { - result = &v1.OperatorStatus{} - err = c.client.Put(). - Namespace(c.ns). - Resource("operatorstatuses"). - Name(operatorStatus.Name). - Body(operatorStatus). - Do(). - Into(result) - return -} - -// Delete takes name of the operatorStatus and deletes it. Returns an error if one occurs. -func (c *operatorStatuses) Delete(name string, options *metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("operatorstatuses"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *operatorStatuses) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("operatorstatuses"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched operatorStatus. -func (c *operatorStatuses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.OperatorStatus, err error) { - result = &v1.OperatorStatus{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("operatorstatuses"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.openshift.io_client.go b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.openshift.io_client.go index 22463e1dee..c6bba1f4bf 100644 --- a/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.openshift.io_client.go +++ b/pkg/generated/clientset/versioned/typed/operatorstatus.openshift.io/v1/operatorstatus.openshift.io_client.go @@ -27,7 +27,7 @@ import ( type OperatorstatusV1Interface interface { RESTClient() rest.Interface - OperatorStatusesGetter + ClusterOperatorsGetter } // OperatorstatusV1Client is used to interact with features provided by the operatorstatus.openshift.io group. @@ -35,8 +35,8 @@ type OperatorstatusV1Client struct { restClient rest.Interface } -func (c *OperatorstatusV1Client) OperatorStatuses(namespace string) OperatorStatusInterface { - return newOperatorStatuses(c, namespace) +func (c *OperatorstatusV1Client) ClusterOperators(namespace string) ClusterOperatorInterface { + return newClusterOperators(c, namespace) } // NewForConfig creates a new OperatorstatusV1Client for the given config. diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index 0a80c698e4..9430f3e8aa 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -58,8 +58,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Clusterversion().V1().CVOConfigs().Informer()}, nil // Group=operatorstatus.openshift.io, Version=v1 - case operatorstatusopenshiftiov1.SchemeGroupVersion.WithResource("operatorstatuses"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Operatorstatus().V1().OperatorStatuses().Informer()}, nil + case operatorstatusopenshiftiov1.SchemeGroupVersion.WithResource("clusteroperators"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Operatorstatus().V1().ClusterOperators().Informer()}, nil } diff --git a/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/operatorstatus.go b/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/clusteroperator.go similarity index 57% rename from pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/operatorstatus.go rename to pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/clusteroperator.go index 5a26a9ce8b..1f27e4aedc 100644 --- a/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/operatorstatus.go +++ b/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/clusteroperator.go @@ -31,59 +31,59 @@ import ( cache "k8s.io/client-go/tools/cache" ) -// OperatorStatusInformer provides access to a shared informer and lister for -// OperatorStatuses. -type OperatorStatusInformer interface { +// ClusterOperatorInformer provides access to a shared informer and lister for +// ClusterOperators. +type ClusterOperatorInformer interface { Informer() cache.SharedIndexInformer - Lister() v1.OperatorStatusLister + Lister() v1.ClusterOperatorLister } -type operatorStatusInformer struct { +type clusterOperatorInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } -// NewOperatorStatusInformer constructs a new informer for OperatorStatus type. +// NewClusterOperatorInformer constructs a new informer for ClusterOperator type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewOperatorStatusInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredOperatorStatusInformer(client, namespace, resyncPeriod, indexers, nil) +func NewClusterOperatorInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterOperatorInformer(client, namespace, resyncPeriod, indexers, nil) } -// NewFilteredOperatorStatusInformer constructs a new informer for OperatorStatus type. +// NewFilteredClusterOperatorInformer constructs a new informer for ClusterOperator type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredOperatorStatusInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredClusterOperatorInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.OperatorstatusV1().OperatorStatuses(namespace).List(options) + return client.OperatorstatusV1().ClusterOperators(namespace).List(options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.OperatorstatusV1().OperatorStatuses(namespace).Watch(options) + return client.OperatorstatusV1().ClusterOperators(namespace).Watch(options) }, }, - &operatorstatusopenshiftiov1.OperatorStatus{}, + &operatorstatusopenshiftiov1.ClusterOperator{}, resyncPeriod, indexers, ) } -func (f *operatorStatusInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredOperatorStatusInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +func (f *clusterOperatorInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterOperatorInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } -func (f *operatorStatusInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&operatorstatusopenshiftiov1.OperatorStatus{}, f.defaultInformer) +func (f *clusterOperatorInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&operatorstatusopenshiftiov1.ClusterOperator{}, f.defaultInformer) } -func (f *operatorStatusInformer) Lister() v1.OperatorStatusLister { - return v1.NewOperatorStatusLister(f.Informer().GetIndexer()) +func (f *clusterOperatorInformer) Lister() v1.ClusterOperatorLister { + return v1.NewClusterOperatorLister(f.Informer().GetIndexer()) } diff --git a/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/interface.go b/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/interface.go index df3afbd181..ff746d7bbd 100644 --- a/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/interface.go +++ b/pkg/generated/informers/externalversions/operatorstatus.openshift.io/v1/interface.go @@ -24,8 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // OperatorStatuses returns a OperatorStatusInformer. - OperatorStatuses() OperatorStatusInformer + // ClusterOperators returns a ClusterOperatorInformer. + ClusterOperators() ClusterOperatorInformer } type version struct { @@ -39,7 +39,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// OperatorStatuses returns a OperatorStatusInformer. -func (v *version) OperatorStatuses() OperatorStatusInformer { - return &operatorStatusInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +// ClusterOperators returns a ClusterOperatorInformer. +func (v *version) ClusterOperators() ClusterOperatorInformer { + return &clusterOperatorInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } diff --git a/pkg/generated/listers/operatorstatus.openshift.io/v1/clusteroperator.go b/pkg/generated/listers/operatorstatus.openshift.io/v1/clusteroperator.go new file mode 100644 index 0000000000..7595953829 --- /dev/null +++ b/pkg/generated/listers/operatorstatus.openshift.io/v1/clusteroperator.go @@ -0,0 +1,94 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterOperatorLister helps list ClusterOperators. +type ClusterOperatorLister interface { + // List lists all ClusterOperators in the indexer. + List(selector labels.Selector) (ret []*v1.ClusterOperator, err error) + // ClusterOperators returns an object that can list and get ClusterOperators. + ClusterOperators(namespace string) ClusterOperatorNamespaceLister + ClusterOperatorListerExpansion +} + +// clusterOperatorLister implements the ClusterOperatorLister interface. +type clusterOperatorLister struct { + indexer cache.Indexer +} + +// NewClusterOperatorLister returns a new ClusterOperatorLister. +func NewClusterOperatorLister(indexer cache.Indexer) ClusterOperatorLister { + return &clusterOperatorLister{indexer: indexer} +} + +// List lists all ClusterOperators in the indexer. +func (s *clusterOperatorLister) List(selector labels.Selector) (ret []*v1.ClusterOperator, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ClusterOperator)) + }) + return ret, err +} + +// ClusterOperators returns an object that can list and get ClusterOperators. +func (s *clusterOperatorLister) ClusterOperators(namespace string) ClusterOperatorNamespaceLister { + return clusterOperatorNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ClusterOperatorNamespaceLister helps list and get ClusterOperators. +type ClusterOperatorNamespaceLister interface { + // List lists all ClusterOperators in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.ClusterOperator, err error) + // Get retrieves the ClusterOperator from the indexer for a given namespace and name. + Get(name string) (*v1.ClusterOperator, error) + ClusterOperatorNamespaceListerExpansion +} + +// clusterOperatorNamespaceLister implements the ClusterOperatorNamespaceLister +// interface. +type clusterOperatorNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ClusterOperators in the indexer for a given namespace. +func (s clusterOperatorNamespaceLister) List(selector labels.Selector) (ret []*v1.ClusterOperator, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ClusterOperator)) + }) + return ret, err +} + +// Get retrieves the ClusterOperator from the indexer for a given namespace and name. +func (s clusterOperatorNamespaceLister) Get(name string) (*v1.ClusterOperator, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("clusteroperator"), name) + } + return obj.(*v1.ClusterOperator), nil +} diff --git a/pkg/generated/listers/operatorstatus.openshift.io/v1/expansion_generated.go b/pkg/generated/listers/operatorstatus.openshift.io/v1/expansion_generated.go index 0413d56c4d..db80edbb8b 100644 --- a/pkg/generated/listers/operatorstatus.openshift.io/v1/expansion_generated.go +++ b/pkg/generated/listers/operatorstatus.openshift.io/v1/expansion_generated.go @@ -18,10 +18,10 @@ limitations under the License. package v1 -// OperatorStatusListerExpansion allows custom methods to be added to -// OperatorStatusLister. -type OperatorStatusListerExpansion interface{} +// ClusterOperatorListerExpansion allows custom methods to be added to +// ClusterOperatorLister. +type ClusterOperatorListerExpansion interface{} -// OperatorStatusNamespaceListerExpansion allows custom methods to be added to -// OperatorStatusNamespaceLister. -type OperatorStatusNamespaceListerExpansion interface{} +// ClusterOperatorNamespaceListerExpansion allows custom methods to be added to +// ClusterOperatorNamespaceLister. +type ClusterOperatorNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/operatorstatus.openshift.io/v1/operatorstatus.go b/pkg/generated/listers/operatorstatus.openshift.io/v1/operatorstatus.go deleted file mode 100644 index a2f04e68f6..0000000000 --- a/pkg/generated/listers/operatorstatus.openshift.io/v1/operatorstatus.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1 - -import ( - v1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// OperatorStatusLister helps list OperatorStatuses. -type OperatorStatusLister interface { - // List lists all OperatorStatuses in the indexer. - List(selector labels.Selector) (ret []*v1.OperatorStatus, err error) - // OperatorStatuses returns an object that can list and get OperatorStatuses. - OperatorStatuses(namespace string) OperatorStatusNamespaceLister - OperatorStatusListerExpansion -} - -// operatorStatusLister implements the OperatorStatusLister interface. -type operatorStatusLister struct { - indexer cache.Indexer -} - -// NewOperatorStatusLister returns a new OperatorStatusLister. -func NewOperatorStatusLister(indexer cache.Indexer) OperatorStatusLister { - return &operatorStatusLister{indexer: indexer} -} - -// List lists all OperatorStatuses in the indexer. -func (s *operatorStatusLister) List(selector labels.Selector) (ret []*v1.OperatorStatus, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.OperatorStatus)) - }) - return ret, err -} - -// OperatorStatuses returns an object that can list and get OperatorStatuses. -func (s *operatorStatusLister) OperatorStatuses(namespace string) OperatorStatusNamespaceLister { - return operatorStatusNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// OperatorStatusNamespaceLister helps list and get OperatorStatuses. -type OperatorStatusNamespaceLister interface { - // List lists all OperatorStatuses in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1.OperatorStatus, err error) - // Get retrieves the OperatorStatus from the indexer for a given namespace and name. - Get(name string) (*v1.OperatorStatus, error) - OperatorStatusNamespaceListerExpansion -} - -// operatorStatusNamespaceLister implements the OperatorStatusNamespaceLister -// interface. -type operatorStatusNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all OperatorStatuses in the indexer for a given namespace. -func (s operatorStatusNamespaceLister) List(selector labels.Selector) (ret []*v1.OperatorStatus, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.OperatorStatus)) - }) - return ret, err -} - -// Get retrieves the OperatorStatus from the indexer for a given namespace and name. -func (s operatorStatusNamespaceLister) Get(name string) (*v1.OperatorStatus, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("operatorstatus"), name) - } - return obj.(*v1.OperatorStatus), nil -}