diff --git a/cmd/main.go b/cmd/main.go index 0c71d913cc..7ac317f6a0 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -6,12 +6,10 @@ import ( "os" "time" - "github.com/openshift/cluster-version-operator/pkg/cincinnati" "github.com/openshift/cluster-version-operator/pkg/cvo" "github.com/openshift/cluster-version-operator/pkg/version" "github.com/golang/glog" - "github.com/google/uuid" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -40,7 +38,6 @@ var ( func init() { flag.StringVar(&flags.kubeconfig, "kubeconfig", "", "Kubeconfig file to access a remote cluster. Warning: For testing only, do not use in production.") - flag.StringVar(&flags.clusterID, "cluster-id", "", "UUID of the cluster that the channel operator is managing, MUST be set") flag.BoolVar(&flags.version, "version", false, "Print the version") flag.Parse() } @@ -54,14 +51,7 @@ func main() { return } - id, err := uuid.Parse(flags.clusterID) - if err != nil { - glog.Fatalf("Invalid clusterID %q, must be a UUID: %s", flags.clusterID, err) - } else if id.Variant() != uuid.RFC4122 { - glog.Fatalf("Invalid clusterID %q, must be an RFC4122-variant UUID: found %s", flags.clusterID, id.Variant()) - } else if id.Version() != 4 { - glog.Fatalf("Invalid clusterID %q, must be a version-4 UUID: found %s", flags.clusterID, id.Version()) - } + glog.Infof(version.String) config, err := loadClientConfig(flags.kubeconfig) if err != nil { @@ -74,15 +64,15 @@ func main() { RenewDeadline: renewDeadline, RetryPeriod: retryPeriod, Callbacks: leaderelection.LeaderCallbacks{ - OnStartedLeading: startedLeading(config, cincinnati.NewClient(id)), + OnStartedLeading: startedLeading(config), OnStoppedLeading: stoppedLeading, }, }) } -func startedLeading(config *rest.Config, client cincinnati.Client) func(<-chan struct{}) { +func startedLeading(config *rest.Config) func(<-chan struct{}) { return func(stopCh <-chan struct{}) { - cvo.StartWorkers(stopCh, config, client) + cvo.StartWorkers(stopCh, config) } } diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index e78d6f6fc3..0971eca5dc 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -7,3 +7,4 @@ ${PROJECT_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh \ github.com/openshift/cluster-version-operator/pkg/generated \ github.com/openshift/cluster-version-operator/pkg/apis \ "clusterversion.openshift.io:v1" \ + $@ \ diff --git a/pkg/apis/clusterversion.openshift.io/v1/cvoconfig.go b/pkg/apis/clusterversion.openshift.io/v1/cvoconfig.go new file mode 100644 index 0000000000..a3461ebd22 --- /dev/null +++ b/pkg/apis/clusterversion.openshift.io/v1/cvoconfig.go @@ -0,0 +1,28 @@ +package v1 + +import ( + "fmt" + + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyObject copies the CVOConfig into an Object. This doesn't actually +// require a deep copy, but the code generator (and Go itself) isn't advanced +// enough to determine that. +func (c *CVOConfig) DeepCopyObject() runtime.Object { + out := *c + c.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + return &out +} + +// DeepCopyInto copies the CVOConfig into another CVOConfig. This doesn't +// actually require a deep copy, but the code generator (and Go itself) isn't +// advanced enough to determine that. +func (c *CVOConfig) DeepCopyInto(out *CVOConfig) { + *out = *c + c.ObjectMeta.DeepCopyInto(&out.ObjectMeta) +} + +func (c CVOConfig) String() string { + return fmt.Sprintf("{ Upstream: %s Channel: %s ClusterID: %s }", c.Upstream, c.Channel, c.ClusterID) +} diff --git a/pkg/apis/clusterversion.openshift.io/v1/doc.go b/pkg/apis/clusterversion.openshift.io/v1/doc.go deleted file mode 100644 index bd48bff2f8..0000000000 --- a/pkg/apis/clusterversion.openshift.io/v1/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// This file only exists because the poorly written code generation tools only -// read doc.go when looking for package-level tags. - -// +k8s:deepcopy-gen=package - -package v1 diff --git a/pkg/apis/clusterversion.openshift.io/v1/register.go b/pkg/apis/clusterversion.openshift.io/v1/register.go index e332a50bfc..a12686c094 100644 --- a/pkg/apis/clusterversion.openshift.io/v1/register.go +++ b/pkg/apis/clusterversion.openshift.io/v1/register.go @@ -38,6 +38,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &OperatorStatus{}, &OperatorStatusList{}, + &CVOConfig{}, &CVOStatus{}, ) diff --git a/pkg/apis/clusterversion.openshift.io/v1/types.go b/pkg/apis/clusterversion.openshift.io/v1/types.go index 8cb441763a..6f31e18726 100644 --- a/pkg/apis/clusterversion.openshift.io/v1/types.go +++ b/pkg/apis/clusterversion.openshift.io/v1/types.go @@ -1,13 +1,14 @@ package v1 import ( + "github.com/google/uuid" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - // OperatorStatusList is a list of OperatorStatus resources. +// +k8s:deepcopy-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type OperatorStatusList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` @@ -15,12 +16,12 @@ type OperatorStatusList struct { Items []OperatorStatus `json:"items"` } -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - // OperatorStatus 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 { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` @@ -75,11 +76,36 @@ const ( OperatorStatusConditionTypeDegraded OperatorStatusConditionType = "Degraded" ) +// CVOConfigList is a list of CVOConfig resources. +// +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type CVOConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []CVOConfig `json:"items"` +} + +// CVOConfig is the configuration for the ClusterVersionOperator. This is where +// parameters related to automatic updates can be set. +// +genclient +type CVOConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Upstream URL `json:"upstream"` + Channel string `json:"channel"` + ClusterID uuid.UUID `json:"clusterId"` +} + +// URL is a thin wrapper around string that ensures the string is a valid URL. +type URL string // CVOStatus contains information specific to the ClusterVersionOperator. This // object is inserted into the Extension attribute of the generic // OperatorStatus object. +// +k8s:deepcopy-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type CVOStatus struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/apis/clusterversion.openshift.io/v1/url.go b/pkg/apis/clusterversion.openshift.io/v1/url.go new file mode 100644 index 0000000000..5c98596458 --- /dev/null +++ b/pkg/apis/clusterversion.openshift.io/v1/url.go @@ -0,0 +1,17 @@ +package v1 + +import ( + "net/url" +) + +// UnmarshalJSON unmarshals a URL, ensuring that it is valid. +func (u *URL) UnmarshalJSON(data []byte) error { + _, err := url.Parse(string(data)) + if err != nil { + return err + } + + *u = URL(string(data)) + + return nil +} diff --git a/pkg/apis/clusterversion.openshift.io/v1/zz_generated.deepcopy.go b/pkg/apis/clusterversion.openshift.io/v1/zz_generated.deepcopy.go index 7a7c5496dd..3976261225 100644 --- a/pkg/apis/clusterversion.openshift.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/clusterversion.openshift.io/v1/zz_generated.deepcopy.go @@ -24,6 +24,39 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CVOConfigList) DeepCopyInto(out *CVOConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CVOConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CVOConfigList. +func (in *CVOConfigList) DeepCopy() *CVOConfigList { + if in == nil { + return nil + } + out := new(CVOConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CVOConfigList) 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 *CVOStatus) DeepCopyInto(out *CVOStatus) { *out = *in @@ -84,22 +117,6 @@ func (in *OperatorStatus) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OperatorStatusCondition) DeepCopyInto(out *OperatorStatusCondition) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatusCondition. -func (in *OperatorStatusCondition) DeepCopy() *OperatorStatusCondition { - if in == nil { - return nil - } - out := new(OperatorStatusCondition) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OperatorStatusList) DeepCopyInto(out *OperatorStatusList) { *out = *in diff --git a/pkg/cincinnati/cincinnati.go b/pkg/cincinnati/cincinnati.go index 3f75b51b17..f5d3cfc0a5 100644 --- a/pkg/cincinnati/cincinnati.go +++ b/pkg/cincinnati/cincinnati.go @@ -34,7 +34,7 @@ func NewClient(id uuid.UUID) Client { // then finding all of the children. These children are the available updates // for the current version and their payloads indicate from where the actual // update image can be downloaded. -func (c *Client) GetUpdatePayloads(upstream string, version semver.Version, channel string) ([]string, error) { +func (c Client) GetUpdatePayloads(upstream string, channel string, version semver.Version) ([]string, error) { // Download the update graph. req, err := http.NewRequest("GET", upstream, nil) if err != nil { diff --git a/pkg/cvo/cvo.go b/pkg/cvo/cvo.go index 13b968713d..bfbc59592c 100644 --- a/pkg/cvo/cvo.go +++ b/pkg/cvo/cvo.go @@ -1,22 +1,12 @@ package cvo import ( - "fmt" "time" - "github.com/openshift/cluster-version-operator/pkg/apis" - "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1" - "github.com/openshift/cluster-version-operator/pkg/cincinnati" "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned" - "github.com/openshift/cluster-version-operator/pkg/version" - "github.com/blang/semver" "github.com/golang/glog" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/rest" ) @@ -26,7 +16,8 @@ const ( // checks. Jitter will vary between 0% and 100% of updateCheckPeriod. updateCheckPeriod = time.Minute - // customResourceName is the name of the CVO's OperatorStatus. + // customResourceName is the name of the CVO's OperatorStatus and the + // CVOConfig. customResourceName = "cluster-version-operator" // XXX: namespace is the hardcoded namespace that will be used for the @@ -39,7 +30,7 @@ const ( // - ensuring the OperatorStatus CRD exists and is correct // - checking for updates and writing the available updates into the CVO's // OperatorStatus. -func StartWorkers(stopCh <-chan struct{}, config *rest.Config, cinClient cincinnati.Client) { +func StartWorkers(stopCh <-chan struct{}, config *rest.Config) { apiExtClient, err := clientset.NewForConfig(config) if err != nil { glog.Errorf("Failed to create Kubernetes client (API Extensions): %v", err) @@ -52,93 +43,9 @@ func StartWorkers(stopCh <-chan struct{}, config *rest.Config, cinClient cincinn return } - go wait.Until(ensureOperatorStatusExists(apiExtClient), updateCheckPeriod, stopCh) - go wait.Until(checkForUpdate(cvoClient, &cinClient), updateCheckPeriod, stopCh) -} - -func ensureOperatorStatusExists(apiExtClient clientset.Interface) func() { - return func() { - _, err := apiExtClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(&v1beta1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("operatorstatuses.%s", apis.GroupName), - Namespace: metav1.NamespaceDefault, - }, - Spec: v1beta1.CustomResourceDefinitionSpec{ - Group: apis.GroupName, - Version: "v1", - Scope: "Namespaced", - Names: v1beta1.CustomResourceDefinitionNames{ - Plural: "operatorstatuses", - Singular: "operatorstatus", - Kind: "OperatorStatus", - ListKind: "OperatorStatusList", - }, - }, - }) - if err != nil && !errors.IsAlreadyExists(err) { - glog.Errorf("Failed to create OperatorStatus CRD: %v", err) - return - } - } -} - -func checkForUpdate(cvoClient versioned.Interface, cinClient *cincinnati.Client) func() { - return func() { - payloads, err := cinClient.GetUpdatePayloads("http://localhost:8080/graph", semver.MustParse("1.8.9-tectonic.3"), "fast") - if err != nil { - glog.Errorf("Failed to check for update: %v", err) - return - } - glog.V(4).Infof("Found update payloads: %v", payloads) - - if updateStatus(cvoClient, payloads) != nil { - glog.Errorf("Failed to update OperatorStatus for ClusterVersionOperator") - } - } -} - -func updateStatus(cvoClient versioned.Interface, payloads []string) error { - status, err := cvoClient.ClusterversionV1().OperatorStatuses(namespace).Get(customResourceName, metav1.GetOptions{}) - if err != nil && !errors.IsNotFound(err) { - glog.Errorf("Failed to get custom resource: %v", err) - return err - } - - if errors.IsNotFound(err) { - status = &v1.OperatorStatus{ - ObjectMeta: metav1.ObjectMeta{ - Name: customResourceName, - }, - Condition: v1.OperatorStatusCondition{ - Type: v1.OperatorStatusConditionTypeDone, - }, - Version: version.Raw, - LastUpdate: metav1.Now(), - Extension: runtime.RawExtension{ - Object: &v1.CVOStatus{ - AvailablePayloads: payloads, - }, - }, - } - - _, err = cvoClient.ClusterversionV1().OperatorStatuses(namespace).Create(status) - if err != nil { - glog.Errorf("Failed to create custom resource: %v", err) - return err - } - } else { - status.Version = version.Raw - status.LastUpdate = metav1.Now() - status.Extension.Object = &v1.CVOStatus{ - AvailablePayloads: payloads, - } - - _, err = cvoClient.ClusterversionV1().OperatorStatuses(namespace).Update(status) - if err != nil { - glog.Errorf("Failed to update custom resource: %v", err) - return err - } - } + // Create the CRDs before attempting to run the reconciliation loops. + ensureCRDsExist(apiExtClient) - return nil + go wait.Until(func() { ensureCRDsExist(apiExtClient) }, updateCheckPeriod, stopCh) + go wait.Until(func() { checkForUpdate(cvoClient) }, updateCheckPeriod, stopCh) } diff --git a/pkg/cvo/operator_status.go b/pkg/cvo/operator_status.go new file mode 100644 index 0000000000..77ee27688e --- /dev/null +++ b/pkg/cvo/operator_status.go @@ -0,0 +1,61 @@ +package cvo + +import ( + "fmt" + + "github.com/openshift/cluster-version-operator/pkg/apis" + + "github.com/golang/glog" + "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" + "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// XXX: this needs to ensure that the CRD is correct (e.g. hasn't been modified +// by the user) rather than just ensuring it exists. +func ensureCRDsExist(apiExtClient clientset.Interface) { + _, err := apiExtClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(&v1beta1.CustomResourceDefinition{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("operatorstatuses.%s", apis.GroupName), + Namespace: metav1.NamespaceDefault, + }, + Spec: v1beta1.CustomResourceDefinitionSpec{ + Group: apis.GroupName, + Version: "v1", + Scope: "Namespaced", + Names: v1beta1.CustomResourceDefinitionNames{ + Plural: "operatorstatuses", + Singular: "operatorstatus", + Kind: "OperatorStatus", + ListKind: "OperatorStatusList", + }, + }, + }) + if err != nil && !errors.IsAlreadyExists(err) { + glog.Errorf("Failed to create OperatorStatus CRD: %v", err) + return + } + + _, err = apiExtClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(&v1beta1.CustomResourceDefinition{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("cvoconfigs.%s", apis.GroupName), + Namespace: metav1.NamespaceDefault, + }, + Spec: v1beta1.CustomResourceDefinitionSpec{ + Group: apis.GroupName, + Version: "v1", + Scope: "Namespaced", + Names: v1beta1.CustomResourceDefinitionNames{ + Plural: "cvoconfigs", + Singular: "cvoconfig", + Kind: "CVOConfig", + ListKind: "CVOConfigList", + }, + }, + }) + if err != nil && !errors.IsAlreadyExists(err) { + glog.Errorf("Failed to create CVOConfig CRD: %v", err) + return + } +} diff --git a/pkg/cvo/update.go b/pkg/cvo/update.go new file mode 100644 index 0000000000..3ddfe4b4d1 --- /dev/null +++ b/pkg/cvo/update.go @@ -0,0 +1,129 @@ +package cvo + +import ( + "fmt" + + "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1" + "github.com/openshift/cluster-version-operator/pkg/cincinnati" + "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned" + "github.com/openshift/cluster-version-operator/pkg/version" + + "github.com/golang/glog" + "github.com/google/uuid" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +var ( + defaultUpstream = v1.URL("http://localhost:8080") + defaultChannel = "fast" +) + +func checkForUpdate(cvoClient versioned.Interface) { + config, err := getConfig(cvoClient) + if err != nil { + glog.Errorf("Failed to get CVO config: %v", err) + return + } + glog.V(4).Infof("Found CVO config: %s", config) + + payloads, err := cincinnati.NewClient(config.ClusterID).GetUpdatePayloads(string(config.Upstream), config.Channel, version.Version) + if err != nil { + glog.Errorf("Failed to check for update: %v", err) + return + } + glog.V(4).Infof("Found update payloads: %v", payloads) + + if updateStatus(cvoClient, payloads) != nil { + glog.Errorf("Failed to update OperatorStatus for ClusterVersionOperator") + } +} + +func getConfig(cvoClient versioned.Interface) (v1.CVOConfig, error) { + config, err := cvoClient.ClusterversionV1().CVOConfigs(namespace).Get(customResourceName, metav1.GetOptions{}) + if err != nil && !errors.IsNotFound(err) { + glog.Errorf("Failed to get custom resource: %v", err) + return v1.CVOConfig{}, err + } + + if errors.IsNotFound(err) { + glog.Infof("No CVO config found. Generating a new one...") + + id, err := uuid.NewRandom() + if err != nil { + glog.Errorf("Failed to generate new cluster identifier: %v", err) + return v1.CVOConfig{}, err + } + + config = &v1.CVOConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: customResourceName, + }, + Upstream: defaultUpstream, + Channel: defaultChannel, + ClusterID: id, + } + + _, err = cvoClient.ClusterversionV1().CVOConfigs(namespace).Create(config) + if err != nil { + glog.Errorf("Failed to create custom resource: %v", err) + return v1.CVOConfig{}, err + } + } + + if config.ClusterID.Variant() != uuid.RFC4122 { + return v1.CVOConfig{}, fmt.Errorf("invalid ClusterID %q, must be an RFC4122-variant UUID: found %s", config.ClusterID, config.ClusterID.Variant()) + } + if config.ClusterID.Version() != 4 { + return v1.CVOConfig{}, fmt.Errorf("Invalid ClusterID %q, must be a version-4 UUID: found %s", config.ClusterID, config.ClusterID.Version()) + } + + return *config, nil +} + +func updateStatus(cvoClient versioned.Interface, payloads []string) error { + status, err := cvoClient.ClusterversionV1().OperatorStatuses(namespace).Get(customResourceName, metav1.GetOptions{}) + if err != nil && !errors.IsNotFound(err) { + glog.Errorf("Failed to get custom resource: %v", err) + return err + } + + if errors.IsNotFound(err) { + status = &v1.OperatorStatus{ + ObjectMeta: metav1.ObjectMeta{ + Name: customResourceName, + }, + Condition: v1.OperatorStatusCondition{ + Type: v1.OperatorStatusConditionTypeDone, + }, + Version: version.Raw, + LastUpdate: metav1.Now(), + Extension: runtime.RawExtension{ + Object: &v1.CVOStatus{ + AvailablePayloads: payloads, + }, + }, + } + + _, err = cvoClient.ClusterversionV1().OperatorStatuses(namespace).Create(status) + if err != nil { + glog.Errorf("Failed to create custom resource: %v", err) + return err + } + } else { + status.Version = version.Raw + status.LastUpdate = metav1.Now() + status.Extension.Object = &v1.CVOStatus{ + AvailablePayloads: payloads, + } + + _, err = cvoClient.ClusterversionV1().OperatorStatuses(namespace).Update(status) + if err != nil { + glog.Errorf("Failed to update custom resource: %v", err) + return err + } + } + + return nil +} diff --git a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/clusterversion.openshift.io_client.go b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/clusterversion.openshift.io_client.go index 8dad096cc7..31e5e9a09a 100644 --- a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/clusterversion.openshift.io_client.go +++ b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/clusterversion.openshift.io_client.go @@ -27,6 +27,7 @@ import ( type ClusterversionV1Interface interface { RESTClient() rest.Interface + CVOConfigsGetter OperatorStatusesGetter } @@ -35,6 +36,10 @@ type ClusterversionV1Client struct { restClient rest.Interface } +func (c *ClusterversionV1Client) CVOConfigs(namespace string) CVOConfigInterface { + return newCVOConfigs(c, namespace) +} + func (c *ClusterversionV1Client) OperatorStatuses(namespace string) OperatorStatusInterface { return newOperatorStatuses(c, namespace) } diff --git a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/cvoconfig.go b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/cvoconfig.go new file mode 100644 index 0000000000..09341398dd --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/cvoconfig.go @@ -0,0 +1,157 @@ +/* +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/clusterversion.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" +) + +// CVOConfigsGetter has a method to return a CVOConfigInterface. +// A group's client should implement this interface. +type CVOConfigsGetter interface { + CVOConfigs(namespace string) CVOConfigInterface +} + +// CVOConfigInterface has methods to work with CVOConfig resources. +type CVOConfigInterface interface { + Create(*v1.CVOConfig) (*v1.CVOConfig, error) + Update(*v1.CVOConfig) (*v1.CVOConfig, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.CVOConfig, error) + List(opts metav1.ListOptions) (*v1.CVOConfigList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.CVOConfig, err error) + CVOConfigExpansion +} + +// cVOConfigs implements CVOConfigInterface +type cVOConfigs struct { + client rest.Interface + ns string +} + +// newCVOConfigs returns a CVOConfigs +func newCVOConfigs(c *ClusterversionV1Client, namespace string) *cVOConfigs { + return &cVOConfigs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the cVOConfig, and returns the corresponding cVOConfig object, and an error if there is any. +func (c *cVOConfigs) Get(name string, options metav1.GetOptions) (result *v1.CVOConfig, err error) { + result = &v1.CVOConfig{} + err = c.client.Get(). + Namespace(c.ns). + Resource("cvoconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of CVOConfigs that match those selectors. +func (c *cVOConfigs) List(opts metav1.ListOptions) (result *v1.CVOConfigList, err error) { + result = &v1.CVOConfigList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("cvoconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested cVOConfigs. +func (c *cVOConfigs) Watch(opts metav1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("cvoconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a cVOConfig and creates it. Returns the server's representation of the cVOConfig, and an error, if there is any. +func (c *cVOConfigs) Create(cVOConfig *v1.CVOConfig) (result *v1.CVOConfig, err error) { + result = &v1.CVOConfig{} + err = c.client.Post(). + Namespace(c.ns). + Resource("cvoconfigs"). + Body(cVOConfig). + Do(). + Into(result) + return +} + +// Update takes the representation of a cVOConfig and updates it. Returns the server's representation of the cVOConfig, and an error, if there is any. +func (c *cVOConfigs) Update(cVOConfig *v1.CVOConfig) (result *v1.CVOConfig, err error) { + result = &v1.CVOConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("cvoconfigs"). + Name(cVOConfig.Name). + Body(cVOConfig). + Do(). + Into(result) + return +} + +// Delete takes name of the cVOConfig and deletes it. Returns an error if one occurs. +func (c *cVOConfigs) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("cvoconfigs"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *cVOConfigs) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("cvoconfigs"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched cVOConfig. +func (c *cVOConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.CVOConfig, err error) { + result = &v1.CVOConfig{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("cvoconfigs"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_clusterversion.openshift.io_client.go b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_clusterversion.openshift.io_client.go index dc7d16cc7e..9233d1314a 100644 --- a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_clusterversion.openshift.io_client.go +++ b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_clusterversion.openshift.io_client.go @@ -28,6 +28,10 @@ type FakeClusterversionV1 struct { *testing.Fake } +func (c *FakeClusterversionV1) CVOConfigs(namespace string) v1.CVOConfigInterface { + return &FakeCVOConfigs{c, namespace} +} + func (c *FakeClusterversionV1) OperatorStatuses(namespace string) v1.OperatorStatusInterface { return &FakeOperatorStatuses{c, namespace} } diff --git a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_cvoconfig.go b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_cvoconfig.go new file mode 100644 index 0000000000..fb2c49114d --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/fake/fake_cvoconfig.go @@ -0,0 +1,128 @@ +/* +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 ( + clusterversionopenshiftiov1 "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.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" +) + +// FakeCVOConfigs implements CVOConfigInterface +type FakeCVOConfigs struct { + Fake *FakeClusterversionV1 + ns string +} + +var cvoconfigsResource = schema.GroupVersionResource{Group: "clusterversion.openshift.io", Version: "v1", Resource: "cvoconfigs"} + +var cvoconfigsKind = schema.GroupVersionKind{Group: "clusterversion.openshift.io", Version: "v1", Kind: "CVOConfig"} + +// Get takes name of the cVOConfig, and returns the corresponding cVOConfig object, and an error if there is any. +func (c *FakeCVOConfigs) Get(name string, options v1.GetOptions) (result *clusterversionopenshiftiov1.CVOConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(cvoconfigsResource, c.ns, name), &clusterversionopenshiftiov1.CVOConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterversionopenshiftiov1.CVOConfig), err +} + +// List takes label and field selectors, and returns the list of CVOConfigs that match those selectors. +func (c *FakeCVOConfigs) List(opts v1.ListOptions) (result *clusterversionopenshiftiov1.CVOConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(cvoconfigsResource, cvoconfigsKind, c.ns, opts), &clusterversionopenshiftiov1.CVOConfigList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &clusterversionopenshiftiov1.CVOConfigList{ListMeta: obj.(*clusterversionopenshiftiov1.CVOConfigList).ListMeta} + for _, item := range obj.(*clusterversionopenshiftiov1.CVOConfigList).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 cVOConfigs. +func (c *FakeCVOConfigs) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(cvoconfigsResource, c.ns, opts)) + +} + +// Create takes the representation of a cVOConfig and creates it. Returns the server's representation of the cVOConfig, and an error, if there is any. +func (c *FakeCVOConfigs) Create(cVOConfig *clusterversionopenshiftiov1.CVOConfig) (result *clusterversionopenshiftiov1.CVOConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(cvoconfigsResource, c.ns, cVOConfig), &clusterversionopenshiftiov1.CVOConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterversionopenshiftiov1.CVOConfig), err +} + +// Update takes the representation of a cVOConfig and updates it. Returns the server's representation of the cVOConfig, and an error, if there is any. +func (c *FakeCVOConfigs) Update(cVOConfig *clusterversionopenshiftiov1.CVOConfig) (result *clusterversionopenshiftiov1.CVOConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(cvoconfigsResource, c.ns, cVOConfig), &clusterversionopenshiftiov1.CVOConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterversionopenshiftiov1.CVOConfig), err +} + +// Delete takes name of the cVOConfig and deletes it. Returns an error if one occurs. +func (c *FakeCVOConfigs) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(cvoconfigsResource, c.ns, name), &clusterversionopenshiftiov1.CVOConfig{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCVOConfigs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(cvoconfigsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &clusterversionopenshiftiov1.CVOConfigList{}) + return err +} + +// Patch applies the patch and returns the patched cVOConfig. +func (c *FakeCVOConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *clusterversionopenshiftiov1.CVOConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(cvoconfigsResource, c.ns, name, data, subresources...), &clusterversionopenshiftiov1.CVOConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*clusterversionopenshiftiov1.CVOConfig), err +} diff --git a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/generated_expansion.go index 7730d680eb..92f8d2e1ca 100644 --- a/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/clusterversion.openshift.io/v1/generated_expansion.go @@ -18,4 +18,6 @@ limitations under the License. package v1 +type CVOConfigExpansion interface{} + type OperatorStatusExpansion interface{} diff --git a/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/cvoconfig.go b/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/cvoconfig.go new file mode 100644 index 0000000000..03cfe8b1a0 --- /dev/null +++ b/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/cvoconfig.go @@ -0,0 +1,89 @@ +/* +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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + clusterversionopenshiftiov1 "github.com/openshift/cluster-version-operator/pkg/apis/clusterversion.openshift.io/v1" + versioned "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned" + internalinterfaces "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/openshift/cluster-version-operator/pkg/generated/listers/clusterversion.openshift.io/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// CVOConfigInformer provides access to a shared informer and lister for +// CVOConfigs. +type CVOConfigInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.CVOConfigLister +} + +type cVOConfigInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCVOConfigInformer constructs a new informer for CVOConfig 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 NewCVOConfigInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCVOConfigInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCVOConfigInformer constructs a new informer for CVOConfig 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 NewFilteredCVOConfigInformer(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.ClusterversionV1().CVOConfigs(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ClusterversionV1().CVOConfigs(namespace).Watch(options) + }, + }, + &clusterversionopenshiftiov1.CVOConfig{}, + resyncPeriod, + indexers, + ) +} + +func (f *cVOConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCVOConfigInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *cVOConfigInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&clusterversionopenshiftiov1.CVOConfig{}, f.defaultInformer) +} + +func (f *cVOConfigInformer) Lister() v1.CVOConfigLister { + return v1.NewCVOConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/interface.go b/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/interface.go index df3afbd181..acb88fb1e3 100644 --- a/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/interface.go +++ b/pkg/generated/informers/externalversions/clusterversion.openshift.io/v1/interface.go @@ -24,6 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // CVOConfigs returns a CVOConfigInformer. + CVOConfigs() CVOConfigInformer // OperatorStatuses returns a OperatorStatusInformer. OperatorStatuses() OperatorStatusInformer } @@ -39,6 +41,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// CVOConfigs returns a CVOConfigInformer. +func (v *version) CVOConfigs() CVOConfigInformer { + return &cVOConfigInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // OperatorStatuses returns a OperatorStatusInformer. func (v *version) OperatorStatuses() OperatorStatusInformer { return &operatorStatusInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index ccc623e63a..6fd10df5b5 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -53,6 +53,8 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=clusterversion.openshift.io, Version=v1 + case v1.SchemeGroupVersion.WithResource("cvoconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Clusterversion().V1().CVOConfigs().Informer()}, nil case v1.SchemeGroupVersion.WithResource("operatorstatuses"): return &genericInformer{resource: resource.GroupResource(), informer: f.Clusterversion().V1().OperatorStatuses().Informer()}, nil diff --git a/pkg/generated/listers/clusterversion.openshift.io/v1/cvoconfig.go b/pkg/generated/listers/clusterversion.openshift.io/v1/cvoconfig.go new file mode 100644 index 0000000000..2f4c2c49ab --- /dev/null +++ b/pkg/generated/listers/clusterversion.openshift.io/v1/cvoconfig.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/clusterversion.openshift.io/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// CVOConfigLister helps list CVOConfigs. +type CVOConfigLister interface { + // List lists all CVOConfigs in the indexer. + List(selector labels.Selector) (ret []*v1.CVOConfig, err error) + // CVOConfigs returns an object that can list and get CVOConfigs. + CVOConfigs(namespace string) CVOConfigNamespaceLister + CVOConfigListerExpansion +} + +// cVOConfigLister implements the CVOConfigLister interface. +type cVOConfigLister struct { + indexer cache.Indexer +} + +// NewCVOConfigLister returns a new CVOConfigLister. +func NewCVOConfigLister(indexer cache.Indexer) CVOConfigLister { + return &cVOConfigLister{indexer: indexer} +} + +// List lists all CVOConfigs in the indexer. +func (s *cVOConfigLister) List(selector labels.Selector) (ret []*v1.CVOConfig, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.CVOConfig)) + }) + return ret, err +} + +// CVOConfigs returns an object that can list and get CVOConfigs. +func (s *cVOConfigLister) CVOConfigs(namespace string) CVOConfigNamespaceLister { + return cVOConfigNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CVOConfigNamespaceLister helps list and get CVOConfigs. +type CVOConfigNamespaceLister interface { + // List lists all CVOConfigs in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.CVOConfig, err error) + // Get retrieves the CVOConfig from the indexer for a given namespace and name. + Get(name string) (*v1.CVOConfig, error) + CVOConfigNamespaceListerExpansion +} + +// cVOConfigNamespaceLister implements the CVOConfigNamespaceLister +// interface. +type cVOConfigNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all CVOConfigs in the indexer for a given namespace. +func (s cVOConfigNamespaceLister) List(selector labels.Selector) (ret []*v1.CVOConfig, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.CVOConfig)) + }) + return ret, err +} + +// Get retrieves the CVOConfig from the indexer for a given namespace and name. +func (s cVOConfigNamespaceLister) Get(name string) (*v1.CVOConfig, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("cvoconfig"), name) + } + return obj.(*v1.CVOConfig), nil +} diff --git a/pkg/generated/listers/clusterversion.openshift.io/v1/expansion_generated.go b/pkg/generated/listers/clusterversion.openshift.io/v1/expansion_generated.go index 0413d56c4d..a82a5cf40d 100644 --- a/pkg/generated/listers/clusterversion.openshift.io/v1/expansion_generated.go +++ b/pkg/generated/listers/clusterversion.openshift.io/v1/expansion_generated.go @@ -18,6 +18,14 @@ limitations under the License. package v1 +// CVOConfigListerExpansion allows custom methods to be added to +// CVOConfigLister. +type CVOConfigListerExpansion interface{} + +// CVOConfigNamespaceListerExpansion allows custom methods to be added to +// CVOConfigNamespaceLister. +type CVOConfigNamespaceListerExpansion interface{} + // OperatorStatusListerExpansion allows custom methods to be added to // OperatorStatusLister. type OperatorStatusListerExpansion interface{} diff --git a/pkg/version/version.go b/pkg/version/version.go index 8146837c1c..9b226a9426 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -2,6 +2,9 @@ package version import ( "fmt" + "strings" + + "github.com/blang/semver" ) var ( @@ -9,6 +12,9 @@ var ( // with the calculated version at build time. Raw = "was not built properly" + // Version is the semver representation of the version. + Version = semver.MustParse(strings.TrimLeft(Raw, "v")) + // String is the human-friendly representation of the version. String = fmt.Sprintf("ClusterVersionOperator %s", Raw) )