From 1e0d69a83858c34fee48fe0458958e720707f70f Mon Sep 17 00:00:00 2001 From: Brandon Palm Date: Fri, 24 Jan 2025 12:28:36 -0600 Subject: [PATCH] Migrate packagemanifest code to eco-goinfra (#1053) --- tests/globalhelper/packagemanifest.go | 104 +- .../eco-goinfra/pkg/olm/catalogsource.go | 286 +++ .../eco-goinfra/pkg/olm/catalogsourcelist.go | 80 + .../pkg/olm/clusterserviceversion.go | 239 +++ .../pkg/olm/clusterserviceversionlist.go | 182 ++ .../eco-goinfra/pkg/olm/installplan.go | 272 +++ .../eco-goinfra/pkg/olm/installplanlist.go | 81 + .../eco-goinfra/pkg/olm/operatorgroup.go | 276 +++ .../eco-goinfra/pkg/olm/packagemanifest.go | 243 +++ .../pkg/olm/packagemanifestlist.go | 79 + .../eco-goinfra/pkg/olm/subscription.go | 368 ++++ .../pkg/schemes/olm/operators/doc.go | 4 + .../pkg/schemes/olm/operators/register.go | 31 + .../pkg/schemes/olm/operators/v1/doc.go | 4 + .../olm/operators/v1/groupversion_info.go | 28 + .../olm/operators/v1/olmconfig_types.go | 90 + .../olm/operators/v1/operator_types.go | 88 + .../operators/v1/operatorcondition_types.go | 49 + .../olm/operators/v1/operatorgroup_types.go | 214 +++ .../olm/operators/v1/zz_generated.deepcopy.go | 556 ++++++ .../operators/v1alpha1/catalogsource_types.go | 364 ++++ .../v1alpha1/clusterserviceversion.go | 215 +++ .../v1alpha1/clusterserviceversion_types.go | 737 ++++++++ .../pkg/schemes/olm/operators/v1alpha1/doc.go | 6 + .../operators/v1alpha1/installplan_types.go | 389 ++++ .../olm/operators/v1alpha1/register.go | 55 + .../operators/v1alpha1/subscription_types.go | 360 ++++ .../v1alpha1/zz_generated.deepcopy.go | 1632 +++++++++++++++++ .../olm/package-server/operators/doc.go | 5 + .../operators/packagemanifest_types.go | 155 ++ .../olm/package-server/operators/register.go | 36 + .../olm/package-server/operators/v1/doc.go | 7 + .../operators/v1/packagemanifest_types.go | 160 ++ .../package-server/operators/v1/register.go | 45 + .../operators/v1/zz_generated.conversion.go | 424 +++++ .../operators/v1/zz_generated.deepcopy.go | 277 +++ .../operators/v1/zz_generated.defaults.go | 33 + .../operators/zz_generated.deepcopy.go | 277 +++ .../pkg/schemes/olm/version/version.go | 67 + vendor/modules.txt | 7 + 40 files changed, 8439 insertions(+), 86 deletions(-) create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsource.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsourcelist.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversion.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversionlist.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplan.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplanlist.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/operatorgroup.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/subscription.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/doc.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/register.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/doc.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/groupversion_info.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/olmconfig_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operator_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorcondition_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorgroup_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/catalogsource_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/doc.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/installplan_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/register.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/subscription_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/doc.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/register.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/doc.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.defaults.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go create mode 100644 vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version/version.go diff --git a/tests/globalhelper/packagemanifest.go b/tests/globalhelper/packagemanifest.go index a509ea8e2..59c67954b 100644 --- a/tests/globalhelper/packagemanifest.go +++ b/tests/globalhelper/packagemanifest.go @@ -1,89 +1,39 @@ package globalhelper import ( - "context" "fmt" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" + egiClients "github.com/openshift-kni/eco-goinfra/pkg/clients" + egiOLM "github.com/openshift-kni/eco-goinfra/pkg/olm" + "sigs.k8s.io/controller-runtime/pkg/client" ) // QueryPackageManifest queries the package manifest for the operator. -// -//nolint:gocognit func QueryPackageManifestForVersion(operatorName, operatorNamespace, channel string) (string, error) { - gvr := schema.GroupVersionResource{ - Group: "packages.operators.coreos.com", - Version: "v1", - Resource: "packagemanifests", - } - - // Query the package manifest for the operator - pkgManifest, err := GetAPIClient().DynamicClient.Resource(gvr).Namespace("").List(context.TODO(), metav1.ListOptions{}) + pkgManifest, err := egiOLM.ListPackageManifest(egiClients.New(""), operatorNamespace, client.ListOptions{}) if err != nil { return "", err } - for _, item := range pkgManifest.Items { - if item.GetName() == operatorName { - // check if defaultChannel exists - if _, ok := item.Object["status"].(map[string]interface{})["defaultChannel"]; !ok { - continue - } - - // type assertion - if _, ok := item.Object["status"].(map[string]interface{})["defaultChannel"].(string); !ok { - continue - } - - //nolint:forcetypeassert - fmt.Printf("Comparing %s with %s\n", item.Object["status"].(map[string]interface{})["defaultChannel"].(string), channel) + for _, item := range pkgManifest { + if item.Object.GetName() == operatorName { + fmt.Printf("Comparing %s with %s\n", item.Object.Status.DefaultChannel, channel) - //nolint:forcetypeassert - if item.Object["status"].(map[string]interface{})["defaultChannel"].(string) != channel { + // skip if the default channel is not the one we are looking for + if item.Object.Status.DefaultChannel != channel { continue } - channelsObj, _, err := unstructured.NestedSlice(item.Object, "status", "channels") + for _, chanObj := range item.Object.Status.Channels { + fmt.Printf("Comparing name %s with channel %s\n", chanObj.Name, channel) - if err != nil { - return "", err - } - - for _, chanObj := range channelsObj { - // verify the name of the channel is the same as the one we are looking for - if _, ok := chanObj.(map[string]interface{})["name"]; !ok { - continue - } - - // type assertion - if _, ok := chanObj.(map[string]interface{})["name"].(string); !ok { + // skip if the name of the channel is not the one we are looking for + if chanObj.Name != channel { continue } - //nolint:forcetypeassert - fmt.Printf("Comparing name %s with channel %s\n", chanObj.(map[string]interface{})["name"].(string), channel) - - // skip this channel because it does not match the one we are looking for - //nolint:forcetypeassert - if chanObj.(map[string]interface{})["name"].(string) != channel { - continue - } - - // check if version exists - if _, ok := chanObj.(map[string]interface{})["currentCSVDesc"].(map[string]interface{})["version"]; !ok { - continue - } - - // type assertion - if _, ok := chanObj.(map[string]interface{})["currentCSVDesc"].(map[string]interface{})["version"].(string); !ok { - continue - } - - //nolint:forcetypeassert - return chanObj.(map[string]interface{})["currentCSVDesc"].(map[string]interface{})["version"].(string), nil + return chanObj.CurrentCSVDesc.Version.String(), nil } } } @@ -92,14 +42,7 @@ func QueryPackageManifestForVersion(operatorName, operatorNamespace, channel str } func QueryPackageManifestForDefaultChannel(operatorName, operatorNamespace string) (string, error) { - gvr := schema.GroupVersionResource{ - Group: "packages.operators.coreos.com", - Version: "v1", - Resource: "packagemanifests", - } - - // Query the package manifest for the operator - pkgManifest, err := GetAPIClient().DynamicClient.Resource(gvr).Namespace("").List(context.TODO(), metav1.ListOptions{}) + pkgManifest, err := egiOLM.ListPackageManifest(egiClients.New(""), operatorNamespace, client.ListOptions{}) if err != nil { return "", err @@ -108,20 +51,9 @@ func QueryPackageManifestForDefaultChannel(operatorName, operatorNamespace strin // Example of how to get the default channel // oc get packagemanifest cluster-logging -o json | jq .status.defaultChannel - for _, item := range pkgManifest.Items { - if item.GetName() == operatorName { - // check if defaultChannel exists - if _, ok := item.Object["status"].(map[string]interface{})["defaultChannel"]; !ok { - continue - } - - // type assertion - if _, ok := item.Object["status"].(map[string]interface{})["defaultChannel"].(string); !ok { - continue - } - - //nolint:forcetypeassert - return item.Object["status"].(map[string]interface{})["defaultChannel"].(string), nil + for _, item := range pkgManifest { + if item.Object.GetName() == operatorName { + return item.Object.Status.DefaultChannel, nil } } diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsource.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsource.go new file mode 100644 index 000000000..5323c29cd --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsource.go @@ -0,0 +1,286 @@ +package olm + +import ( + "context" + "fmt" + + oplmV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" + "github.com/openshift-kni/eco-goinfra/pkg/msg" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CatalogSourceBuilder provides a struct for catalogsource object +// from the cluster and a catalogsource definition. +type CatalogSourceBuilder struct { + // CatalogSource definition. Used to create + // CatalogSource object with minimum set of required elements. + Definition *oplmV1alpha1.CatalogSource + // Created CatalogSource object on the cluster. + Object *oplmV1alpha1.CatalogSource + // api client to interact with the cluster. + apiClient runtimeClient.Client + // errorMsg is processed before CatalogSourceBuilder object is created. + errorMsg string +} + +// NewCatalogSourceBuilder creates new instance of CatalogSourceBuilder. +func NewCatalogSourceBuilder(apiClient *clients.Settings, name, nsname string) *CatalogSourceBuilder { + glog.V(100).Infof("Initializing new %s catalogsource structure", name) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add oplmV1alpha1 scheme to client schemes") + + return nil + } + + builder := &CatalogSourceBuilder{ + apiClient: apiClient.Client, + Definition: &oplmV1alpha1.CatalogSource{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: nsname, + }, + }, + } + + if name == "" { + glog.V(100).Infof("The name of the catalogsource is empty") + + builder.errorMsg = "catalogsource 'name' cannot be empty" + + return builder + } + + if nsname == "" { + glog.V(100).Infof("The nsname of the catalogsource is empty") + + builder.errorMsg = "catalogsource 'nsname' cannot be empty" + + return builder + } + + return builder +} + +// PullCatalogSource loads an existing catalogsource into Builder struct. +func PullCatalogSource(apiClient *clients.Settings, name, nsname string) (*CatalogSourceBuilder, + error) { + glog.V(100).Infof("Pulling existing catalogsource name %s in namespace %s", name, nsname) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("catalogsource 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add oplmV1alpha1 scheme to client schemes") + + return nil, err + } + + builder := &CatalogSourceBuilder{ + apiClient: apiClient.Client, + Definition: &oplmV1alpha1.CatalogSource{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: nsname, + }, + }, + } + + if name == "" { + glog.V(100).Infof("The name of the catalogsource is empty") + + return nil, fmt.Errorf("catalogsource 'name' cannot be empty") + } + + if nsname == "" { + glog.V(100).Infof("The namespace of the catalogsource is empty") + + return nil, fmt.Errorf("catalogsource 'namespace' cannot be empty") + } + + if !builder.Exists() { + return nil, fmt.Errorf("catalogsource object %s does not exist in namespace %s", name, nsname) + } + + builder.Definition = builder.Object + + return builder, nil +} + +// Create makes an CatalogSourceBuilder in cluster and stores the created object in struct. +func (builder *CatalogSourceBuilder) Create() (*CatalogSourceBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Creating the catalogsource %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if builder.Exists() { + return builder, nil + } + + err := builder.apiClient.Create(context.TODO(), builder.Definition) + if err != nil { + return builder, err + } + + builder.Object = builder.Definition + + return builder, nil +} + +// Get returns CatalogSource object if found. +func (builder *CatalogSourceBuilder) Get() (*oplmV1alpha1.CatalogSource, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting CatalogSource object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + catalogSource := &oplmV1alpha1.CatalogSource{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + catalogSource) + + if err != nil { + glog.V(100).Infof( + "CatalogSource object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return catalogSource, nil +} + +// Update renovates the existing CatalogSource object with the CatalogSource definition in builder. +func (builder *CatalogSourceBuilder) Update(force bool) (*CatalogSourceBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Updating the CatalogSource object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace, + ) + + if !builder.Exists() { + return nil, fmt.Errorf("failed to update CatalogSource, object does not exist on cluster") + } + + err := builder.apiClient.Update(context.TODO(), builder.Definition) + + if err != nil { + if force { + glog.V(100).Infof( + msg.FailToUpdateNotification("CatalogSource", builder.Definition.Name, builder.Definition.Namespace)) + + err := builder.Delete() + + if err != nil { + glog.V(100).Infof( + msg.FailToUpdateError("CatalogSource", builder.Definition.Name, builder.Definition.Namespace)) + + return nil, err + } + + return builder.Create() + } + } + + return builder, nil +} + +// Exists checks whether the given catalogsource exists. +func (builder *CatalogSourceBuilder) Exists() bool { + if valid, _ := builder.validate(); !valid { + return false + } + + glog.V(100).Infof( + "Checking if catalogSource %s exists", + builder.Definition.Name) + + var err error + builder.Object, err = builder.Get() + + return err == nil || !k8serrors.IsNotFound(err) +} + +// Delete removes a catalogsource. +func (builder *CatalogSourceBuilder) Delete() error { + if valid, err := builder.validate(); !valid { + return err + } + + glog.V(100).Infof("Deleting catalogsource %s in namespace %s", builder.Definition.Name, + builder.Definition.Namespace) + + if !builder.Exists() { + glog.V(100).Infof("catalogsource cannot be deleted because it does not exist") + + builder.Object = nil + + return nil + } + + err := builder.apiClient.Delete(context.TODO(), builder.Definition) + + if err != nil { + return err + } + + builder.Object = nil + + return nil +} + +// validate will check that the builder and builder definition are properly initialized before +// accessing any member fields. +func (builder *CatalogSourceBuilder) validate() (bool, error) { + resourceCRD := "catalogsource" + + if builder == nil { + glog.V(100).Infof("The %s builder is uninitialized", resourceCRD) + + return false, fmt.Errorf("error: received nil %s builder", resourceCRD) + } + + if builder.Definition == nil { + glog.V(100).Infof("The %s is undefined", resourceCRD) + + return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD)) + } + + if builder.apiClient == nil { + glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD) + + return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD) + } + + if builder.errorMsg != "" { + glog.V(100).Infof("The %s builder has error message: %s", resourceCRD, builder.errorMsg) + + return false, fmt.Errorf(builder.errorMsg) + } + + return true, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsourcelist.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsourcelist.go new file mode 100644 index 000000000..ce570092e --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/catalogsourcelist.go @@ -0,0 +1,80 @@ +package olm + +import ( + "context" + "fmt" + + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" + oplmV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" +) + +// ListCatalogSources returns catalogsource inventory in the given namespace. +func ListCatalogSources( + apiClient *clients.Settings, + nsname string, + options ...client.ListOptions) ([]*CatalogSourceBuilder, error) { + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("failed to list catalogSource, 'apiClient' parameter is empty") + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add oplmV1alpha1 scheme to client schemes") + + return nil, err + } + + if nsname == "" { + glog.V(100).Infof("catalogsource 'nsname' parameter can not be empty") + + return nil, fmt.Errorf("failed to list catalogsource, 'nsname' parameter is empty") + } + + passedOptions := client.ListOptions{} + logMessage := fmt.Sprintf("Listing catalogsource in the namespace %s", nsname) + + if len(options) > 1 { + glog.V(100).Infof("'options' parameter must be empty or single-valued") + + return nil, fmt.Errorf("error: more than one ListOptions was passed") + } + + if len(options) == 1 { + passedOptions = options[0] + logMessage += fmt.Sprintf(" with the options %v", passedOptions) + } + + glog.V(100).Infof(logMessage) + + passedOptions.Namespace = nsname + + catalogSourceList := new(oplmV1alpha1.CatalogSourceList) + err = apiClient.List(context.TODO(), catalogSourceList, &passedOptions) + + if err != nil { + glog.V(100).Infof("Failed to list catalogsources in the namespace %s due to %s", nsname, err.Error()) + + return nil, err + } + + var catalogSourceObjects []*CatalogSourceBuilder + + for _, existingCatalogSource := range catalogSourceList.Items { + copiedCatalogSource := existingCatalogSource + catalogSourceBuilder := &CatalogSourceBuilder{ + apiClient: apiClient.Client, + Object: &copiedCatalogSource, + Definition: &copiedCatalogSource, + } + + catalogSourceObjects = append(catalogSourceObjects, catalogSourceBuilder) + } + + return catalogSourceObjects, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversion.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversion.go new file mode 100644 index 000000000..1a0ba5d1a --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversion.go @@ -0,0 +1,239 @@ +package olm + +import ( + "context" + "fmt" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" + "github.com/openshift-kni/eco-goinfra/pkg/msg" + oplmV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" +) + +// ClusterServiceVersionBuilder provides a struct for clusterserviceversion object +// from the cluster and a clusterserviceversion definition. +type ClusterServiceVersionBuilder struct { + // ClusterServiceVersionBuilder definition. Used to create + // ClusterServiceVersionBuilder object with minimum set of required elements. + Definition *oplmV1alpha1.ClusterServiceVersion + // Created ClusterServiceVersionBuilder object on the cluster. + Object *oplmV1alpha1.ClusterServiceVersion + // api client to interact with the cluster. + apiClient *clients.Settings + // errorMsg is processed before ClusterServiceVersionBuilder object is created. + errorMsg string +} + +// PullClusterServiceVersion loads an existing clusterserviceversion into Builder struct. +func PullClusterServiceVersion(apiClient *clients.Settings, name, namespace string) (*ClusterServiceVersionBuilder, + error) { + glog.V(100).Infof("Pulling existing clusterserviceversion name %s in namespace %s", name, namespace) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("clusterserviceversion 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsV1alpha1 scheme to client schemes") + + return nil, err + } + + builder := ClusterServiceVersionBuilder{ + apiClient: apiClient, + Definition: &oplmV1alpha1.ClusterServiceVersion{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + }, + } + + if name == "" { + glog.V(100).Infof("The name of the clusterserviceversion is empty") + + return nil, fmt.Errorf("clusterserviceversion 'name' cannot be empty") + } + + if namespace == "" { + glog.V(100).Infof("The namespace of the clusterserviceversion is empty") + + return nil, fmt.Errorf("clusterserviceversion 'namespace' cannot be empty") + } + + if !builder.Exists() { + return nil, fmt.Errorf("clusterserviceversion object %s does not exist in namespace %s", name, namespace) + } + + builder.Definition = builder.Object + + return &builder, nil +} + +// Get returns ClusterServiceVersion object if found. +func (builder *ClusterServiceVersionBuilder) Get() (*oplmV1alpha1.ClusterServiceVersion, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting ClusterServiceVersion object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + clusterServiceVersion := &oplmV1alpha1.ClusterServiceVersion{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + clusterServiceVersion) + + if err != nil { + glog.V(100).Infof( + "ClusterServiceVersion object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return clusterServiceVersion, nil +} + +// Exists checks whether the given ClusterService exists. +func (builder *ClusterServiceVersionBuilder) Exists() bool { + if valid, _ := builder.validate(); !valid { + return false + } + + glog.V(100).Infof( + "Checking if ClusterServiceVersion %s exists", + builder.Definition.Name) + + var err error + builder.Object, err = builder.Get() + + return err == nil || !k8serrors.IsNotFound(err) +} + +// Delete removes a clusterserviceversion. +func (builder *ClusterServiceVersionBuilder) Delete() error { + if valid, err := builder.validate(); !valid { + return err + } + + glog.V(100).Infof("Deleting clusterserviceversion %s in namespace %s", builder.Definition.Name, + builder.Definition.Namespace) + + if !builder.Exists() { + glog.V(100).Infof("clusterserviceversion %s namespace %s cannot be deleted because it does not exist", + builder.Definition.Name, builder.Definition.Namespace) + + builder.Object = nil + + return nil + } + + err := builder.apiClient.Delete(context.TODO(), builder.Definition) + + if err != nil { + return err + } + + builder.Object = nil + + return nil +} + +// GetAlmExamples extracts and returns the alm-examples block from the clusterserviceversion. +func (builder *ClusterServiceVersionBuilder) GetAlmExamples() (string, error) { + if valid, err := builder.validate(); !valid { + return "", err + } + + glog.V(100).Infof("Extracting the 'alm-examples' section from clusterserviceversion %s in "+ + "namespace %s", builder.Definition.Name, builder.Definition.Namespace) + + almExamples := "alm-examples" + + if builder.Exists() { + annotations := builder.Object.ObjectMeta.GetAnnotations() + + if example, ok := annotations[almExamples]; ok { + return example, nil + } + } + + return "", fmt.Errorf("%s not found in given clusterserviceversion named %v", + almExamples, builder.Definition.Name) +} + +// IsSuccessful checks if the clusterserviceversion is Successful. +func (builder *ClusterServiceVersionBuilder) IsSuccessful() (bool, error) { + if valid, err := builder.validate(); !valid { + return false, err + } + + glog.V(100).Infof("Verify clusterserviceversion %s in namespace %s is Successful", + builder.Definition.Name, builder.Definition.Namespace) + + phase, err := builder.GetPhase() + + if err != nil { + return false, fmt.Errorf("failed to get phase value for %s clusterserviceversion in %s namespace due to %w", + builder.Definition.Name, builder.Definition.Namespace, err) + } + + return phase == "Succeeded", nil +} + +// GetPhase gets current clusterserviceversion phase. +func (builder *ClusterServiceVersionBuilder) GetPhase() (oplmV1alpha1.ClusterServiceVersionPhase, error) { + if valid, err := builder.validate(); !valid { + return "", err + } + + glog.V(100).Infof("Get clusterserviceversion %s phase in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if !builder.Exists() { + return "", fmt.Errorf("%s clusterserviceversion not found in %s namespace", + builder.Definition.Name, builder.Definition.Namespace) + } + + return builder.Object.Status.Phase, nil +} + +// validate will check that the builder and builder definition are properly initialized before +// accessing any member fields. +func (builder *ClusterServiceVersionBuilder) validate() (bool, error) { + resourceCRD := "ClusterServiceVersion" + + if builder == nil { + glog.V(100).Infof("The %s builder is uninitialized", resourceCRD) + + return false, fmt.Errorf("error: received nil %s builder", resourceCRD) + } + + if builder.Definition == nil { + glog.V(100).Infof("The %s is undefined", resourceCRD) + + return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD)) + } + + if builder.apiClient == nil { + glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD) + + return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD) + } + + if builder.errorMsg != "" { + glog.V(100).Infof("The %s builder has error message: %s", resourceCRD, builder.errorMsg) + + return false, fmt.Errorf(builder.errorMsg) + } + + return true, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversionlist.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversionlist.go new file mode 100644 index 000000000..e8294d06a --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/clusterserviceversionlist.go @@ -0,0 +1,182 @@ +package olm + +import ( + "context" + "fmt" + "strings" + + oplmV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" +) + +// ListClusterServiceVersion returns clusterserviceversion inventory in the given namespace. +func ListClusterServiceVersion( + apiClient *clients.Settings, + nsname string, + options ...client.ListOptions) ([]*ClusterServiceVersionBuilder, error) { + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("clusterserviceversion 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add oplmV1alpha1 scheme to client schemes") + + return nil, err + } + + if nsname == "" { + glog.V(100).Infof("clusterserviceversion 'nsname' parameter can not be empty") + + return nil, fmt.Errorf("failed to list clusterserviceversion, 'nsname' parameter is empty") + } + + passedOptions := client.ListOptions{} + logMessage := fmt.Sprintf("Listing clusterserviceversion in the namespace %s", nsname) + + if len(options) > 1 { + glog.V(100).Infof("'options' parameter must be empty or single-valued") + + return nil, fmt.Errorf("error: more than one ListOptions was passed") + } + + if len(options) == 1 { + passedOptions = options[0] + logMessage += fmt.Sprintf(" with the options %v", passedOptions) + } + + glog.V(100).Infof(logMessage) + + csvList := new(oplmV1alpha1.ClusterServiceVersionList) + err = apiClient.List(context.TODO(), csvList, &passedOptions) + + if err != nil { + glog.V(100).Infof("Failed to list clusterserviceversion in the nsname %s due to %s", nsname, err.Error()) + + return nil, err + } + + var csvObjects []*ClusterServiceVersionBuilder + + for _, runningCSV := range csvList.Items { + copiedCSV := runningCSV + csvBuilder := &ClusterServiceVersionBuilder{ + apiClient: apiClient, + Object: &copiedCSV, + Definition: &copiedCSV, + } + + csvObjects = append(csvObjects, csvBuilder) + } + + return csvObjects, nil +} + +// ListClusterServiceVersionWithNamePattern returns a cluster-wide clusterserviceversion inventory +// filtered by the name pattern. +func ListClusterServiceVersionWithNamePattern( + apiClient *clients.Settings, + namePattern string, + nsname string, + options ...client.ListOptions) ([]*ClusterServiceVersionBuilder, error) { + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("clusterserviceversion 'apiClient' cannot be empty") + } + + if namePattern == "" { + glog.V(100).Info( + "The namePattern field to filter out all relevant clusterserviceversion cannot be empty") + + return nil, fmt.Errorf( + "the namePattern field to filter out all relevant clusterserviceversion cannot be empty") + } + + glog.V(100).Infof("Listing clusterserviceversion filtered by the name pattern %s in %s namespace", + namePattern, nsname) + + notFilteredCsvList, err := ListClusterServiceVersion(apiClient, nsname, options...) + + if err != nil { + glog.V(100).Infof("Failed to list all clusterserviceversions in namespace %s due to %s", + nsname, err.Error()) + + return nil, err + } + + var finalCsvList []*ClusterServiceVersionBuilder + + for _, foundCsv := range notFilteredCsvList { + if strings.Contains(foundCsv.Definition.Name, namePattern) { + finalCsvList = append(finalCsvList, foundCsv) + } + } + + return finalCsvList, nil +} + +// ListClusterServiceVersionInAllNamespaces returns cluster-wide clusterserviceversion inventory. +func ListClusterServiceVersionInAllNamespaces( + apiClient *clients.Settings, + options ...client.ListOptions) ([]*ClusterServiceVersionBuilder, error) { + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("clusterserviceversion 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add oplmV1alpha1 scheme to client schemes") + + return nil, err + } + + passedOptions := client.ListOptions{} + logMessage := "Listing CSVs in all namespaces" + + if len(options) > 1 { + glog.V(100).Infof("'options' parameter must be empty or single-valued") + + return nil, fmt.Errorf("error: more than one ListOptions was passed") + } + + if len(options) == 1 { + passedOptions = options[0] + logMessage += fmt.Sprintf(" with the options %v", passedOptions) + } + + glog.V(100).Infof(logMessage) + + csvList := new(oplmV1alpha1.ClusterServiceVersionList) + err = apiClient.List(context.TODO(), csvList, &passedOptions) + + if err != nil { + glog.V(100).Infof("Failed to list CSVs in all namespaces due to %s", err.Error()) + + return nil, err + } + + var csvObjects []*ClusterServiceVersionBuilder + + for _, csvs := range csvList.Items { + copiedCSV := csvs + csvBuilder := &ClusterServiceVersionBuilder{ + apiClient: apiClient, + Object: &copiedCSV, + Definition: &copiedCSV, + } + + csvObjects = append(csvObjects, csvBuilder) + } + + return csvObjects, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplan.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplan.go new file mode 100644 index 000000000..4417070c8 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplan.go @@ -0,0 +1,272 @@ +package olm + +import ( + "context" + "fmt" + + operatorsV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openshift-kni/eco-goinfra/pkg/msg" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// InstallPlanBuilder provides a struct for installplan object from the cluster and an installplan definition. +type InstallPlanBuilder struct { + // Installplan definition, used to create the installplan object. + Definition *operatorsV1alpha1.InstallPlan + // Created installplan object. + Object *operatorsV1alpha1.InstallPlan + // Used in functions that define or mutate installplan definition. errorMsg is processed + // before the installplan object is created + errorMsg string + // api client to interact with the cluster. + apiClient runtimeClient.Client +} + +// NewInstallPlanBuilder creates new instance of InstallPlanBuilder. +func NewInstallPlanBuilder(apiClient *clients.Settings, name, nsname string) *InstallPlanBuilder { + glog.V(100).Infof("Initializing new %s installplan structure", name) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil + } + + err := apiClient.AttachScheme(operatorsV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsV1alpha1 scheme to client schemes") + + return nil + } + + builder := &InstallPlanBuilder{ + apiClient: apiClient.Client, + Definition: &operatorsV1alpha1.InstallPlan{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: nsname, + }, + }, + } + + if name == "" { + glog.V(100).Infof("The name of the installplan is empty") + + builder.errorMsg = "installplan 'name' cannot be empty" + + return builder + } + + if nsname == "" { + glog.V(100).Infof("The nsname of the installplan is empty") + + builder.errorMsg = "installplan 'nsname' cannot be empty" + + return builder + } + + return builder +} + +// PullInstallPlan loads existing InstallPlan from cluster into the InstallPlanBuilder struct. +func PullInstallPlan(apiClient *clients.Settings, name, nsName string) (*InstallPlanBuilder, error) { + glog.V(100).Infof("Pulling existing InstallPlan %s from cluster in namespace %s", name, nsName) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("installPlan 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(operatorsV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsV1alpha1 scheme to client schemes") + + return nil, err + } + + builder := &InstallPlanBuilder{ + apiClient: apiClient.Client, + Definition: &operatorsV1alpha1.InstallPlan{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: nsName, + }, + }, + } + + if name == "" { + glog.V(100).Infof("The name of the InstallPlan is empty") + + return nil, fmt.Errorf("installPlan 'name' cannot be empty") + } + + if nsName == "" { + glog.V(100).Infof("The namespace of the InstallPlan is empty") + + return nil, fmt.Errorf("installPlan 'nsName' cannot be empty") + } + + if !builder.Exists() { + return nil, fmt.Errorf( + "installPlan object named %s does not exist in namespace %s", name, nsName) + } + + builder.Definition = builder.Object + + return builder, nil +} + +// Get returns InstallPlan object if found. +func (builder *InstallPlanBuilder) Get() (*operatorsV1alpha1.InstallPlan, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting InstallPlan object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + installPlan := &operatorsV1alpha1.InstallPlan{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + installPlan) + + if err != nil { + glog.V(100).Infof( + "InstallPlan object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return installPlan, nil +} + +// Create makes an InstallPlanBuilder in cluster and stores the created object in struct. +func (builder *InstallPlanBuilder) Create() (*InstallPlanBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Creating the InstallPlan %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if builder.Exists() { + return builder, nil + } + + err := builder.apiClient.Create(context.TODO(), builder.Definition) + if err != nil { + return builder, err + } + + builder.Object = builder.Definition + + return builder, nil +} + +// Exists checks whether the given installplan exists. +func (builder *InstallPlanBuilder) Exists() bool { + if valid, _ := builder.validate(); !valid { + return false + } + + glog.V(100).Infof("Checking if installplan %s exists in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + var err error + builder.Object, err = builder.Get() + + return err == nil || !k8serrors.IsNotFound(err) +} + +// Delete removes an installplan. +func (builder *InstallPlanBuilder) Delete() error { + if valid, err := builder.validate(); !valid { + return err + } + + glog.V(100).Infof("Deleting installplan %s in namespace %s", builder.Definition.Name, + builder.Definition.Namespace) + + if !builder.Exists() { + glog.V(100).Infof("InstallPlan object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + builder.Object = nil + + return nil + } + + err := builder.apiClient.Delete(context.TODO(), builder.Definition) + + if err != nil { + return err + } + + builder.Object = nil + + return nil +} + +// Update modifies the existing InstallPlanBuilder with the InstallPlan definition in InstallPlanBuilder. +func (builder *InstallPlanBuilder) Update() (*InstallPlanBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Updating installPlan %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if !builder.Exists() { + return nil, fmt.Errorf("installPlan named %s in namespace %s does not exist", + builder.Definition.Name, builder.Definition.Namespace) + } + + err := builder.apiClient.Update(context.TODO(), builder.Definition) + + if err == nil { + builder.Object = builder.Definition + } + + return builder, err +} + +// validate will check that the builder and builder definition are properly initialized before +// accessing any member fields. +func (builder *InstallPlanBuilder) validate() (bool, error) { + resourceCRD := "installplan" + + if builder == nil { + glog.V(100).Infof("The builder %s is uninitialized", resourceCRD) + + return false, fmt.Errorf("error: received nil %s builder", resourceCRD) + } + + if builder.Definition == nil { + glog.V(100).Infof("The %s is undefined", resourceCRD) + + return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD)) + } + + if builder.apiClient == nil { + glog.V(100).Infof("The builder %s apiclient is nil", resourceCRD) + + return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD) + } + + if builder.errorMsg != "" { + glog.V(100).Infof("The builder %s has error message: %w", resourceCRD, builder.errorMsg) + + return false, fmt.Errorf(builder.errorMsg) + } + + return true, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplanlist.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplanlist.go new file mode 100644 index 000000000..e853b4ffb --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/installplanlist.go @@ -0,0 +1,81 @@ +package olm + +import ( + "context" + "fmt" + + oplmV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" +) + +// ListInstallPlan returns a list of installplans found for specific namespace. +func ListInstallPlan( + apiClient *clients.Settings, nsname string, options ...client.ListOptions) ([]*InstallPlanBuilder, error) { + if nsname == "" { + glog.V(100).Info("The nsname of the installplan is empty") + + return nil, fmt.Errorf("the nsname of the installplan is empty") + } + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("failed to list installPlan, 'apiClient' parameter is empty") + } + + err := apiClient.AttachScheme(oplmV1alpha1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add oplmV1alpha1 scheme to client schemes") + + return nil, err + } + + passedOptions := client.ListOptions{} + logMessage := fmt.Sprintf("Listing InstallPlans in namespace %s", nsname) + + if len(options) > 1 { + glog.V(100).Infof("'options' parameter must be empty or single-valued") + + return nil, fmt.Errorf("error: more than one ListOptions was passed") + } + + if len(options) == 1 { + passedOptions = options[0] + logMessage += fmt.Sprintf(" with the options %v", passedOptions) + } + + glog.V(100).Infof(logMessage) + + installPlanList := new(oplmV1alpha1.InstallPlanList) + err = apiClient.List(context.TODO(), installPlanList, &passedOptions) + + if err != nil { + glog.V(100).Infof("Failed to list all installplan in namespace %s due to %s", + nsname, err.Error()) + + return nil, err + } + + var installPlanObjects []*InstallPlanBuilder + + for _, foundCsv := range installPlanList.Items { + copiedCsv := foundCsv + csvBuilder := &InstallPlanBuilder{ + apiClient: apiClient.Client, + Object: &copiedCsv, + Definition: &copiedCsv, + } + + installPlanObjects = append(installPlanObjects, csvBuilder) + } + + if len(installPlanObjects) == 0 { + return nil, fmt.Errorf("installplan not found in namespace %s", nsname) + } + + return installPlanObjects, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/operatorgroup.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/operatorgroup.go new file mode 100644 index 000000000..e8c0e5953 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/operatorgroup.go @@ -0,0 +1,276 @@ +package olm + +import ( + "context" + "fmt" + + operatorsv1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/golang/glog" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + + "github.com/openshift-kni/eco-goinfra/pkg/clients" + "github.com/openshift-kni/eco-goinfra/pkg/msg" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// OperatorGroupBuilder provides a struct for OperatorGroup object containing connection to the +// cluster and the OperatorGroup definition. +type OperatorGroupBuilder struct { + // OperatorGroup definition. Used to create OperatorGroup object with minimum set of required elements. + Definition *operatorsv1.OperatorGroup + // Created OperatorGroup object on the cluster. + Object *operatorsv1.OperatorGroup + // api client to interact with the cluster. + apiClient runtimeClient.Client + // errorMsg is processed before OperatorGroup object is created. + errorMsg string +} + +// NewOperatorGroupBuilder returns an OperatorGroupBuilder struct. +func NewOperatorGroupBuilder(apiClient *clients.Settings, groupName, nsName string) *OperatorGroupBuilder { + glog.V(100).Infof( + "Initializing new OperatorGroupBuilder structure with the following params: %s, %s", groupName, nsName) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil + } + + err := apiClient.AttachScheme(operatorsv1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsv1 scheme to client schemes") + + return nil + } + + builder := &OperatorGroupBuilder{ + apiClient: apiClient.Client, + Definition: &operatorsv1.OperatorGroup{ + ObjectMeta: metav1.ObjectMeta{ + Name: groupName, + Namespace: nsName, + GenerateName: fmt.Sprintf("%v-", groupName), + }, + Spec: operatorsv1.OperatorGroupSpec{ + TargetNamespaces: []string{nsName}, + }, + }, + } + + if groupName == "" { + glog.V(100).Infof("The Name of the OperatorGroup is empty") + + builder.errorMsg = "operatorGroup 'groupName' cannot be empty" + + return builder + } + + if nsName == "" { + glog.V(100).Infof("The Namespace of the OperatorGroup is empty") + + builder.errorMsg = "operatorGroup 'Namespace' cannot be empty" + + return builder + } + + return builder +} + +// Get returns OperatorGroup object if found. +func (builder *OperatorGroupBuilder) Get() (*operatorsv1.OperatorGroup, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting operatorGroup object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + operatorGroup := &operatorsv1.OperatorGroup{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + operatorGroup) + + if err != nil { + glog.V(100).Infof( + "OperatorGroup object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return operatorGroup, nil +} + +// Create makes an OperatorGroup in cluster and stores the created object in struct. +func (builder *OperatorGroupBuilder) Create() (*OperatorGroupBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Creating the OperatorGroup %s", builder.Definition.Name) + + if builder.Exists() { + return builder, nil + } + + err := builder.apiClient.Create(context.TODO(), builder.Definition) + if err != nil { + return builder, err + } + + builder.Object = builder.Definition + + return builder, nil +} + +// Exists checks whether the given OperatorGroup exists. +func (builder *OperatorGroupBuilder) Exists() bool { + if valid, _ := builder.validate(); !valid { + return false + } + + glog.V(100).Infof("Checking if OperatorGroup %s exists in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + var err error + builder.Object, err = builder.Get() + + return err == nil || !k8serrors.IsNotFound(err) +} + +// Delete removes an OperatorGroup. +func (builder *OperatorGroupBuilder) Delete() error { + if valid, err := builder.validate(); !valid { + return err + } + + glog.V(100).Infof("Deleting OperatorGroup %s in namespace %s", builder.Definition.Name, + builder.Definition.Namespace) + + if !builder.Exists() { + glog.V(100).Infof("OperatorGroup %s namespace %s cannot be deleted because it does not exist", + builder.Definition.Name, builder.Definition.Namespace) + + builder.Object = nil + + return nil + } + + err := builder.apiClient.Delete(context.TODO(), builder.Definition) + + if err != nil { + return err + } + + builder.Object = nil + + return nil +} + +// Update modifies the existing OperatorGroup with the OperatorGroup definition in OperatorGroupBuilder. +func (builder *OperatorGroupBuilder) Update() (*OperatorGroupBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Updating OperatorGroup %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if !builder.Exists() { + return nil, fmt.Errorf("cannot update non-existent operatorgroup") + } + + err := builder.apiClient.Update(context.TODO(), builder.Definition) + + if err == nil { + builder.Object = builder.Definition + } + + return builder, err +} + +// PullOperatorGroup loads existing OperatorGroup from cluster into the OperatorGroupBuilder struct. +func PullOperatorGroup(apiClient *clients.Settings, groupName, nsName string) (*OperatorGroupBuilder, error) { + glog.V(100).Infof("Pulling existing OperatorGroup %s from cluster in namespace %s", + groupName, nsName) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("operatorGroup 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(operatorsv1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsv1 scheme to client schemes") + + return nil, err + } + + builder := &OperatorGroupBuilder{ + apiClient: apiClient.Client, + Definition: &operatorsv1.OperatorGroup{ + ObjectMeta: metav1.ObjectMeta{ + Name: groupName, + Namespace: nsName, + GenerateName: fmt.Sprintf("%v-", groupName), + }, + }, + } + + if groupName == "" { + glog.V(100).Infof("The name of the OperatorGroup is empty") + + return nil, fmt.Errorf("operatorGroup 'Name' cannot be empty") + } + + if nsName == "" { + glog.V(100).Infof("The namespace of the OperatorGroup is empty") + + return nil, fmt.Errorf("operatorGroup 'Namespace' cannot be empty") + } + + if !builder.Exists() { + return nil, fmt.Errorf("operatorGroup object named %s does not exist", nsName) + } + + builder.Definition = builder.Object + + return builder, nil +} + +// validate will check that the builder and builder definition are properly initialized before +// accessing any member fields. +func (builder *OperatorGroupBuilder) validate() (bool, error) { + resourceCRD := "OperatorGroup" + + if builder == nil { + glog.V(100).Infof("The %s builder is uninitialized", resourceCRD) + + return false, fmt.Errorf("error: received nil %s builder", resourceCRD) + } + + if builder.Definition == nil { + glog.V(100).Infof("The %s is undefined", resourceCRD) + + return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD)) + } + + if builder.apiClient == nil { + glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD) + + return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD) + } + + if builder.errorMsg != "" { + glog.V(100).Infof("The %s builder has error message: %s", resourceCRD, builder.errorMsg) + + return false, fmt.Errorf(builder.errorMsg) + } + + return true, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go new file mode 100644 index 000000000..5c96f31b6 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifest.go @@ -0,0 +1,243 @@ +package olm + +import ( + "context" + "fmt" + + "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/labels" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" + "github.com/openshift-kni/eco-goinfra/pkg/msg" + operatorv1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" +) + +// PackageManifestBuilder provides a struct for PackageManifest object from the cluster +// and a PackageManifest definition. +type PackageManifestBuilder struct { + // PackageManifest definition. Used to create + // PackageManifest object with minimum set of required elements. + Definition *operatorv1.PackageManifest + // Created PackageManifest object on the cluster. + Object *operatorv1.PackageManifest + // api client to interact with the cluster. + apiClient runtimeClient.Client + // errorMsg is processed before PackageManifest object is created. + errorMsg string +} + +// PullPackageManifest loads an existing PackageManifest into Builder struct. +func PullPackageManifest(apiClient *clients.Settings, name, nsname string) (*PackageManifestBuilder, error) { + glog.V(100).Infof("Pulling existing PackageManifest name %s in namespace %s", name, nsname) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("packagemanifest 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(operatorv1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add operatorv1 scheme to client schemes") + + return nil, err + } + + builder := &PackageManifestBuilder{ + apiClient: apiClient.Client, + Definition: &operatorv1.PackageManifest{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: nsname, + }, + }, + } + + if name == "" { + glog.V(100).Infof("The Name of the PackageManifest is empty") + + return nil, fmt.Errorf("packageManifest 'name' cannot be empty") + } + + if nsname == "" { + glog.V(100).Infof("The Namespace of the PackageManifest is empty") + + return nil, fmt.Errorf("packageManifest 'nsname' cannot be empty") + } + + if !builder.Exists() { + return nil, fmt.Errorf("packageManifest object %s does not exist in namespace %s", name, nsname) + } + + builder.Definition = builder.Object + + return builder, nil +} + +// PullPackageManifestByCatalog loads an existing PackageManifest from specified catalog into Builder struct. +func PullPackageManifestByCatalog(apiClient *clients.Settings, name, nsname, + catalog string) (*PackageManifestBuilder, error) { + glog.V(100).Infof("Pulling existing PackageManifest name %s in namespace %s and from catalog %s", + name, nsname, catalog) + + if name == "" { + glog.V(100).Infof("The Name of the PackageManifest is empty") + + return nil, fmt.Errorf("packageManifest 'name' cannot be empty") + } + + fieldSelector, err := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", name)) + + if err != nil { + glog.V(100).Infof("Failed to parse invalid packageManifest name %s", name) + + return nil, err + } + + if catalog == "" { + glog.V(100).Infof("The Catalog of the PackageManifest is empty") + + return nil, fmt.Errorf("packageManifest 'catalog' cannot be empty") + } + + labelSelector, err := labels.Parse(fmt.Sprintf("catalog=%s", catalog)) + + if err != nil { + glog.V(100).Infof("Failed to parse invalid catalog name %s", catalog) + + return nil, err + } + + packageManifests, err := ListPackageManifest(apiClient, nsname, runtimeClient.ListOptions{ + LabelSelector: labelSelector, + FieldSelector: fieldSelector, + }) + + if err != nil { + glog.V(100).Infof("Failed to list PackageManifests with name %s in namespace %s from catalog"+ + " %s due to %s", name, nsname, catalog, err.Error()) + + return nil, err + } + + if len(packageManifests) == 0 { + glog.V(100).Infof("The list of matching PackageManifests is empty") + + return nil, fmt.Errorf("no matching PackageManifests were found") + } + + if len(packageManifests) > 1 { + glog.V(100).Infof("More than one matching PackageManifests were found") + + return nil, fmt.Errorf("more than one matching PackageManifests were found") + } + + return packageManifests[0], nil +} + +// Get returns PackageManifest object if found. +func (builder *PackageManifestBuilder) Get() (*operatorv1.PackageManifest, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting packageManifest object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + packageManifest := &operatorv1.PackageManifest{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + packageManifest) + + if err != nil { + glog.V(100).Infof( + "PackageManifest object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return packageManifest, nil +} + +// Exists checks whether the given PackageManifest exists. +func (builder *PackageManifestBuilder) Exists() bool { + if valid, _ := builder.validate(); !valid { + return false + } + + glog.V(100).Infof( + "Checking if PackageManifest %s exists", builder.Definition.Name) + + var err error + builder.Object, err = builder.Get() + + return err == nil || !k8serrors.IsNotFound(err) +} + +// Delete removes a PackageManifest. +func (builder *PackageManifestBuilder) Delete() error { + if valid, err := builder.validate(); !valid { + return err + } + + glog.V(100).Infof("Deleting PackageManifest %s in namespace %s", builder.Definition.Name, + builder.Definition.Namespace) + + if !builder.Exists() { + glog.V(100).Infof("PackageManifest object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + builder.Object = nil + + return nil + } + + err := builder.apiClient.Delete(context.TODO(), builder.Definition) + + if err != nil { + return err + } + + builder.Object = nil + + return nil +} + +// validate will check that the builder and builder definition are properly initialized before +// accessing any member fields. +func (builder *PackageManifestBuilder) validate() (bool, error) { + resourceCRD := "PackageManifest" + + if builder == nil { + glog.V(100).Infof("The %s builder is uninitialized", resourceCRD) + + return false, fmt.Errorf("error: received nil %s builder", resourceCRD) + } + + if builder.Definition == nil { + glog.V(100).Infof("The %s is undefined", resourceCRD) + + return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD)) + } + + if builder.apiClient == nil { + glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD) + + return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD) + } + + if builder.errorMsg != "" { + glog.V(100).Infof("The %s builder has error message: %s", resourceCRD, builder.errorMsg) + + return false, fmt.Errorf(builder.errorMsg) + } + + return true, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go new file mode 100644 index 000000000..2384b9c12 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/packagemanifestlist.go @@ -0,0 +1,79 @@ +package olm + +import ( + "context" + "fmt" + + operatorv1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" +) + +// ListPackageManifest returns PackageManifest inventory in the given namespace. +func ListPackageManifest( + apiClient *clients.Settings, + nsname string, + options ...client.ListOptions) ([]*PackageManifestBuilder, error) { + if nsname == "" { + glog.V(100).Infof("packagemanifest 'nsname' parameter can not be empty") + + return nil, fmt.Errorf("failed to list packagemanifests, 'nsname' parameter is empty") + } + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("failed to list packageManifest, 'apiClient' parameter is empty") + } + + err := apiClient.AttachScheme(operatorv1.AddToScheme) + + if err != nil { + glog.V(100).Infof("Failed to add packageManifest scheme to client schemes") + + return nil, err + } + + passedOptions := client.ListOptions{} + logMessage := fmt.Sprintf("Listing PackageManifests in the namespace %s", nsname) + + if len(options) > 1 { + glog.V(100).Infof("'options' parameter must be empty or single-valued") + + return nil, fmt.Errorf("error: more than one ListOptions was passed") + } + + if len(options) == 1 { + passedOptions = options[0] + logMessage += fmt.Sprintf(" with the options %v", passedOptions) + } + + glog.V(100).Infof(logMessage) + + pkgManifestList := new(operatorv1.PackageManifestList) + err = apiClient.List(context.TODO(), pkgManifestList, &passedOptions) + + if err != nil { + glog.V(100).Infof("Failed to list PackageManifests in the namespace %s due to %s", + nsname, err.Error()) + + return nil, err + } + + var pkgManifestObjects []*PackageManifestBuilder + + for _, runningPkgManifest := range pkgManifestList.Items { + copiedPkgManifest := runningPkgManifest + pkgManifestBuilder := &PackageManifestBuilder{ + apiClient: apiClient.Client, + Object: &copiedPkgManifest, + Definition: &copiedPkgManifest, + } + + pkgManifestObjects = append(pkgManifestObjects, pkgManifestBuilder) + } + + return pkgManifestObjects, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/subscription.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/subscription.go new file mode 100644 index 000000000..acdd276d2 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/olm/subscription.go @@ -0,0 +1,368 @@ +package olm + +import ( + "context" + "fmt" + + "github.com/golang/glog" + "github.com/openshift-kni/eco-goinfra/pkg/clients" + "github.com/openshift-kni/eco-goinfra/pkg/msg" + operatorsV1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtimeClient "sigs.k8s.io/controller-runtime/pkg/client" +) + +// SubscriptionBuilder provides a struct for Subscription object containing connection to the +// cluster and the Subscription definition. +type SubscriptionBuilder struct { + // Subscription definition. Used to create Subscription object with minimum set of required elements. + Definition *operatorsV1alpha1.Subscription + // Created Subscription object on the cluster. + Object *operatorsV1alpha1.Subscription + // api client to interact with the cluster. + apiClient runtimeClient.Client + // errorMsg is processed before Subscription object is created. + errorMsg string +} + +// NewSubscriptionBuilder returns a SubscriptionBuilder. +func NewSubscriptionBuilder(apiClient *clients.Settings, subName, subNamespace, catalogSource, catalogSourceNamespace, + packageName string) *SubscriptionBuilder { + glog.V(100).Infof( + "Initializing new SubscriptionBuilder structure with the following params, subName: %s, "+ + "subNamespace: %s, catalogSource: %s, catalogSourceNamespace: %s, packageName: %s ", + subName, subNamespace, catalogSource, catalogSourceNamespace, packageName) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil + } + + err := apiClient.AttachScheme(operatorsV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsV1alpha1 scheme to client schemes") + + return nil + } + + builder := &SubscriptionBuilder{ + apiClient: apiClient.Client, + Definition: &operatorsV1alpha1.Subscription{ + ObjectMeta: metav1.ObjectMeta{ + Name: subName, + Namespace: subNamespace, + }, + Spec: &operatorsV1alpha1.SubscriptionSpec{ + CatalogSource: catalogSource, + CatalogSourceNamespace: catalogSourceNamespace, + Package: packageName, + }, + }, + } + + if subName == "" { + glog.V(100).Infof("The Name of the Subscription is empty") + + builder.errorMsg = "subscription 'subName' cannot be empty" + + return builder + } + + if subNamespace == "" { + glog.V(100).Infof("The Namespace of the Subscription is empty") + + builder.errorMsg = "subscription 'subNamespace' cannot be empty" + + return builder + } + + if catalogSource == "" { + glog.V(100).Infof("The Catalogsource of the Subscription is empty") + + builder.errorMsg = "subscription 'catalogSource' cannot be empty" + + return builder + } + + if catalogSourceNamespace == "" { + glog.V(100).Infof("The Catalogsource namespace of the Subscription is empty") + + builder.errorMsg = "subscription 'catalogSourceNamespace' cannot be empty" + + return builder + } + + if packageName == "" { + glog.V(100).Infof("The Package name of the Subscription is empty") + + builder.errorMsg = "subscription 'packageName' cannot be empty" + + return builder + } + + return builder +} + +// WithChannel adds the specific channel to the Subscription. +func (builder *SubscriptionBuilder) WithChannel(channel string) *SubscriptionBuilder { + if valid, _ := builder.validate(); !valid { + return builder + } + + glog.V(100).Infof("Defining Subscription builder object with channel: %s", channel) + + if channel == "" { + builder.errorMsg = "can not redefine subscription with empty channel" + + return builder + } + + builder.Definition.Spec.Channel = channel + + return builder +} + +// WithStartingCSV adds the specific startingCSV to the Subscription. +func (builder *SubscriptionBuilder) WithStartingCSV(startingCSV string) *SubscriptionBuilder { + if valid, _ := builder.validate(); !valid { + return builder + } + + glog.V(100).Infof("Defining Subscription builder object with startingCSV: %s", + startingCSV) + + if startingCSV == "" { + builder.errorMsg = "can not redefine subscription with empty startingCSV" + + return builder + } + + builder.Definition.Spec.StartingCSV = startingCSV + + return builder +} + +// WithInstallPlanApproval adds the specific installPlanApproval to the Subscription. +func (builder *SubscriptionBuilder) WithInstallPlanApproval( + installPlanApproval operatorsV1alpha1.Approval) *SubscriptionBuilder { + if valid, _ := builder.validate(); !valid { + return builder + } + + glog.V(100).Infof("Defining Subscription builder object with "+ + "installPlanApproval: %s", installPlanApproval) + + if !(installPlanApproval == "Automatic" || installPlanApproval == "Manual") { + glog.V(100).Infof("The InstallPlanApproval of the Subscription must be either \"Automatic\" " + + "or \"Manual\"") + + builder.errorMsg = "Subscription 'installPlanApproval' must be either \"Automatic\" or \"Manual\"" + + return builder + } + + builder.Definition.Spec.InstallPlanApproval = installPlanApproval + + return builder +} + +// Get returns Subscription object if found. +func (builder *SubscriptionBuilder) Get() (*operatorsV1alpha1.Subscription, error) { + if valid, err := builder.validate(); !valid { + return nil, err + } + + glog.V(100).Infof( + "Collecting Subscription object %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + subscription := &operatorsV1alpha1.Subscription{} + err := builder.apiClient.Get(context.TODO(), + runtimeClient.ObjectKey{Name: builder.Definition.Name, Namespace: builder.Definition.Namespace}, + subscription) + + if err != nil { + glog.V(100).Infof( + "Subscription object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + return nil, err + } + + return subscription, nil +} + +// Create makes an Subscription in cluster and stores the created object in struct. +func (builder *SubscriptionBuilder) Create() (*SubscriptionBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Creating the Subscription %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if builder.Exists() { + return builder, nil + } + + err := builder.apiClient.Create(context.TODO(), builder.Definition) + if err != nil { + return builder, err + } + + builder.Object = builder.Definition + + return builder, nil +} + +// Exists checks whether the given Subscription exists. +func (builder *SubscriptionBuilder) Exists() bool { + if valid, _ := builder.validate(); !valid { + return false + } + + glog.V(100).Infof( + "Checking if Subscription %s exists", + builder.Definition.Name) + + var err error + builder.Object, err = builder.Get() + + return err == nil || !k8serrors.IsNotFound(err) +} + +// Delete removes a Subscription. +func (builder *SubscriptionBuilder) Delete() error { + if valid, err := builder.validate(); !valid { + return err + } + + glog.V(100).Infof("Deleting Subscription %s in namespace %s", builder.Definition.Name, + builder.Definition.Namespace) + + if !builder.Exists() { + glog.V(100).Infof("Subscription object %s does not exist in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + builder.Object = nil + + return nil + } + + err := builder.apiClient.Delete(context.TODO(), builder.Definition) + + if err != nil { + return err + } + + builder.Object = nil + + return nil +} + +// Update modifies the existing Subscription with the Subscription definition in SubscriptionBuilder. +func (builder *SubscriptionBuilder) Update() (*SubscriptionBuilder, error) { + if valid, err := builder.validate(); !valid { + return builder, err + } + + glog.V(100).Infof("Updating Subscription %s in namespace %s", + builder.Definition.Name, builder.Definition.Namespace) + + if !builder.Exists() { + return nil, fmt.Errorf("subscription named %s in namespace %s does not exist", + builder.Definition.Name, builder.Definition.Namespace) + } + + err := builder.apiClient.Update(context.TODO(), builder.Definition) + + if err == nil { + builder.Object = builder.Definition + } + + return builder, err +} + +// PullSubscription loads existing Subscription from cluster into the SubscriptionBuilder struct. +func PullSubscription(apiClient *clients.Settings, subName, subNamespace string) (*SubscriptionBuilder, error) { + glog.V(100).Infof("Pulling existing Subscription %s from cluster in namespace %s", + subName, subNamespace) + + if apiClient == nil { + glog.V(100).Infof("The apiClient cannot be nil") + + return nil, fmt.Errorf("subscription 'apiClient' cannot be empty") + } + + err := apiClient.AttachScheme(operatorsV1alpha1.AddToScheme) + if err != nil { + glog.V(100).Infof("Failed to add operatorsV1alpha1 scheme to client schemes") + + return nil, err + } + + builder := &SubscriptionBuilder{ + apiClient: apiClient.Client, + Definition: &operatorsV1alpha1.Subscription{ + ObjectMeta: metav1.ObjectMeta{ + Name: subName, + Namespace: subNamespace, + }, + }, + } + + if subName == "" { + glog.V(100).Infof("The name of the Subscription is empty") + + return nil, fmt.Errorf("subscription 'subName' cannot be empty") + } + + if subNamespace == "" { + glog.V(100).Infof("The namespace of the Subscription is empty") + + return nil, fmt.Errorf("subscription 'subNamespace' cannot be empty") + } + + if !builder.Exists() { + return nil, fmt.Errorf( + "subscription object named %s does not exist in namespace %s", subName, subNamespace) + } + + builder.Definition = builder.Object + + return builder, nil +} + +// validate will check that the builder and builder definition are properly initialized before +// accessing any member fields. +func (builder *SubscriptionBuilder) validate() (bool, error) { + resourceCRD := "Subscription" + + if builder == nil { + glog.V(100).Infof("The %s builder is uninitialized", resourceCRD) + + return false, fmt.Errorf("error: received nil %s builder", resourceCRD) + } + + if builder.Definition == nil { + glog.V(100).Infof("The %s is undefined", resourceCRD) + + return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD)) + } + + if builder.apiClient == nil { + glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD) + + return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD) + } + + if builder.errorMsg != "" { + glog.V(100).Infof("The %s builder has error message: %s", resourceCRD, builder.errorMsg) + + return false, fmt.Errorf(builder.errorMsg) + } + + return true, nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/doc.go new file mode 100644 index 000000000..7eba79448 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/doc.go @@ -0,0 +1,4 @@ +// +kubebuilder:skip + +// Package operators contains all resource types of the operators.coreos.com API group. +package operators diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/register.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/register.go new file mode 100644 index 000000000..e3c31d51a --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/register.go @@ -0,0 +1,31 @@ +package operators + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + // GroupName is the group name used in this package. + GroupName = "operators.coreos.com" + // GroupVersion is the group version used in this package. + GroupVersion = runtime.APIVersionInternal + + // LEGACY: Exported kind names, remove after major version bump + + // ClusterServiceVersionKind is the kind name for ClusterServiceVersion resources. + ClusterServiceVersionKind = "ClusterServiceVersion" + // CatalogSourceKind is the kind name for CatalogSource resources. + CatalogSourceKind = "CatalogSource" + // InstallPlanKind is the kind name for InstallPlan resources. + InstallPlanKind = "InstallPlan" + // SubscriptionKind is the kind name for Subscription resources. + SubscriptionKind = "Subscription" + // OperatorKind is the kind name for Operator resources. + OperatorKind = "Operator" + // OperatorGroupKind is the kind name for OperatorGroup resources. + OperatorGroupKind = "OperatorGroup" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/doc.go new file mode 100644 index 000000000..dec83277b --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/doc.go @@ -0,0 +1,4 @@ +// +groupName=operators.coreos.com + +// Package v1 contains resources types for version v1 of the operators.coreos.com API group. +package v1 diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/groupversion_info.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/groupversion_info.go new file mode 100644 index 000000000..089ec8783 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/groupversion_info.go @@ -0,0 +1,28 @@ +// +kubebuilder:object:generate=true + +// Package v1 contains API Schema definitions for the operator v1 API group. +package v1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v1"} + + // SchemeGroupVersion is required for compatibility with client generation. + SchemeGroupVersion = GroupVersion + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return GroupVersion.WithResource(resource).GroupResource() +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/olmconfig_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/olmconfig_types.go new file mode 100644 index 000000000..c15b5114f --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/olmconfig_types.go @@ -0,0 +1,90 @@ +package v1 + +import ( + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + DisabledCopiedCSVsConditionType = "DisabledCopiedCSVs" +) + +// OLMConfigSpec is the spec for an OLMConfig resource. +type OLMConfigSpec struct { + Features *Features `json:"features,omitempty"` +} + +// Features contains the list of configurable OLM features. +type Features struct { + + // DisableCopiedCSVs is used to disable OLM's "Copied CSV" feature + // for operators installed at the cluster scope, where a cluster + // scoped operator is one that has been installed in an + // OperatorGroup that targets all namespaces. + // When reenabled, OLM will recreate the "Copied CSVs" for each + // cluster scoped operator. + DisableCopiedCSVs *bool `json:"disableCopiedCSVs,omitempty"` + // PackageServerSyncInterval is used to define the sync interval for + // packagerserver pods. Packageserver pods periodically check the + // status of CatalogSources; this specifies the period using duration + // format (e.g. "60m"). For this parameter, only hours ("h"), minutes + // ("m"), and seconds ("s") may be specified. When not specified, the + // period defaults to the value specified within the packageserver. + // +optional + // +kubebuilder:validation:Type=string + // +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(s|m|h))+$" + PackageServerSyncInterval *metav1.Duration `json:"packageServerSyncInterval,omitempty"` +} + +// OLMConfigStatus is the status for an OLMConfig resource. +type OLMConfigStatus struct { + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced +// +kubebuilder:storageversion +// +kubebuilder:resource:categories=olm,scope=Cluster +// +kubebuilder:subresource:status + +// OLMConfig is a resource responsible for configuring OLM. +type OLMConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec OLMConfigSpec `json:"spec,omitempty"` + Status OLMConfigStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// OLMConfigList is a list of OLMConfig resources. +type OLMConfigList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + // +listType=set + Items []OLMConfig `json:"items"` +} + +func init() { + SchemeBuilder.Register(&OLMConfig{}, &OLMConfigList{}) +} + +// CopiedCSVsAreEnabled returns true if and only if the olmConfigs DisableCopiedCSVs is set and true, +// otherwise false is returned +func (config *OLMConfig) CopiedCSVsAreEnabled() bool { + if config == nil || config.Spec.Features == nil || config.Spec.Features.DisableCopiedCSVs == nil { + return true + } + + return !*config.Spec.Features.DisableCopiedCSVs +} + +func (config *OLMConfig) PackageServerSyncInterval() *time.Duration { + if config == nil || config.Spec.Features == nil || config.Spec.Features.PackageServerSyncInterval == nil { + return nil + } + return &config.Spec.Features.PackageServerSyncInterval.Duration +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operator_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operator_types.go new file mode 100644 index 000000000..af735950f --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operator_types.go @@ -0,0 +1,88 @@ +package v1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// OperatorSpec defines the desired state of Operator +type OperatorSpec struct{} + +// OperatorStatus defines the observed state of an Operator and its components +type OperatorStatus struct { + // Components describes resources that compose the operator. + // +optional + Components *Components `json:"components,omitempty"` +} + +// ConditionType codifies a condition's type. +type ConditionType string + +// Condition represent the latest available observations of an component's state. +type Condition struct { + // Type of condition. + Type ConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + // The reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty"` + // A human readable message indicating details about the transition. + // +optional + Message string `json:"message,omitempty"` + // Last time the condition was probed + // +optional + LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the condition transitioned from one status to another. + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` +} + +// Components tracks the resources that compose an operator. +type Components struct { + // LabelSelector is a label query over a set of resources used to select the operator's components + LabelSelector *metav1.LabelSelector `json:"labelSelector"` + // Refs are a set of references to the operator's component resources, selected with LabelSelector. + // +optional + Refs []RichReference `json:"refs,omitempty"` +} + +// RichReference is a reference to a resource, enriched with its status conditions. +type RichReference struct { + *corev1.ObjectReference `json:",inline"` + // Conditions represents the latest state of the component. + // +optional + // +patchMergeKey=type + // +patchStrategy=merge + Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` +} + +// +genclient +// +genclient:nonNamespaced +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:resource:categories=olm,scope=Cluster +// +kubebuilder:subresource:status + +// Operator represents a cluster operator. +type Operator struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec OperatorSpec `json:"spec,omitempty"` + Status OperatorStatus `json:"status,omitempty"` +} + +// +genclient:nonNamespaced +// +kubebuilder:object:root=true + +// OperatorList contains a list of Operators. +type OperatorList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Operator `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Operator{}, &OperatorList{}) +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorcondition_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorcondition_types.go new file mode 100644 index 000000000..8647b227e --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorcondition_types.go @@ -0,0 +1,49 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // Upgradeable indicates that the operator is upgradeable + Upgradeable string = "Upgradeable" +) + +// OperatorConditionSpec allows a cluster admin to convey information about the state of an operator to OLM, potentially overriding state reported by the operator. +type OperatorConditionSpec struct { + ServiceAccounts []string `json:"serviceAccounts,omitempty"` + Deployments []string `json:"deployments,omitempty"` + Overrides []metav1.Condition `json:"overrides,omitempty"` +} + +// OperatorConditionStatus allows an operator to convey information its state to OLM. The status may trail the actual +// state of a system. +type OperatorConditionStatus struct { + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +kubebuilder:resource:shortName=condition,categories=olm +// +kubebuilder:subresource:status +// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator. +type OperatorCondition struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec OperatorConditionSpec `json:"spec,omitempty"` + Status OperatorConditionStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// OperatorConditionList represents a list of Conditions. +type OperatorConditionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []OperatorCondition `json:"items"` +} + +func init() { + SchemeBuilder.Register(&OperatorCondition{}, &OperatorConditionList{}) +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorgroup_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorgroup_types.go new file mode 100644 index 000000000..81ad352d4 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/operatorgroup_types.go @@ -0,0 +1,214 @@ +package v1 + +import ( + "fmt" + "sort" + "strings" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + OperatorGroupAnnotationKey = "olm.operatorGroup" + OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" + OperatorGroupTargetsAnnotationKey = "olm.targetNamespaces" + OperatorGroupProvidedAPIsAnnotationKey = "olm.providedAPIs" + + OperatorGroupKind = "OperatorGroup" + + OperatorGroupLabelPrefix = "olm.operatorgroup.uid/" + OperatorGroupLabelTemplate = OperatorGroupLabelPrefix + "%s" + + OperatorGroupServiceAccountCondition = "OperatorGroupServiceAccount" + MutlipleOperatorGroupCondition = "MultipleOperatorGroup" + MultipleOperatorGroupsReason = "MultipleOperatorGroupsFound" + OperatorGroupServiceAccountReason = "ServiceAccountNotFound" + + // UpgradeStrategyDefault configures OLM such that it will only allow + // clusterServiceVersions to move to the replacing phase to the succeeded + // phase. This effectively means that OLM will not allow operators to move + // to the next version if an installation or upgrade has failed. + UpgradeStrategyDefault UpgradeStrategy = "Default" + + // UpgradeStrategyUnsafeFailForward configures OLM such that it will allow + // clusterServiceVersions to move to the replacing phase from the succeeded + // phase or from the failed phase. Additionally, OLM will generate new + // installPlans when a subscription references a failed installPlan and the + // catalog has been updated with a new upgrade for the existing set of + // operators. + // + // WARNING: The UpgradeStrategyUnsafeFailForward upgrade strategy is unsafe + // and may result in unexpected behavior or unrecoverable data loss unless + // you have deep understanding of the set of operators being managed in the + // namespace. + UpgradeStrategyUnsafeFailForward UpgradeStrategy = "TechPreviewUnsafeFailForward" +) + +type UpgradeStrategy string + +// OperatorGroupSpec is the spec for an OperatorGroup resource. +type OperatorGroupSpec struct { + // Selector selects the OperatorGroup's target namespaces. + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty"` + + // TargetNamespaces is an explicit set of namespaces to target. + // If it is set, Selector is ignored. + // +optional + // +listType=set + TargetNamespaces []string `json:"targetNamespaces,omitempty"` + + // ServiceAccountName is the admin specified service account which will be + // used to deploy operator(s) in this operator group. + ServiceAccountName string `json:"serviceAccountName,omitempty"` + + // Static tells OLM not to update the OperatorGroup's providedAPIs annotation + // +optional + StaticProvidedAPIs bool `json:"staticProvidedAPIs,omitempty"` + + // UpgradeStrategy defines the upgrade strategy for operators in the namespace. + // There are currently two supported upgrade strategies: + // + // Default: OLM will only allow clusterServiceVersions to move to the replacing + // phase from the succeeded phase. This effectively means that OLM will not + // allow operators to move to the next version if an installation or upgrade + // has failed. + // + // TechPreviewUnsafeFailForward: OLM will allow clusterServiceVersions to move to the + // replacing phase from the succeeded phase or from the failed phase. + // Additionally, OLM will generate new installPlans when a subscription references + // a failed installPlan and the catalog has been updated with a new upgrade for + // the existing set of operators. + // + // WARNING: The TechPreviewUnsafeFailForward upgrade strategy is unsafe and may result + // in unexpected behavior or unrecoverable data loss unless you have deep + // understanding of the set of operators being managed in the namespace. + // + // +kubebuilder:validation:Enum=Default;TechPreviewUnsafeFailForward + // +kubebuilder:default=Default + // +optional + UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy,omitempty"` +} + +// OperatorGroupStatus is the status for an OperatorGroupResource. +type OperatorGroupStatus struct { + // Namespaces is the set of target namespaces for the OperatorGroup. + // +listType=set + Namespaces []string `json:"namespaces,omitempty"` + + // ServiceAccountRef references the service account object specified. + ServiceAccountRef *corev1.ObjectReference `json:"serviceAccountRef,omitempty"` + + // LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated. + LastUpdated *metav1.Time `json:"lastUpdated"` + + // Conditions is an array of the OperatorGroup's conditions. + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +kubebuilder:storageversion +// +kubebuilder:resource:shortName=og,categories=olm +// +kubebuilder:subresource:status + +// OperatorGroup is the unit of multitenancy for OLM managed operators. +// It constrains the installation of operators in its namespace to a specified set of target namespaces. +type OperatorGroup struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + // +optional + // +kubebuilder:default={upgradeStrategy:Default} + Spec OperatorGroupSpec `json:"spec"` + Status OperatorGroupStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// OperatorGroupList is a list of OperatorGroup resources. +type OperatorGroupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + // +listType=set + Items []OperatorGroup `json:"items"` +} + +// BuildTargetNamespaces returns the set of target namespaces as a sorted, comma-delimited string +func (o *OperatorGroup) BuildTargetNamespaces() string { + ns := make([]string, len(o.Status.Namespaces)) + copy(ns, o.Status.Namespaces) + sort.Strings(ns) + return strings.Join(ns, ",") +} + +// UpgradeStrategy returns the UpgradeStrategy specified or the default value otherwise. +func (o *OperatorGroup) UpgradeStrategy() UpgradeStrategy { + strategyName := o.Spec.UpgradeStrategy + switch { + case strategyName == UpgradeStrategyUnsafeFailForward: + return strategyName + default: + return UpgradeStrategyDefault + } +} + +// IsServiceAccountSpecified returns true if the spec has a service account name specified. +func (o *OperatorGroup) IsServiceAccountSpecified() bool { + if o.Spec.ServiceAccountName == "" { + return false + } + + return true +} + +// HasServiceAccountSynced returns true if the service account specified has been synced. +func (o *OperatorGroup) HasServiceAccountSynced() bool { + if o.IsServiceAccountSpecified() && o.Status.ServiceAccountRef != nil { + return true + } + + return false +} + +// OGLabelKeyAndValue returns a key and value that should be applied to namespaces listed in the OperatorGroup. +// If the UID is not set an error is returned. +func (o *OperatorGroup) OGLabelKeyAndValue() (string, string, error) { + if string(o.GetUID()) == "" { + return "", "", fmt.Errorf("Missing UID") + } + return fmt.Sprintf(OperatorGroupLabelTemplate, o.GetUID()), "", nil +} + +// NamespaceLabelSelector provides a selector that can be used to filter namespaces that belong to the OperatorGroup. +func (o *OperatorGroup) NamespaceLabelSelector() (*metav1.LabelSelector, error) { + if len(o.Spec.TargetNamespaces) == 0 { + // If no target namespaces are set, check if a selector exists. + if o.Spec.Selector != nil { + return o.Spec.Selector, nil + } + // No selector exists, return nil which should be used to select EVERYTHING. + return nil, nil + } + // Return a label that should be present on all namespaces defined in the OperatorGroup.Spec.TargetNamespaces field. + ogKey, ogValue, err := o.OGLabelKeyAndValue() + if err != nil { + return nil, err + } + + return &metav1.LabelSelector{ + MatchLabels: map[string]string{ + ogKey: ogValue, + }, + }, nil +} + +// IsOperatorGroupLabel returns true if the label is an OperatorGroup label. +func IsOperatorGroupLabel(label string) bool { + return strings.HasPrefix(label, OperatorGroupLabelPrefix) +} + +func init() { + SchemeBuilder.Register(&OperatorGroup{}, &OperatorGroupList{}) +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/zz_generated.deepcopy.go new file mode 100644 index 000000000..d6f89ba40 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1/zz_generated.deepcopy.go @@ -0,0 +1,556 @@ +//go:build !ignore_autogenerated + +/* + +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 controller-gen. DO NOT EDIT. + +package v1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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 *Components) DeepCopyInto(out *Components) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.Refs != nil { + in, out := &in.Refs, &out.Refs + *out = make([]RichReference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Components. +func (in *Components) DeepCopy() *Components { + if in == nil { + return nil + } + out := new(Components) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Condition) DeepCopyInto(out *Condition) { + *out = *in + if in.LastUpdateTime != nil { + in, out := &in.LastUpdateTime, &out.LastUpdateTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. +func (in *Condition) DeepCopy() *Condition { + if in == nil { + return nil + } + out := new(Condition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Features) DeepCopyInto(out *Features) { + *out = *in + if in.DisableCopiedCSVs != nil { + in, out := &in.DisableCopiedCSVs, &out.DisableCopiedCSVs + *out = new(bool) + **out = **in + } + if in.PackageServerSyncInterval != nil { + in, out := &in.PackageServerSyncInterval, &out.PackageServerSyncInterval + *out = new(metav1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Features. +func (in *Features) DeepCopy() *Features { + if in == nil { + return nil + } + out := new(Features) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OLMConfig) DeepCopyInto(out *OLMConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfig. +func (in *OLMConfig) DeepCopy() *OLMConfig { + if in == nil { + return nil + } + out := new(OLMConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OLMConfig) 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 *OLMConfigList) DeepCopyInto(out *OLMConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OLMConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfigList. +func (in *OLMConfigList) DeepCopy() *OLMConfigList { + if in == nil { + return nil + } + out := new(OLMConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OLMConfigList) 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 *OLMConfigSpec) DeepCopyInto(out *OLMConfigSpec) { + *out = *in + if in.Features != nil { + in, out := &in.Features, &out.Features + *out = new(Features) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfigSpec. +func (in *OLMConfigSpec) DeepCopy() *OLMConfigSpec { + if in == nil { + return nil + } + out := new(OLMConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OLMConfigStatus) DeepCopyInto(out *OLMConfigStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OLMConfigStatus. +func (in *OLMConfigStatus) DeepCopy() *OLMConfigStatus { + if in == nil { + return nil + } + out := new(OLMConfigStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Operator) DeepCopyInto(out *Operator) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Operator. +func (in *Operator) DeepCopy() *Operator { + if in == nil { + return nil + } + out := new(Operator) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Operator) 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 *OperatorCondition) DeepCopyInto(out *OperatorCondition) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorCondition. +func (in *OperatorCondition) DeepCopy() *OperatorCondition { + if in == nil { + return nil + } + out := new(OperatorCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorCondition) 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 *OperatorConditionList) DeepCopyInto(out *OperatorConditionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OperatorCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionList. +func (in *OperatorConditionList) DeepCopy() *OperatorConditionList { + if in == nil { + return nil + } + out := new(OperatorConditionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorConditionList) 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 *OperatorConditionSpec) DeepCopyInto(out *OperatorConditionSpec) { + *out = *in + if in.ServiceAccounts != nil { + in, out := &in.ServiceAccounts, &out.ServiceAccounts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Deployments != nil { + in, out := &in.Deployments, &out.Deployments + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Overrides != nil { + in, out := &in.Overrides, &out.Overrides + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionSpec. +func (in *OperatorConditionSpec) DeepCopy() *OperatorConditionSpec { + if in == nil { + return nil + } + out := new(OperatorConditionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorConditionStatus) DeepCopyInto(out *OperatorConditionStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorConditionStatus. +func (in *OperatorConditionStatus) DeepCopy() *OperatorConditionStatus { + if in == nil { + return nil + } + out := new(OperatorConditionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroup) DeepCopyInto(out *OperatorGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroup. +func (in *OperatorGroup) DeepCopy() *OperatorGroup { + if in == nil { + return nil + } + out := new(OperatorGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorGroup) 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 *OperatorGroupList) DeepCopyInto(out *OperatorGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OperatorGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupList. +func (in *OperatorGroupList) DeepCopy() *OperatorGroupList { + if in == nil { + return nil + } + out := new(OperatorGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorGroupList) 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 *OperatorGroupSpec) DeepCopyInto(out *OperatorGroupSpec) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.TargetNamespaces != nil { + in, out := &in.TargetNamespaces, &out.TargetNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupSpec. +func (in *OperatorGroupSpec) DeepCopy() *OperatorGroupSpec { + if in == nil { + return nil + } + out := new(OperatorGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorGroupStatus) DeepCopyInto(out *OperatorGroupStatus) { + *out = *in + if in.Namespaces != nil { + in, out := &in.Namespaces, &out.Namespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ServiceAccountRef != nil { + in, out := &in.ServiceAccountRef, &out.ServiceAccountRef + *out = new(corev1.ObjectReference) + **out = **in + } + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorGroupStatus. +func (in *OperatorGroupStatus) DeepCopy() *OperatorGroupStatus { + if in == nil { + return nil + } + out := new(OperatorGroupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorList) DeepCopyInto(out *OperatorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Operator, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorList. +func (in *OperatorList) DeepCopy() *OperatorList { + if in == nil { + return nil + } + out := new(OperatorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OperatorList) 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 *OperatorSpec) DeepCopyInto(out *OperatorSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorSpec. +func (in *OperatorSpec) DeepCopy() *OperatorSpec { + if in == nil { + return nil + } + out := new(OperatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorStatus) DeepCopyInto(out *OperatorStatus) { + *out = *in + if in.Components != nil { + in, out := &in.Components, &out.Components + *out = new(Components) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorStatus. +func (in *OperatorStatus) DeepCopy() *OperatorStatus { + if in == nil { + return nil + } + out := new(OperatorStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RichReference) DeepCopyInto(out *RichReference) { + *out = *in + if in.ObjectReference != nil { + in, out := &in.ObjectReference, &out.ObjectReference + *out = new(corev1.ObjectReference) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RichReference. +func (in *RichReference) DeepCopy() *RichReference { + if in == nil { + return nil + } + out := new(RichReference) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/catalogsource_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/catalogsource_types.go new file mode 100644 index 000000000..b5f5e3b7e --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/catalogsource_types.go @@ -0,0 +1,364 @@ +package v1alpha1 + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/sirupsen/logrus" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +const ( + CatalogSourceCRDAPIVersion = GroupName + "/" + GroupVersion + CatalogSourceKind = "CatalogSource" + DefaultRegistryPollDuration = 15 * time.Minute +) + +// SourceType indicates the type of backing store for a CatalogSource +type SourceType string + +const ( + // SourceTypeInternal (deprecated) specifies a CatalogSource of type SourceTypeConfigmap + SourceTypeInternal SourceType = "internal" + + // SourceTypeConfigmap specifies a CatalogSource that generates a configmap-server registry + SourceTypeConfigmap SourceType = "configmap" + + // SourceTypeGrpc specifies a CatalogSource that can use an operator registry image to generate a + // registry-server or connect to a pre-existing registry at an address. + SourceTypeGrpc SourceType = "grpc" +) + +const ( + // CatalogSourceSpecInvalidError denotes when fields on the spec of the CatalogSource are not valid. + CatalogSourceSpecInvalidError ConditionReason = "SpecInvalidError" + // CatalogSourceConfigMapError denotes when there is an issue extracting manifests from the specified ConfigMap. + CatalogSourceConfigMapError ConditionReason = "ConfigMapError" + // CatalogSourceRegistryServerError denotes when there is an issue querying the specified registry server. + CatalogSourceRegistryServerError ConditionReason = "RegistryServerError" + // CatalogSourceIntervalInvalidError denotes if the registry polling interval is invalid. + CatalogSourceIntervalInvalidError ConditionReason = "InvalidIntervalError" +) + +type CatalogSourceSpec struct { + // SourceType is the type of source + SourceType SourceType `json:"sourceType"` + + // Priority field assigns a weight to the catalog source to prioritize them so that it can be consumed by the dependency resolver. + // Usage: + // Higher weight indicates that this catalog source is preferred over lower weighted catalog sources during dependency resolution. + // The range of the priority value can go from positive to negative in the range of int32. + // The default value to a catalog source with unassigned priority would be 0. + // The catalog source with the same priority values will be ranked lexicographically based on its name. + // +optional + Priority int `json:"priority,omitempty"` + + // ConfigMap is the name of the ConfigMap to be used to back a configmap-server registry. + // Only used when SourceType = SourceTypeConfigmap or SourceTypeInternal. + // +optional + ConfigMap string `json:"configMap,omitempty"` + + // Address is a host that OLM can use to connect to a pre-existing registry. + // Format: : + // Only used when SourceType = SourceTypeGrpc. + // Ignored when the Image field is set. + // +optional + Address string `json:"address,omitempty"` + + // Image is an operator-registry container image to instantiate a registry-server with. + // Only used when SourceType = SourceTypeGrpc. + // If present, the address field is ignored. + // +optional + Image string `json:"image,omitempty"` + + // GrpcPodConfig exposes different overrides for the pod spec of the CatalogSource Pod. + // Only used when SourceType = SourceTypeGrpc and Image is set. + // +optional + GrpcPodConfig *GrpcPodConfig `json:"grpcPodConfig,omitempty"` + + // UpdateStrategy defines how updated catalog source images can be discovered + // Consists of an interval that defines polling duration and an embedded strategy type + // +optional + UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"` + + // Secrets represent set of secrets that can be used to access the contents of the catalog. + // It is best to keep this list small, since each will need to be tried for every catalog entry. + // +optional + Secrets []string `json:"secrets,omitempty"` + + // Metadata + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + Publisher string `json:"publisher,omitempty"` + Icon Icon `json:"icon,omitempty"` +} + +type SecurityConfig string + +const ( + Legacy SecurityConfig = "legacy" + Restricted SecurityConfig = "restricted" +) + +// GrpcPodConfig contains configuration specified for a catalog source +type GrpcPodConfig struct { + // NodeSelector is a selector which must be true for the pod to fit on a node. + // Selector which must match a node's labels for the pod to be scheduled on that node. + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + + // Tolerations are the catalog source's pod's tolerations. + // +optional + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + + // Affinity is the catalog source's pod's affinity. + // +optional + Affinity *corev1.Affinity `json:"affinity,omitempty"` + + // If specified, indicates the pod's priority. + // If not specified, the pod priority will be default or zero if there is no + // default. + // +optional + PriorityClassName *string `json:"priorityClassName,omitempty"` + + // SecurityContextConfig can be one of `legacy` or `restricted`. The CatalogSource's pod is either injected with the + // right pod.spec.securityContext and pod.spec.container[*].securityContext values to allow the pod to run in Pod + // Security Admission (PSA) `restricted` mode, or doesn't set these values at all, in which case the pod can only be + // run in PSA `baseline` or `privileged` namespaces. If the SecurityContextConfig is unspecified, the mode will be + // determined by the namespace's PSA configuration. If the namespace is enforcing `restricted` mode, then the pod + // will be configured as if `restricted` was specified. Otherwise, it will be configured as if `legacy` was + // specified. Specifying a value other than `legacy` or `restricted` result in a validation error. When using older + // catalog images, which can not run in `restricted` mode, the SecurityContextConfig should be set to `legacy`. + // + // More information about PSA can be found here: https://kubernetes.io/docs/concepts/security/pod-security-admission/' + // +optional + // +kubebuilder:validation:Enum=legacy;restricted + SecurityContextConfig SecurityConfig `json:"securityContextConfig,omitempty"` + + // MemoryTarget configures the $GOMEMLIMIT value for the gRPC catalog Pod. This is a soft memory limit for the server, + // which the runtime will attempt to meet but makes no guarantees that it will do so. If this value is set, the Pod + // will have the following modifications made to the container running the server: + // - the $GOMEMLIMIT environment variable will be set to this value in bytes + // - the memory request will be set to this value + // + // This field should be set if it's desired to reduce the footprint of a catalog server as much as possible, or if + // a catalog being served is very large and needs more than the default allocation. If your index image has a file- + // system cache, determine a good approximation for this value by doubling the size of the package cache at + // /tmp/cache/cache/packages.json in the index image. + // + // This field is best-effort; if unset, no default will be used and no Pod memory limit or $GOMEMLIMIT value will be set. + // +optional + MemoryTarget *resource.Quantity `json:"memoryTarget,omitempty"` + + // ExtractContent configures the gRPC catalog Pod to extract catalog metadata from the provided index image and + // use a well-known version of the `opm` server to expose it. The catalog index image that this CatalogSource is + // configured to use *must* be using the file-based catalogs in order to utilize this feature. + // +optional + ExtractContent *ExtractContentConfig `json:"extractContent,omitempty"` +} + +// ExtractContentConfig configures context extraction from a file-based catalog index image. +type ExtractContentConfig struct { + // CacheDir is the directory storing the pre-calculated API cache. + CacheDir string `json:"cacheDir"` + // CatalogDir is the directory storing the file-based catalog contents. + CatalogDir string `json:"catalogDir"` +} + +// UpdateStrategy holds all the different types of catalog source update strategies +// Currently only registry polling strategy is implemented +type UpdateStrategy struct { + *RegistryPoll `json:"registryPoll,omitempty"` +} + +type RegistryPoll struct { + // Interval is used to determine the time interval between checks of the latest catalog source version. + // The catalog operator polls to see if a new version of the catalog source is available. + // If available, the latest image is pulled and gRPC traffic is directed to the latest catalog source. + RawInterval string `json:"interval,omitempty"` + Interval *metav1.Duration `json:"-"` + ParsingError string `json:"-"` +} + +// UnmarshalJSON implements the encoding/json.Unmarshaler interface. +func (u *UpdateStrategy) UnmarshalJSON(data []byte) (err error) { + type alias struct { + *RegistryPoll `json:"registryPoll,omitempty"` + } + us := alias{} + if err = json.Unmarshal(data, &us); err != nil { + return err + } + registryPoll := &RegistryPoll{ + RawInterval: us.RegistryPoll.RawInterval, + } + duration, err := time.ParseDuration(registryPoll.RawInterval) + if err != nil { + registryPoll.ParsingError = fmt.Sprintf("error parsing spec.updateStrategy.registryPoll.interval. Using the default value of %s instead. Error: %s", DefaultRegistryPollDuration, err) + registryPoll.Interval = &metav1.Duration{Duration: DefaultRegistryPollDuration} + } else { + registryPoll.Interval = &metav1.Duration{Duration: duration} + } + u.RegistryPoll = registryPoll + return nil +} + +type RegistryServiceStatus struct { + Protocol string `json:"protocol,omitempty"` + ServiceName string `json:"serviceName,omitempty"` + ServiceNamespace string `json:"serviceNamespace,omitempty"` + Port string `json:"port,omitempty"` + CreatedAt metav1.Time `json:"createdAt,omitempty"` +} + +func (s *RegistryServiceStatus) Address() string { + return fmt.Sprintf("%s.%s.svc:%s", s.ServiceName, s.ServiceNamespace, s.Port) +} + +type GRPCConnectionState struct { + Address string `json:"address,omitempty"` + LastObservedState string `json:"lastObservedState"` + LastConnectTime metav1.Time `json:"lastConnect,omitempty"` +} + +type CatalogSourceStatus struct { + // A human readable message indicating details about why the CatalogSource is in this condition. + // +optional + Message string `json:"message,omitempty"` + // Reason is the reason the CatalogSource was transitioned to its current state. + // +optional + Reason ConditionReason `json:"reason,omitempty"` + + // The last time the CatalogSource image registry has been polled to ensure the image is up-to-date + LatestImageRegistryPoll *metav1.Time `json:"latestImageRegistryPoll,omitempty"` + + // ConfigMapReference (deprecated) is the reference to the ConfigMap containing the catalog source's configuration, when the catalog source is a ConfigMap + ConfigMapResource *ConfigMapResourceReference `json:"configMapReference,omitempty"` + // RegistryService represents the current state of the GRPC service used to serve the catalog + RegistryServiceStatus *RegistryServiceStatus `json:"registryService,omitempty"` + // ConnectionState represents the current state of the CatalogSource's connection to the registry + GRPCConnectionState *GRPCConnectionState `json:"connectionState,omitempty"` + + // Represents the state of a CatalogSource. Note that Message and Reason represent the original + // status information, which may be migrated to be conditions based in the future. Any new features + // introduced will use conditions. + // +optional + // +patchMergeKey=type + // +patchStrategy=merge + // +listType=map + // +listMapKey=type + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` +} + +type ConfigMapResourceReference struct { + Name string `json:"name"` + Namespace string `json:"namespace"` + UID types.UID `json:"uid,omitempty"` + ResourceVersion string `json:"resourceVersion,omitempty"` + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` +} + +func (r *ConfigMapResourceReference) IsAMatch(object *metav1.ObjectMeta) bool { + return r.UID == object.GetUID() && r.ResourceVersion == object.GetResourceVersion() +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +kubebuilder:resource:shortName=catsrc,categories=olm +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Display",type=string,JSONPath=`.spec.displayName`,description="The pretty name of the catalog" +// +kubebuilder:printcolumn:name="Type",type=string,JSONPath=`.spec.sourceType`,description="The type of the catalog" +// +kubebuilder:printcolumn:name="Publisher",type=string,JSONPath=`.spec.publisher`,description="The publisher of the catalog" +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` + +// CatalogSource is a repository of CSVs, CRDs, and operator packages. +type CatalogSource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec CatalogSourceSpec `json:"spec"` + // +optional + Status CatalogSourceStatus `json:"status"` +} + +func (c *CatalogSource) Address() string { + if c.Spec.Address != "" { + return c.Spec.Address + } + return c.Status.RegistryServiceStatus.Address() +} + +func (c *CatalogSource) SetError(reason ConditionReason, err error) { + c.Status.Reason = reason + c.Status.Message = "" + if err != nil { + c.Status.Message = err.Error() + } +} + +func (c *CatalogSource) SetLastUpdateTime() { + now := metav1.Now() + c.Status.LatestImageRegistryPoll = &now +} + +// Check if it is time to update based on polling setting +func (c *CatalogSource) Update() bool { + if !c.Poll() { + return false + } + interval := c.Spec.UpdateStrategy.Interval.Duration + latest := c.Status.LatestImageRegistryPoll + if latest == nil { + logrus.WithField("CatalogSource", c.Name).Debugf("latest poll %v", latest) + } else { + logrus.WithField("CatalogSource", c.Name).Debugf("latest poll %v", *c.Status.LatestImageRegistryPoll) + } + + if c.Status.LatestImageRegistryPoll.IsZero() { + logrus.WithField("CatalogSource", c.Name).Debugf("creation timestamp plus interval before now %t", c.CreationTimestamp.Add(interval).Before(time.Now())) + if c.CreationTimestamp.Add(interval).Before(time.Now()) { + return true + } + } else { + logrus.WithField("CatalogSource", c.Name).Debugf("latest poll plus interval before now %t", c.Status.LatestImageRegistryPoll.Add(interval).Before(time.Now())) + if c.Status.LatestImageRegistryPoll.Add(interval).Before(time.Now()) { + return true + } + } + + return false +} + +// Poll determines whether the polling feature is enabled on the particular catalog source +func (c *CatalogSource) Poll() bool { + if c.Spec.UpdateStrategy == nil { + return false + } + // if polling interval is zero polling will not be done + if c.Spec.UpdateStrategy.RegistryPoll == nil { + return false + } + // if catalog source is not backed by an image polling will not be done + if c.Spec.Image == "" { + return false + } + // if image is not type gRPC polling will not be done + if c.Spec.SourceType != SourceTypeGrpc { + return false + } + return true +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CatalogSourceList is a repository of CSVs, CRDs, and operator packages. +type CatalogSourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []CatalogSource `json:"items"` +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion.go new file mode 100644 index 000000000..a4c8d1746 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion.go @@ -0,0 +1,215 @@ +package v1alpha1 + +import ( + "fmt" + + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/record" +) + +const ( + CopiedLabelKey = "olm.copiedFrom" + + // ConditionsLengthLimit is the maximum length of Status.Conditions of a + // given ClusterServiceVersion object. The oldest condition(s) are removed + // from the list as it grows over time to keep it at limit. + ConditionsLengthLimit = 20 +) + +// obsoleteReasons are the set of reasons that mean a CSV should no longer be processed as active +var obsoleteReasons = map[ConditionReason]struct{}{ + CSVReasonReplaced: {}, + CSVReasonBeingReplaced: {}, +} + +// uncopiableReasons are the set of reasons that should prevent a CSV from being copied to target namespaces +var uncopiableReasons = map[ConditionReason]struct{}{ + CSVReasonCopied: {}, + CSVReasonInvalidInstallModes: {}, + CSVReasonNoTargetNamespaces: {}, + CSVReasonUnsupportedOperatorGroup: {}, + CSVReasonNoOperatorGroup: {}, + CSVReasonTooManyOperatorGroups: {}, + CSVReasonInterOperatorGroupOwnerConflict: {}, + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs: {}, +} + +// safeToAnnotateOperatorGroupReasons are the set of reasons that it's safe to attempt to update the operatorgroup +// annotations +var safeToAnnotateOperatorGroupReasons = map[ConditionReason]struct{}{ + CSVReasonOwnerConflict: {}, + CSVReasonInstallSuccessful: {}, + CSVReasonInvalidInstallModes: {}, + CSVReasonNoTargetNamespaces: {}, + CSVReasonUnsupportedOperatorGroup: {}, + CSVReasonNoOperatorGroup: {}, + CSVReasonTooManyOperatorGroups: {}, + CSVReasonInterOperatorGroupOwnerConflict: {}, + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs: {}, +} + +// SetPhaseWithEventIfChanged emits a Kubernetes event with details of a phase change and sets the current phase if phase, reason, or message would changed +func (c *ClusterServiceVersion) SetPhaseWithEventIfChanged(phase ClusterServiceVersionPhase, reason ConditionReason, message string, now *metav1.Time, recorder record.EventRecorder) { + if c.Status.Phase == phase && c.Status.Reason == reason && c.Status.Message == message { + return + } + + c.SetPhaseWithEvent(phase, reason, message, now, recorder) +} + +// SetPhaseWithEvent generates a Kubernetes event with details about the phase change and sets the current phase +func (c *ClusterServiceVersion) SetPhaseWithEvent(phase ClusterServiceVersionPhase, reason ConditionReason, message string, now *metav1.Time, recorder record.EventRecorder) { + var eventtype string + if phase == CSVPhaseFailed { + eventtype = v1.EventTypeWarning + } else { + eventtype = v1.EventTypeNormal + } + go recorder.Event(c, eventtype, string(reason), message) + c.SetPhase(phase, reason, message, now) +} + +// SetPhase sets the current phase and adds a condition if necessary +func (c *ClusterServiceVersion) SetPhase(phase ClusterServiceVersionPhase, reason ConditionReason, message string, now *metav1.Time) { + newCondition := func() ClusterServiceVersionCondition { + return ClusterServiceVersionCondition{ + Phase: c.Status.Phase, + LastTransitionTime: c.Status.LastTransitionTime, + LastUpdateTime: c.Status.LastUpdateTime, + Message: message, + Reason: reason, + } + } + + defer c.TrimConditionsIfLimitExceeded() + + c.Status.LastUpdateTime = now + if c.Status.Phase != phase { + c.Status.Phase = phase + c.Status.LastTransitionTime = now + } + c.Status.Message = message + c.Status.Reason = reason + if len(c.Status.Conditions) == 0 { + c.Status.Conditions = append(c.Status.Conditions, newCondition()) + return + } + + previousCondition := c.Status.Conditions[len(c.Status.Conditions)-1] + if previousCondition.Phase != c.Status.Phase || previousCondition.Reason != c.Status.Reason { + c.Status.Conditions = append(c.Status.Conditions, newCondition()) + } +} + +// SetRequirementStatus adds the status of all requirements to the CSV status +func (c *ClusterServiceVersion) SetRequirementStatus(statuses []RequirementStatus) { + c.Status.RequirementStatus = statuses +} + +// IsObsolete returns if this CSV is being replaced or is marked for deletion +func (c *ClusterServiceVersion) IsObsolete() bool { + for _, condition := range c.Status.Conditions { + _, ok := obsoleteReasons[condition.Reason] + if ok { + return true + } + } + return false +} + +// IsCopied returns true if the CSV has been copied and false otherwise. +func (c *ClusterServiceVersion) IsCopied() bool { + return c.Status.Reason == CSVReasonCopied || IsCopied(c) +} + +func IsCopied(o metav1.Object) bool { + annotations := o.GetAnnotations() + if annotations != nil { + operatorNamespace, ok := annotations[OperatorGroupNamespaceAnnotationKey] + if ok && o.GetNamespace() != operatorNamespace { + return true + } + } + + if labels := o.GetLabels(); labels != nil { + if _, ok := labels[CopiedLabelKey]; ok { + return true + } + } + return false +} + +func (c *ClusterServiceVersion) IsUncopiable() bool { + if c.Status.Phase == CSVPhaseNone { + return true + } + _, ok := uncopiableReasons[c.Status.Reason] + return ok +} + +func (c *ClusterServiceVersion) IsSafeToUpdateOperatorGroupAnnotations() bool { + _, ok := safeToAnnotateOperatorGroupReasons[c.Status.Reason] + return ok +} + +// NewInstallModeSet returns an InstallModeSet instantiated from the given list of InstallModes. +// If the given list is not a set, an error is returned. +func NewInstallModeSet(modes []InstallMode) (InstallModeSet, error) { + set := InstallModeSet{} + for _, mode := range modes { + if _, exists := set[mode.Type]; exists { + return nil, fmt.Errorf("InstallMode list contains duplicates, cannot make set: %v", modes) + } + set[mode.Type] = mode.Supported + } + + return set, nil +} + +// Supports returns an error if the InstallModeSet does not support configuration for +// the given operatorNamespace and list of target namespaces. +func (set InstallModeSet) Supports(operatorNamespace string, namespaces []string) error { + numNamespaces := len(namespaces) + switch { + case numNamespaces == 0: + return fmt.Errorf("operatorgroup has invalid selected namespaces, cannot configure to watch zero namespaces") + case numNamespaces == 1: + switch namespaces[0] { + case operatorNamespace: + if !set[InstallModeTypeOwnNamespace] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch own namespace", InstallModeTypeOwnNamespace) + } + case v1.NamespaceAll: + if !set[InstallModeTypeAllNamespaces] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch all namespaces", InstallModeTypeAllNamespaces) + } + default: + if !set[InstallModeTypeSingleNamespace] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch one namespace", InstallModeTypeSingleNamespace) + } + } + case numNamespaces > 1 && !set[InstallModeTypeMultiNamespace]: + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch %d namespaces", InstallModeTypeMultiNamespace, numNamespaces) + case numNamespaces > 1: + for _, namespace := range namespaces { + if namespace == operatorNamespace && !set[InstallModeTypeOwnNamespace] { + return fmt.Errorf("%s InstallModeType not supported, cannot configure to watch own namespace", InstallModeTypeOwnNamespace) + } + if namespace == v1.NamespaceAll { + return fmt.Errorf("operatorgroup has invalid selected namespaces, NamespaceAll found when |selected namespaces| > 1") + } + } + } + + return nil +} + +func (c *ClusterServiceVersion) TrimConditionsIfLimitExceeded() { + if len(c.Status.Conditions) <= ConditionsLengthLimit { + return + } + + firstIndex := len(c.Status.Conditions) - ConditionsLengthLimit + c.Status.Conditions = c.Status.Conditions[firstIndex:len(c.Status.Conditions)] +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion_types.go new file mode 100644 index 000000000..04c8c90c2 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/clusterserviceversion_types.go @@ -0,0 +1,737 @@ +package v1alpha1 + +import ( + "encoding/json" + "fmt" + "sort" + "strings" + + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + appsv1 "k8s.io/api/apps/v1" + rbac "k8s.io/api/rbac/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/util/intstr" + + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version" +) + +const ( + ClusterServiceVersionAPIVersion = GroupName + "/" + GroupVersion + ClusterServiceVersionKind = "ClusterServiceVersion" + OperatorGroupNamespaceAnnotationKey = "olm.operatorNamespace" + InstallStrategyNameDeployment = "deployment" + SkipRangeAnnotationKey = "olm.skipRange" +) + +// InstallModeType is a supported type of install mode for CSV installation +type InstallModeType string + +const ( + // InstallModeTypeOwnNamespace indicates that the operator can be a member of an `OperatorGroup` that selects its own namespace. + InstallModeTypeOwnNamespace InstallModeType = "OwnNamespace" + // InstallModeTypeSingleNamespace indicates that the operator can be a member of an `OperatorGroup` that selects one namespace. + InstallModeTypeSingleNamespace InstallModeType = "SingleNamespace" + // InstallModeTypeMultiNamespace indicates that the operator can be a member of an `OperatorGroup` that selects more than one namespace. + InstallModeTypeMultiNamespace InstallModeType = "MultiNamespace" + // InstallModeTypeAllNamespaces indicates that the operator can be a member of an `OperatorGroup` that selects all namespaces (target namespace set is the empty string ""). + InstallModeTypeAllNamespaces InstallModeType = "AllNamespaces" +) + +// InstallMode associates an InstallModeType with a flag representing if the CSV supports it +// +k8s:openapi-gen=true +type InstallMode struct { + Type InstallModeType `json:"type"` + Supported bool `json:"supported"` +} + +// InstallModeSet is a mapping of unique InstallModeTypes to whether they are supported. +type InstallModeSet map[InstallModeType]bool + +// NamedInstallStrategy represents the block of an ClusterServiceVersion resource +// where the install strategy is specified. +// +k8s:openapi-gen=true +type NamedInstallStrategy struct { + StrategyName string `json:"strategy"` + StrategySpec StrategyDetailsDeployment `json:"spec,omitempty"` +} + +// StrategyDeploymentPermissions describe the rbac rules and service account needed by the install strategy +// +k8s:openapi-gen=true +type StrategyDeploymentPermissions struct { + ServiceAccountName string `json:"serviceAccountName"` + Rules []rbac.PolicyRule `json:"rules"` +} + +// StrategyDeploymentSpec contains the name, spec and labels for the deployment ALM should create +// +k8s:openapi-gen=true +type StrategyDeploymentSpec struct { + Name string `json:"name"` + Spec appsv1.DeploymentSpec `json:"spec"` + Label labels.Set `json:"label,omitempty"` +} + +// StrategyDetailsDeployment represents the parsed details of a Deployment +// InstallStrategy. +// +k8s:openapi-gen=true +type StrategyDetailsDeployment struct { + DeploymentSpecs []StrategyDeploymentSpec `json:"deployments"` + Permissions []StrategyDeploymentPermissions `json:"permissions,omitempty"` + ClusterPermissions []StrategyDeploymentPermissions `json:"clusterPermissions,omitempty"` +} + +func (d *StrategyDetailsDeployment) GetStrategyName() string { + return InstallStrategyNameDeployment +} + +// StatusDescriptor describes a field in a status block of a CRD so that OLM can consume it +// +k8s:openapi-gen=true +type StatusDescriptor struct { + Path string `json:"path"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + XDescriptors []string `json:"x-descriptors,omitempty"` + Value json.RawMessage `json:"value,omitempty"` +} + +// SpecDescriptor describes a field in a spec block of a CRD so that OLM can consume it +// +k8s:openapi-gen=true +type SpecDescriptor struct { + Path string `json:"path"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + XDescriptors []string `json:"x-descriptors,omitempty"` + Value json.RawMessage `json:"value,omitempty"` +} + +// ActionDescriptor describes a declarative action that can be performed on a custom resource instance +// +k8s:openapi-gen=true +type ActionDescriptor struct { + Path string `json:"path"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + XDescriptors []string `json:"x-descriptors,omitempty"` + Value json.RawMessage `json:"value,omitempty"` +} + +// CRDDescription provides details to OLM about the CRDs +// +k8s:openapi-gen=true +type CRDDescription struct { + Name string `json:"name"` + Version string `json:"version"` + Kind string `json:"kind"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + Resources []APIResourceReference `json:"resources,omitempty"` + StatusDescriptors []StatusDescriptor `json:"statusDescriptors,omitempty"` + SpecDescriptors []SpecDescriptor `json:"specDescriptors,omitempty"` + ActionDescriptor []ActionDescriptor `json:"actionDescriptors,omitempty"` +} + +// APIServiceDescription provides details to OLM about apis provided via aggregation +// +k8s:openapi-gen=true +type APIServiceDescription struct { + Name string `json:"name"` + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + DeploymentName string `json:"deploymentName,omitempty"` + ContainerPort int32 `json:"containerPort,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Description string `json:"description,omitempty"` + Resources []APIResourceReference `json:"resources,omitempty"` + StatusDescriptors []StatusDescriptor `json:"statusDescriptors,omitempty"` + SpecDescriptors []SpecDescriptor `json:"specDescriptors,omitempty"` + ActionDescriptor []ActionDescriptor `json:"actionDescriptors,omitempty"` +} + +// APIResourceReference is a reference to a Kubernetes resource type that the referrer utilizes. +// +k8s:openapi-gen=true +type APIResourceReference struct { + // Plural name of the referenced resource type (CustomResourceDefinition.Spec.Names[].Plural). Empty string if the referenced resource type is not a custom resource. + Name string `json:"name"` + // Kind of the referenced resource type. + Kind string `json:"kind"` + // API Version of the referenced resource type. + Version string `json:"version"` +} + +// GetName returns the name of an APIService as derived from its group and version. +func (d APIServiceDescription) GetName() string { + return fmt.Sprintf("%s.%s", d.Version, d.Group) +} + +// WebhookAdmissionType is the type of admission webhooks supported by OLM +type WebhookAdmissionType string + +const ( + // ValidatingAdmissionWebhook is for validating admission webhooks + ValidatingAdmissionWebhook WebhookAdmissionType = "ValidatingAdmissionWebhook" + // MutatingAdmissionWebhook is for mutating admission webhooks + MutatingAdmissionWebhook WebhookAdmissionType = "MutatingAdmissionWebhook" + // ConversionWebhook is for conversion webhooks + ConversionWebhook WebhookAdmissionType = "ConversionWebhook" +) + +// WebhookDescription provides details to OLM about required webhooks +// +k8s:openapi-gen=true +type WebhookDescription struct { + GenerateName string `json:"generateName"` + // +kubebuilder:validation:Enum=ValidatingAdmissionWebhook;MutatingAdmissionWebhook;ConversionWebhook + Type WebhookAdmissionType `json:"type"` + DeploymentName string `json:"deploymentName,omitempty"` + // +kubebuilder:validation:Maximum=65535 + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:default=443 + ContainerPort int32 `json:"containerPort,omitempty"` + TargetPort *intstr.IntOrString `json:"targetPort,omitempty"` + Rules []admissionregistrationv1.RuleWithOperations `json:"rules,omitempty"` + FailurePolicy *admissionregistrationv1.FailurePolicyType `json:"failurePolicy,omitempty"` + MatchPolicy *admissionregistrationv1.MatchPolicyType `json:"matchPolicy,omitempty"` + ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty"` + SideEffects *admissionregistrationv1.SideEffectClass `json:"sideEffects"` + TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` + AdmissionReviewVersions []string `json:"admissionReviewVersions"` + ReinvocationPolicy *admissionregistrationv1.ReinvocationPolicyType `json:"reinvocationPolicy,omitempty"` + WebhookPath *string `json:"webhookPath,omitempty"` + ConversionCRDs []string `json:"conversionCRDs,omitempty"` +} + +// GetValidatingWebhook returns a ValidatingWebhook generated from the WebhookDescription +func (w *WebhookDescription) GetValidatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.ValidatingWebhook { + return admissionregistrationv1.ValidatingWebhook{ + Name: w.GenerateName, + Rules: w.Rules, + FailurePolicy: w.FailurePolicy, + MatchPolicy: w.MatchPolicy, + NamespaceSelector: namespaceSelector, + ObjectSelector: w.ObjectSelector, + SideEffects: w.SideEffects, + TimeoutSeconds: w.TimeoutSeconds, + AdmissionReviewVersions: w.AdmissionReviewVersions, + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ + Name: w.DomainName() + "-service", + Namespace: namespace, + Path: w.WebhookPath, + Port: &w.ContainerPort, + }, + CABundle: caBundle, + }, + } +} + +// GetMutatingWebhook returns a MutatingWebhook generated from the WebhookDescription +func (w *WebhookDescription) GetMutatingWebhook(namespace string, namespaceSelector *metav1.LabelSelector, caBundle []byte) admissionregistrationv1.MutatingWebhook { + return admissionregistrationv1.MutatingWebhook{ + Name: w.GenerateName, + Rules: w.Rules, + FailurePolicy: w.FailurePolicy, + MatchPolicy: w.MatchPolicy, + NamespaceSelector: namespaceSelector, + ObjectSelector: w.ObjectSelector, + SideEffects: w.SideEffects, + TimeoutSeconds: w.TimeoutSeconds, + AdmissionReviewVersions: w.AdmissionReviewVersions, + ClientConfig: admissionregistrationv1.WebhookClientConfig{ + Service: &admissionregistrationv1.ServiceReference{ + Name: w.DomainName() + "-service", + Namespace: namespace, + Path: w.WebhookPath, + Port: &w.ContainerPort, + }, + CABundle: caBundle, + }, + ReinvocationPolicy: w.ReinvocationPolicy, + } +} + +// DomainName returns the result of replacing all periods in the given Webhook name with hyphens +func (w *WebhookDescription) DomainName() string { + // Replace all '.'s with "-"s to convert to a DNS-1035 label + return strings.Replace(w.DeploymentName, ".", "-", -1) +} + +// CustomResourceDefinitions declares all of the CRDs managed or required by +// an operator being ran by ClusterServiceVersion. +// +// If the CRD is present in the Owned list, it is implicitly required. +// +k8s:openapi-gen=true +type CustomResourceDefinitions struct { + Owned []CRDDescription `json:"owned,omitempty"` + Required []CRDDescription `json:"required,omitempty"` +} + +// APIServiceDefinitions declares all of the extension apis managed or required by +// an operator being ran by ClusterServiceVersion. +// +k8s:openapi-gen=true +type APIServiceDefinitions struct { + Owned []APIServiceDescription `json:"owned,omitempty"` + Required []APIServiceDescription `json:"required,omitempty"` +} + +// ClusterServiceVersionSpec declarations tell OLM how to install an operator +// that can manage apps for a given version. +// +k8s:openapi-gen=true +type ClusterServiceVersionSpec struct { + InstallStrategy NamedInstallStrategy `json:"install"` + Version version.OperatorVersion `json:"version,omitempty"` + Maturity string `json:"maturity,omitempty"` + CustomResourceDefinitions CustomResourceDefinitions `json:"customresourcedefinitions,omitempty"` + APIServiceDefinitions APIServiceDefinitions `json:"apiservicedefinitions,omitempty"` + WebhookDefinitions []WebhookDescription `json:"webhookdefinitions,omitempty"` + NativeAPIs []metav1.GroupVersionKind `json:"nativeAPIs,omitempty"` + MinKubeVersion string `json:"minKubeVersion,omitempty"` + + // The name of the operator in display format. + DisplayName string `json:"displayName"` + + // Description of the operator. Can include the features, limitations or use-cases of the + // operator. + // +optional + Description string `json:"description,omitempty"` + + // A list of keywords describing the operator. + // +optional + Keywords []string `json:"keywords,omitempty"` + + // A list of organizational entities maintaining the operator. + // +optional + Maintainers []Maintainer `json:"maintainers,omitempty"` + + // The publishing entity behind the operator. + // +optional + Provider AppLink `json:"provider,omitempty"` + + // A list of links related to the operator. + // +optional + Links []AppLink `json:"links,omitempty"` + + // The icon for this operator. + // +optional + Icon []Icon `json:"icon,omitempty"` + + // InstallModes specify supported installation types + // +optional + InstallModes []InstallMode `json:"installModes,omitempty"` + + // The name of a CSV this one replaces. Should match the `metadata.Name` field of the old CSV. + // +optional + Replaces string `json:"replaces,omitempty"` + + // Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. + // +optional + Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` + + // Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` + + // Label selector for related resources. + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,opt,name=selector"` + + // Cleanup specifies the cleanup behaviour when the CSV gets deleted + // +optional + Cleanup CleanupSpec `json:"cleanup,omitempty"` + + // The name(s) of one or more CSV(s) that should be skipped in the upgrade graph. + // Should match the `metadata.Name` field of the CSV that should be skipped. + // This field is only used during catalog creation and plays no part in cluster runtime. + // +optional + Skips []string `json:"skips,omitempty"` + + // List any related images, or other container images that your Operator might require to perform their functions. + // This list should also include operand images as well. All image references should be specified by + // digest (SHA) and not by tag. This field is only used during catalog creation and plays no part in cluster runtime. + // +optional + RelatedImages []RelatedImage `json:"relatedImages,omitempty"` +} + +// +k8s:openapi-gen=true +type CleanupSpec struct { + Enabled bool `json:"enabled"` +} + +// +k8s:openapi-gen=true +type Maintainer struct { + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` +} + +// +k8s:openapi-gen=true +type AppLink struct { + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` +} + +// +k8s:openapi-gen=true +type Icon struct { + Data string `json:"base64data"` + MediaType string `json:"mediatype"` +} + +// +k8s:openapi-gen=true +type RelatedImage struct { + Name string `json:"name"` + Image string `json:"image"` +} + +// ClusterServiceVersionPhase is a label for the condition of a ClusterServiceVersion at the current time. +type ClusterServiceVersionPhase string + +// These are the valid phases of ClusterServiceVersion +const ( + CSVPhaseNone = "" + // CSVPhasePending means the csv has been accepted by the system, but the install strategy has not been attempted. + // This is likely because there are unmet requirements. + CSVPhasePending ClusterServiceVersionPhase = "Pending" + // CSVPhaseInstallReady means that the requirements are met but the install strategy has not been run. + CSVPhaseInstallReady ClusterServiceVersionPhase = "InstallReady" + // CSVPhaseInstalling means that the install strategy has been initiated but not completed. + CSVPhaseInstalling ClusterServiceVersionPhase = "Installing" + // CSVPhaseSucceeded means that the resources in the CSV were created successfully. + CSVPhaseSucceeded ClusterServiceVersionPhase = "Succeeded" + // CSVPhaseFailed means that the install strategy could not be successfully completed. + CSVPhaseFailed ClusterServiceVersionPhase = "Failed" + // CSVPhaseUnknown means that for some reason the state of the csv could not be obtained. + CSVPhaseUnknown ClusterServiceVersionPhase = "Unknown" + // CSVPhaseReplacing means that a newer CSV has been created and the csv's resources will be transitioned to a new owner. + CSVPhaseReplacing ClusterServiceVersionPhase = "Replacing" + // CSVPhaseDeleting means that a CSV has been replaced by a new one and will be checked for safety before being deleted + CSVPhaseDeleting ClusterServiceVersionPhase = "Deleting" + // CSVPhaseAny matches all other phases in CSV queries + CSVPhaseAny ClusterServiceVersionPhase = "" +) + +// ConditionReason is a camelcased reason for the state transition +type ConditionReason string + +const ( + CSVReasonRequirementsUnknown ConditionReason = "RequirementsUnknown" + CSVReasonRequirementsNotMet ConditionReason = "RequirementsNotMet" + CSVReasonRequirementsMet ConditionReason = "AllRequirementsMet" + CSVReasonOwnerConflict ConditionReason = "OwnerConflict" + CSVReasonComponentFailed ConditionReason = "InstallComponentFailed" + CSVReasonComponentFailedNoRetry ConditionReason = "InstallComponentFailedNoRetry" + CSVReasonInvalidStrategy ConditionReason = "InvalidInstallStrategy" + CSVReasonWaiting ConditionReason = "InstallWaiting" + CSVReasonInstallSuccessful ConditionReason = "InstallSucceeded" + CSVReasonInstallCheckFailed ConditionReason = "InstallCheckFailed" + CSVReasonComponentUnhealthy ConditionReason = "ComponentUnhealthy" + CSVReasonBeingReplaced ConditionReason = "BeingReplaced" + CSVReasonReplaced ConditionReason = "Replaced" + CSVReasonNeedsReinstall ConditionReason = "NeedsReinstall" + CSVReasonNeedsCertRotation ConditionReason = "NeedsCertRotation" + CSVReasonAPIServiceResourceIssue ConditionReason = "APIServiceResourceIssue" + CSVReasonAPIServiceResourcesNeedReinstall ConditionReason = "APIServiceResourcesNeedReinstall" + CSVReasonAPIServiceInstallFailed ConditionReason = "APIServiceInstallFailed" + CSVReasonCopied ConditionReason = "Copied" + CSVReasonInvalidInstallModes ConditionReason = "InvalidInstallModes" + CSVReasonNoTargetNamespaces ConditionReason = "NoTargetNamespaces" + CSVReasonUnsupportedOperatorGroup ConditionReason = "UnsupportedOperatorGroup" + CSVReasonNoOperatorGroup ConditionReason = "NoOperatorGroup" + CSVReasonTooManyOperatorGroups ConditionReason = "TooManyOperatorGroups" + CSVReasonInterOperatorGroupOwnerConflict ConditionReason = "InterOperatorGroupOwnerConflict" + CSVReasonCannotModifyStaticOperatorGroupProvidedAPIs ConditionReason = "CannotModifyStaticOperatorGroupProvidedAPIs" + CSVReasonDetectedClusterChange ConditionReason = "DetectedClusterChange" + CSVReasonInvalidWebhookDescription ConditionReason = "InvalidWebhookDescription" + CSVReasonOperatorConditionNotUpgradeable ConditionReason = "OperatorConditionNotUpgradeable" + CSVReasonWaitingForCleanupToComplete ConditionReason = "WaitingOnCleanup" +) + +// HasCaResources returns true if the CSV has owned APIServices or Webhooks. +func (c *ClusterServiceVersion) HasCAResources() bool { + // Return early if there are no owned APIServices + if len(c.Spec.APIServiceDefinitions.Owned)+len(c.Spec.WebhookDefinitions) == 0 { + return false + } + return true +} + +// Conditions appear in the status as a record of state transitions on the ClusterServiceVersion +// +k8s:openapi-gen=true +type ClusterServiceVersionCondition struct { + // Condition of the ClusterServiceVersion + Phase ClusterServiceVersionPhase `json:"phase,omitempty"` + // A human readable message indicating details about why the ClusterServiceVersion is in this condition. + // +optional + Message string `json:"message,omitempty"` + // A brief CamelCase message indicating details about why the ClusterServiceVersion is in this state. + // e.g. 'RequirementsNotMet' + // +optional + Reason ConditionReason `json:"reason,omitempty"` + // Last time we updated the status + // +optional + LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the status transitioned from one status to another. + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` +} + +// OwnsCRD determines whether the current CSV owns a particular CRD. +func (csv ClusterServiceVersion) OwnsCRD(name string) bool { + for _, desc := range csv.Spec.CustomResourceDefinitions.Owned { + if desc.Name == name { + return true + } + } + + return false +} + +// OwnsAPIService determines whether the current CSV owns a particular APIService. +func (csv ClusterServiceVersion) OwnsAPIService(name string) bool { + for _, desc := range csv.Spec.APIServiceDefinitions.Owned { + apiServiceName := fmt.Sprintf("%s.%s", desc.Version, desc.Group) + if apiServiceName == name { + return true + } + } + + return false +} + +// StatusReason is a camelcased reason for the status of a RequirementStatus or DependentStatus +type StatusReason string + +const ( + RequirementStatusReasonPresent StatusReason = "Present" + RequirementStatusReasonNotPresent StatusReason = "NotPresent" + RequirementStatusReasonPresentNotSatisfied StatusReason = "PresentNotSatisfied" + // The CRD is present but the Established condition is False (not available) + RequirementStatusReasonNotAvailable StatusReason = "PresentNotAvailable" + DependentStatusReasonSatisfied StatusReason = "Satisfied" + DependentStatusReasonNotSatisfied StatusReason = "NotSatisfied" +) + +// DependentStatus is the status for a dependent requirement (to prevent infinite nesting) +// +k8s:openapi-gen=true +type DependentStatus struct { + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Status StatusReason `json:"status"` + UUID string `json:"uuid,omitempty"` + Message string `json:"message,omitempty"` +} + +// +k8s:openapi-gen=true +type RequirementStatus struct { + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Name string `json:"name"` + Status StatusReason `json:"status"` + Message string `json:"message"` + UUID string `json:"uuid,omitempty"` + Dependents []DependentStatus `json:"dependents,omitempty"` +} + +// ClusterServiceVersionStatus represents information about the status of a CSV. Status may trail the actual +// state of a system. +// +k8s:openapi-gen=true +type ClusterServiceVersionStatus struct { + // Current condition of the ClusterServiceVersion + Phase ClusterServiceVersionPhase `json:"phase,omitempty"` + // A human readable message indicating details about why the ClusterServiceVersion is in this condition. + // +optional + Message string `json:"message,omitempty"` + // A brief CamelCase message indicating details about why the ClusterServiceVersion is in this state. + // e.g. 'RequirementsNotMet' + // +optional + Reason ConditionReason `json:"reason,omitempty"` + // Last time we updated the status + // +optional + LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the status transitioned from one status to another. + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` + // List of conditions, a history of state transitions + Conditions []ClusterServiceVersionCondition `json:"conditions,omitempty"` + // The status of each requirement for this CSV + RequirementStatus []RequirementStatus `json:"requirementStatus,omitempty"` + // Last time the owned APIService certs were updated + // +optional + CertsLastUpdated *metav1.Time `json:"certsLastUpdated,omitempty"` + // Time the owned APIService certs will rotate next + // +optional + CertsRotateAt *metav1.Time `json:"certsRotateAt,omitempty"` + // CleanupStatus represents information about the status of cleanup while a CSV is pending deletion + // +optional + Cleanup CleanupStatus `json:"cleanup,omitempty"` +} + +// CleanupStatus represents information about the status of cleanup while a CSV is pending deletion +// +k8s:openapi-gen=true +type CleanupStatus struct { + // PendingDeletion is the list of custom resource objects that are pending deletion and blocked on finalizers. + // This indicates the progress of cleanup that is blocking CSV deletion or operator uninstall. + // +optional + PendingDeletion []ResourceList `json:"pendingDeletion,omitempty"` +} + +// ResourceList represents a list of resources which are of the same Group/Kind +// +k8s:openapi-gen=true +type ResourceList struct { + Group string `json:"group"` + Kind string `json:"kind"` + Instances []ResourceInstance `json:"instances"` +} + +// +k8s:openapi-gen=true +type ResourceInstance struct { + Name string `json:"name"` + // Namespace can be empty for cluster-scoped resources + Namespace string `json:"namespace,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +kubebuilder:storageversion +// +kubebuilder:resource:shortName={csv, csvs},categories=olm +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Display",type=string,JSONPath=`.spec.displayName`,description="The name of the CSV" +// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version`,description="The version of the CSV" +// +kubebuilder:printcolumn:name="Replaces",type=string,JSONPath=`.spec.replaces`,description="The name of a CSV that this one replaces" +// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase` + +// ClusterServiceVersion is a Custom Resource of type `ClusterServiceVersionSpec`. +type ClusterServiceVersion struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec ClusterServiceVersionSpec `json:"spec"` + // +optional + Status ClusterServiceVersionStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterServiceVersionList represents a list of ClusterServiceVersions. +type ClusterServiceVersionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []ClusterServiceVersion `json:"items"` +} + +// GetAllCRDDescriptions returns a deduplicated set of CRDDescriptions that is +// the union of the owned and required CRDDescriptions. +// +// Descriptions with the same name prefer the value in Owned. +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetAllCRDDescriptions() []CRDDescription { + set := make(map[string]CRDDescription) + for _, required := range csv.Spec.CustomResourceDefinitions.Required { + set[required.Name] = required + } + + for _, owned := range csv.Spec.CustomResourceDefinitions.Owned { + set[owned.Name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]CRDDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetAllAPIServiceDescriptions returns a deduplicated set of APIServiceDescriptions that is +// the union of the owned and required APIServiceDescriptions. +// +// Descriptions with the same name prefer the value in Owned. +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetAllAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, required := range csv.Spec.APIServiceDefinitions.Required { + name := fmt.Sprintf("%s.%s", required.Version, required.Group) + set[name] = required + } + + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := fmt.Sprintf("%s.%s", owned.Version, owned.Group) + set[name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetRequiredAPIServiceDescriptions returns a deduplicated set of required APIServiceDescriptions +// with the intersection of required and owned removed +// Equivalent to the set subtraction required - owned +// +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetRequiredAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, required := range csv.Spec.APIServiceDefinitions.Required { + name := fmt.Sprintf("%s.%s", required.Version, required.Group) + set[name] = required + } + + // Remove any shared owned from the set + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := fmt.Sprintf("%s.%s", owned.Version, owned.Group) + if _, ok := set[name]; ok { + delete(set, name) + } + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} + +// GetOwnedAPIServiceDescriptions returns a deduplicated set of owned APIServiceDescriptions +// +// Descriptions are returned in alphabetical order. +func (csv ClusterServiceVersion) GetOwnedAPIServiceDescriptions() []APIServiceDescription { + set := make(map[string]APIServiceDescription) + for _, owned := range csv.Spec.APIServiceDefinitions.Owned { + name := owned.GetName() + set[name] = owned + } + + keys := make([]string, 0) + for key := range set { + keys = append(keys, key) + } + sort.StringSlice(keys).Sort() + + descs := make([]APIServiceDescription, 0) + for _, key := range keys { + descs = append(descs, set[key]) + } + + return descs +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/doc.go new file mode 100644 index 000000000..74bc9b819 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/doc.go @@ -0,0 +1,6 @@ +// +groupName=operators.coreos.com +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators + +// Package v1alpha1 contains resources types for version v1alpha1 of the operators.coreos.com API group. +package v1alpha1 diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/installplan_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/installplan_types.go new file mode 100644 index 000000000..09deba525 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/installplan_types.go @@ -0,0 +1,389 @@ +package v1alpha1 + +import ( + "errors" + "fmt" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + InstallPlanKind = "InstallPlan" + InstallPlanAPIVersion = GroupName + "/" + GroupVersion +) + +// Approval is the user approval policy for an InstallPlan. +// It must be one of "Automatic" or "Manual". +type Approval string + +const ( + ApprovalAutomatic Approval = "Automatic" + ApprovalManual Approval = "Manual" +) + +// InstallPlanSpec defines a set of Application resources to be installed +type InstallPlanSpec struct { + CatalogSource string `json:"source,omitempty"` + CatalogSourceNamespace string `json:"sourceNamespace,omitempty"` + ClusterServiceVersionNames []string `json:"clusterServiceVersionNames"` + Approval Approval `json:"approval"` + Approved bool `json:"approved"` + Generation int `json:"generation,omitempty"` +} + +// InstallPlanPhase is the current status of a InstallPlan as a whole. +type InstallPlanPhase string + +const ( + InstallPlanPhaseNone InstallPlanPhase = "" + InstallPlanPhasePlanning InstallPlanPhase = "Planning" + InstallPlanPhaseRequiresApproval InstallPlanPhase = "RequiresApproval" + InstallPlanPhaseInstalling InstallPlanPhase = "Installing" + InstallPlanPhaseComplete InstallPlanPhase = "Complete" + InstallPlanPhaseFailed InstallPlanPhase = "Failed" +) + +// InstallPlanConditionType describes the state of an InstallPlan at a certain point as a whole. +type InstallPlanConditionType string + +const ( + InstallPlanResolved InstallPlanConditionType = "Resolved" + InstallPlanInstalled InstallPlanConditionType = "Installed" +) + +// ConditionReason is a camelcased reason for the state transition. +type InstallPlanConditionReason string + +const ( + InstallPlanReasonPlanUnknown InstallPlanConditionReason = "PlanUnknown" + InstallPlanReasonInstallCheckFailed InstallPlanConditionReason = "InstallCheckFailed" + InstallPlanReasonDependencyConflict InstallPlanConditionReason = "DependenciesConflict" + InstallPlanReasonComponentFailed InstallPlanConditionReason = "InstallComponentFailed" +) + +// StepStatus is the current status of a particular resource an in +// InstallPlan +type StepStatus string + +const ( + StepStatusUnknown StepStatus = "Unknown" + StepStatusNotPresent StepStatus = "NotPresent" + StepStatusPresent StepStatus = "Present" + StepStatusCreated StepStatus = "Created" + StepStatusNotCreated StepStatus = "NotCreated" + StepStatusWaitingForAPI StepStatus = "WaitingForApi" + StepStatusUnsupportedResource StepStatus = "UnsupportedResource" +) + +// ErrInvalidInstallPlan is the error returned by functions that operate on +// InstallPlans when the InstallPlan does not contain totally valid data. +var ErrInvalidInstallPlan = errors.New("the InstallPlan contains invalid data") + +// InstallPlanStatus represents the information about the status of +// steps required to complete installation. +// +// Status may trail the actual state of a system. +type InstallPlanStatus struct { + Phase InstallPlanPhase `json:"phase"` + Conditions []InstallPlanCondition `json:"conditions,omitempty"` + CatalogSources []string `json:"catalogSources"` + Plan []*Step `json:"plan,omitempty"` + // BundleLookups is the set of in-progress requests to pull and unpackage bundle content to the cluster. + // +optional + BundleLookups []BundleLookup `json:"bundleLookups,omitempty"` + // AttenuatedServiceAccountRef references the service account that is used + // to do scoped operator install. + AttenuatedServiceAccountRef *corev1.ObjectReference `json:"attenuatedServiceAccountRef,omitempty"` + + // StartTime is the time when the controller began applying + // the resources listed in the plan to the cluster. + // +optional + StartTime *metav1.Time `json:"startTime,omitempty"` + + // Message is a human-readable message containing detailed + // information that may be important to understanding why the + // plan has its current status. + // +optional + Message string `json:"message,omitempty"` +} + +// InstallPlanCondition represents the overall status of the execution of +// an InstallPlan. +type InstallPlanCondition struct { + Type InstallPlanConditionType `json:"type,omitempty"` + Status corev1.ConditionStatus `json:"status,omitempty"` // True, False, or Unknown + LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` + Reason InstallPlanConditionReason `json:"reason,omitempty"` + Message string `json:"message,omitempty"` +} + +// allow overwriting `now` function for deterministic tests +var now = metav1.Now + +// GetCondition returns the InstallPlanCondition of the given type if it exists in the InstallPlanStatus' Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (s InstallPlanStatus) GetCondition(conditionType InstallPlanConditionType) InstallPlanCondition { + for _, cond := range s.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return InstallPlanCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// SetCondition adds or updates a condition, using `Type` as merge key. +func (s *InstallPlanStatus) SetCondition(cond InstallPlanCondition) InstallPlanCondition { + for i, existing := range s.Conditions { + if existing.Type != cond.Type { + continue + } + if existing.Status == cond.Status { + cond.LastTransitionTime = existing.LastTransitionTime + } + s.Conditions[i] = cond + return cond + } + s.Conditions = append(s.Conditions, cond) + return cond +} + +func OrderSteps(steps []*Step) []*Step { + // CSVs must be applied first + csvList := []*Step{} + + // CRDs must be applied second + crdList := []*Step{} + + // Other resources may be applied in any order + remainingResources := []*Step{} + for _, step := range steps { + switch step.Resource.Kind { + case crdKind: + crdList = append(crdList, step) + case ClusterServiceVersionKind: + csvList = append(csvList, step) + default: + remainingResources = append(remainingResources, step) + } + } + + result := make([]*Step, len(steps)) + i := 0 + + for j := range csvList { + result[i] = csvList[j] + i++ + } + + for j := range crdList { + result[i] = crdList[j] + i++ + } + + for j := range remainingResources { + result[i] = remainingResources[j] + i++ + } + + return result +} + +func (s InstallPlanStatus) NeedsRequeue() bool { + for _, step := range s.Plan { + switch step.Status { + case StepStatusWaitingForAPI: + return true + } + } + + return false +} +func ConditionFailed(cond InstallPlanConditionType, reason InstallPlanConditionReason, message string, now *metav1.Time) InstallPlanCondition { + return InstallPlanCondition{ + Type: cond, + Status: corev1.ConditionFalse, + Reason: reason, + Message: message, + LastUpdateTime: now, + LastTransitionTime: now, + } +} + +func ConditionMet(cond InstallPlanConditionType, now *metav1.Time) InstallPlanCondition { + return InstallPlanCondition{ + Type: cond, + Status: corev1.ConditionTrue, + LastUpdateTime: now, + LastTransitionTime: now, + } +} + +// Step represents the status of an individual step in an InstallPlan. +type Step struct { + Resolving string `json:"resolving"` + Resource StepResource `json:"resource"` + Optional bool `json:"optional,omitempty"` + Status StepStatus `json:"status"` +} + +// BundleLookupConditionType is a category of the overall state of a BundleLookup. +type BundleLookupConditionType string + +const ( + // BundleLookupPending describes BundleLookups that are not complete. + BundleLookupPending BundleLookupConditionType = "BundleLookupPending" + + // BundleLookupFailed describes conditions types for when BundleLookups fail + BundleLookupFailed BundleLookupConditionType = "BundleLookupFailed" + + crdKind = "CustomResourceDefinition" +) + +type BundleLookupCondition struct { + // Type of condition. + Type BundleLookupConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status"` + // The reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty"` + // A human readable message indicating details about the transition. + // +optional + Message string `json:"message,omitempty"` + // Last time the condition was probed. + // +optional + LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the condition transitioned from one status to another. + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` +} + +// BundleLookup is a request to pull and unpackage the content of a bundle to the cluster. +type BundleLookup struct { + // Path refers to the location of a bundle to pull. + // It's typically an image reference. + Path string `json:"path"` + // Identifier is the catalog-unique name of the operator (the name of the CSV for bundles that contain CSVs) + Identifier string `json:"identifier"` + // Replaces is the name of the bundle to replace with the one found at Path. + Replaces string `json:"replaces"` + // CatalogSourceRef is a reference to the CatalogSource the bundle path was resolved from. + CatalogSourceRef *corev1.ObjectReference `json:"catalogSourceRef"` + // Conditions represents the overall state of a BundleLookup. + // +optional + Conditions []BundleLookupCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` + // The effective properties of the unpacked bundle. + // +optional + Properties string `json:"properties,omitempty"` +} + +// GetCondition returns the BundleLookupCondition of the given type if it exists in the BundleLookup's Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (b BundleLookup) GetCondition(conditionType BundleLookupConditionType) BundleLookupCondition { + for _, cond := range b.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return BundleLookupCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// RemoveCondition removes the BundleLookupCondition of the given type from the BundleLookup's Conditions if it exists. +func (b *BundleLookup) RemoveCondition(conditionType BundleLookupConditionType) { + for i, cond := range b.Conditions { + if cond.Type == conditionType { + b.Conditions = append(b.Conditions[:i], b.Conditions[i+1:]...) + if len(b.Conditions) == 0 { + b.Conditions = nil + } + return + } + } +} + +// SetCondition replaces the existing BundleLookupCondition of the same type, or adds it if it was not found. +func (b *BundleLookup) SetCondition(cond BundleLookupCondition) BundleLookupCondition { + for i, existing := range b.Conditions { + if existing.Type != cond.Type { + continue + } + if existing.Status == cond.Status { + cond.LastTransitionTime = existing.LastTransitionTime + } + b.Conditions[i] = cond + return cond + } + b.Conditions = append(b.Conditions, cond) + + return cond +} + +func (s *Step) String() string { + return fmt.Sprintf("%s: %s (%s)", s.Resolving, s.Resource, s.Status) +} + +// StepResource represents the status of a resource to be tracked by an +// InstallPlan. +type StepResource struct { + CatalogSource string `json:"sourceName"` + CatalogSourceNamespace string `json:"sourceNamespace"` + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Name string `json:"name"` + Manifest string `json:"manifest,omitempty"` +} + +func (r StepResource) String() string { + return fmt.Sprintf("%s[%s/%s/%s (%s/%s)]", r.Name, r.Group, r.Version, r.Kind, r.CatalogSource, r.CatalogSourceNamespace) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +kubebuilder:resource:shortName=ip,categories=olm +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="CSV",type=string,JSONPath=`.spec.clusterServiceVersionNames[0]`,description="The first CSV in the list of clusterServiceVersionNames" +// +kubebuilder:printcolumn:name="Approval",type=string,JSONPath=`.spec.approval`,description="The approval mode" +// +kubebuilder:printcolumn:name="Approved",type=boolean,JSONPath=`.spec.approved` + +// InstallPlan defines the installation of a set of operators. +type InstallPlan struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec InstallPlanSpec `json:"spec"` + // +optional + Status InstallPlanStatus `json:"status"` +} + +// EnsureCatalogSource ensures that a CatalogSource is present in the Status +// block of an InstallPlan. +func (p *InstallPlan) EnsureCatalogSource(sourceName string) { + for _, srcName := range p.Status.CatalogSources { + if srcName == sourceName { + return + } + } + + p.Status.CatalogSources = append(p.Status.CatalogSources, sourceName) +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// InstallPlanList is a list of InstallPlan resources. +type InstallPlanList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []InstallPlan `json:"items"` +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/register.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/register.go new file mode 100644 index 000000000..f0331ba3e --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/register.go @@ -0,0 +1,55 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators" +) + +const ( + // GroupName is the group name used in this package. + GroupName = operators.GroupName + // GroupVersion is the group version used in this package. + GroupVersion = "v1alpha1" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder initializes a scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme + + // localSchemeBuilder is expected by generated conversion functions + localSchemeBuilder = &SchemeBuilder +) + +// addKnownTypes adds the list of known types to Scheme +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &CatalogSource{}, + &CatalogSourceList{}, + &InstallPlan{}, + &InstallPlanList{}, + &Subscription{}, + &SubscriptionList{}, + &ClusterServiceVersion{}, + &ClusterServiceVersionList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/subscription_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/subscription_types.go new file mode 100644 index 000000000..292fedf9b --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/subscription_types.go @@ -0,0 +1,360 @@ +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" +) + +const ( + SubscriptionKind = "Subscription" + SubscriptionCRDAPIVersion = GroupName + "/" + GroupVersion +) + +// SubscriptionState tracks when updates are available, installing, or service is up to date +type SubscriptionState string + +const ( + SubscriptionStateNone = "" + SubscriptionStateFailed = "UpgradeFailed" + SubscriptionStateUpgradeAvailable = "UpgradeAvailable" + SubscriptionStateUpgradePending = "UpgradePending" + SubscriptionStateAtLatest = "AtLatestKnown" +) + +const ( + SubscriptionReasonInvalidCatalog ConditionReason = "InvalidCatalog" + SubscriptionReasonUpgradeSucceeded ConditionReason = "UpgradeSucceeded" +) + +// SubscriptionSpec defines an Application that can be installed +type SubscriptionSpec struct { + CatalogSource string `json:"source"` + CatalogSourceNamespace string `json:"sourceNamespace"` + Package string `json:"name"` + Channel string `json:"channel,omitempty"` + StartingCSV string `json:"startingCSV,omitempty"` + InstallPlanApproval Approval `json:"installPlanApproval,omitempty"` + Config *SubscriptionConfig `json:"config,omitempty"` +} + +// SubscriptionConfig contains configuration specified for a subscription. +type SubscriptionConfig struct { + // Selector is the label selector for pods to be configured. + // Existing ReplicaSets whose pods are + // selected by this will be the ones affected by this deployment. + // It must match the pod template's labels. + Selector *metav1.LabelSelector `json:"selector,omitempty"` + + // NodeSelector is a selector which must be true for the pod to fit on a node. + // Selector which must match a node's labels for the pod to be scheduled on that node. + // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + + // Tolerations are the pod's tolerations. + // +optional + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + + // Resources represents compute resources required by this container. + // Immutable. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ + // +optional + Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + + // EnvFrom is a list of sources to populate environment variables in the container. + // The keys defined within a source must be a C_IDENTIFIER. All invalid keys + // will be reported as an event when the container is starting. When a key exists in multiple + // sources, the value associated with the last source will take precedence. + // Values defined by an Env with a duplicate key will take precedence. + // Immutable. + // +optional + EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"` + // Env is a list of environment variables to set in the container. + // Cannot be updated. + // +patchMergeKey=name + // +patchStrategy=merge + // +optional + Env []corev1.EnvVar `json:"env,omitempty" patchMergeKey:"name" patchStrategy:"merge"` + + // List of Volumes to set in the podSpec. + // +optional + Volumes []corev1.Volume `json:"volumes,omitempty"` + + // List of VolumeMounts to set in the container. + // +optional + VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"` + + // If specified, overrides the pod's scheduling constraints. + // nil sub-attributes will *not* override the original values in the pod.spec for those sub-attributes. + // Use empty object ({}) to erase original sub-attribute values. + // +optional + Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"` + + // Annotations is an unstructured key value map stored with each Deployment, Pod, APIService in the Operator. + // Typically, annotations may be set by external tools to store and retrieve arbitrary metadata. + // Use this field to pre-define annotations that OLM should add to each of the Subscription's + // deployments, pods, and apiservices. + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` +} + +// SubscriptionConditionType indicates an explicit state condition about a Subscription in "abnormal-true" +// polarity form (see https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties). +type SubscriptionConditionType string + +const ( + // SubscriptionCatalogSourcesUnhealthy indicates that some or all of the CatalogSources to be used in resolution are unhealthy. + SubscriptionCatalogSourcesUnhealthy SubscriptionConditionType = "CatalogSourcesUnhealthy" + + // SubscriptionInstallPlanMissing indicates that a Subscription's InstallPlan is missing. + SubscriptionInstallPlanMissing SubscriptionConditionType = "InstallPlanMissing" + + // SubscriptionInstallPlanPending indicates that a Subscription's InstallPlan is pending installation. + SubscriptionInstallPlanPending SubscriptionConditionType = "InstallPlanPending" + + // SubscriptionInstallPlanFailed indicates that the installation of a Subscription's InstallPlan has failed. + SubscriptionInstallPlanFailed SubscriptionConditionType = "InstallPlanFailed" + + // SubscriptionResolutionFailed indicates that the dependency resolution in the namespace in which the subscription is created has failed + SubscriptionResolutionFailed SubscriptionConditionType = "ResolutionFailed" + + // SubscriptionBundleUnpacking indicates that the unpack job is currently running + SubscriptionBundleUnpacking SubscriptionConditionType = "BundleUnpacking" + + // SubscriptionBundleUnpackFailed indicates that the unpack job failed + SubscriptionBundleUnpackFailed SubscriptionConditionType = "BundleUnpackFailed" + + // SubscriptionDeprecated is a roll-up condition which indicates that the Operator currently installed with this Subscription + //has been deprecated. It will be present when any of the three deprecation types (Package, Channel, Bundle) are present. + SubscriptionDeprecated SubscriptionConditionType = "Deprecated" + + // SubscriptionOperatorDeprecated indicates that the Package currently installed with this Subscription has been deprecated. + SubscriptionPackageDeprecated SubscriptionConditionType = "PackageDeprecated" + + // SubscriptionOperatorDeprecated indicates that the Channel used with this Subscription has been deprecated. + SubscriptionChannelDeprecated SubscriptionConditionType = "ChannelDeprecated" + + // SubscriptionOperatorDeprecated indicates that the Bundle currently installed with this Subscription has been deprecated. + SubscriptionBundleDeprecated SubscriptionConditionType = "BundleDeprecated" +) + +const ( + // NoCatalogSourcesFound is a reason string for Subscriptions with unhealthy CatalogSources due to none being available. + NoCatalogSourcesFound = "NoCatalogSourcesFound" + + // AllCatalogSourcesHealthy is a reason string for Subscriptions that transitioned due to all CatalogSources being healthy. + AllCatalogSourcesHealthy = "AllCatalogSourcesHealthy" + + // CatalogSourcesAdded is a reason string for Subscriptions that transitioned due to CatalogSources being added. + CatalogSourcesAdded = "CatalogSourcesAdded" + + // CatalogSourcesUpdated is a reason string for Subscriptions that transitioned due to CatalogSource being updated. + CatalogSourcesUpdated = "CatalogSourcesUpdated" + + // CatalogSourcesDeleted is a reason string for Subscriptions that transitioned due to CatalogSources being removed. + CatalogSourcesDeleted = "CatalogSourcesDeleted" + + // UnhealthyCatalogSourceFound is a reason string for Subscriptions that transitioned because an unhealthy CatalogSource was found. + UnhealthyCatalogSourceFound = "UnhealthyCatalogSourceFound" + + // ReferencedInstallPlanNotFound is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being found. + ReferencedInstallPlanNotFound = "ReferencedInstallPlanNotFound" + + // InstallPlanNotYetReconciled is a reason string for Subscriptions that transitioned due to a referenced InstallPlan not being reconciled yet. + InstallPlanNotYetReconciled = "InstallPlanNotYetReconciled" + + // InstallPlanFailed is a reason string for Subscriptions that transitioned due to a referenced InstallPlan failing without setting an explicit failure condition. + InstallPlanFailed = "InstallPlanFailed" +) + +// SubscriptionCondition represents the latest available observations of a Subscription's state. +type SubscriptionCondition struct { + // Type is the type of Subscription condition. + Type SubscriptionConditionType `json:"type" description:"type of Subscription condition"` + + // Status is the status of the condition, one of True, False, Unknown. + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // Reason is a one-word CamelCase reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + + // Message is a human-readable message indicating details about last transition. + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` + + // LastHeartbeatTime is the last time we got an update on a given condition + // +optional + LastHeartbeatTime *metav1.Time `json:"lastHeartbeatTime,omitempty" description:"last time we got an update on a given condition"` + + // LastTransitionTime is the last time the condition transit from one status to another + // +optional + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another" hash:"ignore"` +} + +// Equals returns true if a SubscriptionCondition equals the one given, false otherwise. +// Equality is determined by the equality of the type, status, reason, and message fields ONLY. +func (s SubscriptionCondition) Equals(condition SubscriptionCondition) bool { + return s.Type == condition.Type && s.Status == condition.Status && s.Reason == condition.Reason && s.Message == condition.Message +} + +type SubscriptionStatus struct { + // CurrentCSV is the CSV the Subscription is progressing to. + // +optional + CurrentCSV string `json:"currentCSV,omitempty"` + + // InstalledCSV is the CSV currently installed by the Subscription. + // +optional + InstalledCSV string `json:"installedCSV,omitempty"` + + // Install is a reference to the latest InstallPlan generated for the Subscription. + // DEPRECATED: InstallPlanRef + // +optional + Install *InstallPlanReference `json:"installplan,omitempty"` + + // State represents the current state of the Subscription + // +optional + State SubscriptionState `json:"state,omitempty"` + + // Reason is the reason the Subscription was transitioned to its current state. + // +optional + Reason ConditionReason `json:"reason,omitempty"` + + // InstallPlanGeneration is the current generation of the installplan + // +optional + InstallPlanGeneration int `json:"installPlanGeneration,omitempty"` + + // InstallPlanRef is a reference to the latest InstallPlan that contains the Subscription's current CSV. + // +optional + InstallPlanRef *corev1.ObjectReference `json:"installPlanRef,omitempty"` + + // CatalogHealth contains the Subscription's view of its relevant CatalogSources' status. + // It is used to determine SubscriptionStatusConditions related to CatalogSources. + // +optional + CatalogHealth []SubscriptionCatalogHealth `json:"catalogHealth,omitempty"` + + // Conditions is a list of the latest available observations about a Subscription's current state. + // +optional + Conditions []SubscriptionCondition `json:"conditions,omitempty" hash:"set"` + + // LastUpdated represents the last time that the Subscription status was updated. + LastUpdated metav1.Time `json:"lastUpdated"` +} + +// GetCondition returns the SubscriptionCondition of the given type if it exists in the SubscriptionStatus' Conditions. +// Returns a condition of the given type with a ConditionStatus of "Unknown" if not found. +func (s SubscriptionStatus) GetCondition(conditionType SubscriptionConditionType) SubscriptionCondition { + for _, cond := range s.Conditions { + if cond.Type == conditionType { + return cond + } + } + + return SubscriptionCondition{ + Type: conditionType, + Status: corev1.ConditionUnknown, + } +} + +// SetCondition sets the given SubscriptionCondition in the SubscriptionStatus' Conditions. +func (s *SubscriptionStatus) SetCondition(condition SubscriptionCondition) { + for i, cond := range s.Conditions { + if cond.Type == condition.Type { + s.Conditions[i] = condition + return + } + } + + s.Conditions = append(s.Conditions, condition) +} + +// RemoveConditions removes any conditions of the given types from the SubscriptionStatus' Conditions. +func (s *SubscriptionStatus) RemoveConditions(remove ...SubscriptionConditionType) { + exclusions := map[SubscriptionConditionType]struct{}{} + for _, r := range remove { + exclusions[r] = struct{}{} + } + + var filtered []SubscriptionCondition + for _, cond := range s.Conditions { + if _, ok := exclusions[cond.Type]; ok { + // Skip excluded condition types + continue + } + filtered = append(filtered, cond) + } + + s.Conditions = filtered +} + +type InstallPlanReference struct { + APIVersion string `json:"apiVersion"` + Kind string `json:"kind"` + Name string `json:"name"` + UID types.UID `json:"uuid"` +} + +// SubscriptionCatalogHealth describes the health of a CatalogSource the Subscription knows about. +type SubscriptionCatalogHealth struct { + // CatalogSourceRef is a reference to a CatalogSource. + CatalogSourceRef *corev1.ObjectReference `json:"catalogSourceRef"` + + // LastUpdated represents the last time that the CatalogSourceHealth changed + LastUpdated *metav1.Time `json:"lastUpdated"` + + // Healthy is true if the CatalogSource is healthy; false otherwise. + Healthy bool `json:"healthy"` +} + +// Equals returns true if a SubscriptionCatalogHealth equals the one given, false otherwise. +// Equality is based SOLEY on health and UID. +func (s SubscriptionCatalogHealth) Equals(health SubscriptionCatalogHealth) bool { + return s.Healthy == health.Healthy && s.CatalogSourceRef.UID == health.CatalogSourceRef.UID +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +kubebuilder:resource:shortName={sub, subs},categories=olm +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Package",type=string,JSONPath=`.spec.name`,description="The package subscribed to" +// +kubebuilder:printcolumn:name="Source",type=string,JSONPath=`.spec.source`,description="The catalog source for the specified package" +// +kubebuilder:printcolumn:name="Channel",type=string,JSONPath=`.spec.channel`,description="The channel of updates to subscribe to" + +// Subscription keeps operators up to date by tracking changes to Catalogs. +type Subscription struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec *SubscriptionSpec `json:"spec"` + // +optional + Status SubscriptionStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SubscriptionList is a list of Subscription resources. +type SubscriptionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Subscription `json:"items"` +} + +// GetInstallPlanApproval gets the configured install plan approval or the default +func (s *Subscription) GetInstallPlanApproval() Approval { + if s.Spec.InstallPlanApproval == ApprovalManual { + return ApprovalManual + } + return ApprovalAutomatic +} + +// NewInstallPlanReference returns an InstallPlanReference for the given ObjectReference. +func NewInstallPlanReference(ref *corev1.ObjectReference) *InstallPlanReference { + return &InstallPlanReference{ + APIVersion: ref.APIVersion, + Kind: ref.Kind, + Name: ref.Name, + UID: ref.UID, + } +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..684a7432a --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,1632 @@ +//go:build !ignore_autogenerated + +/* + +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 controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "encoding/json" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + "k8s.io/api/core/v1" + rbacv1 "k8s.io/api/rbac/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIResourceReference) DeepCopyInto(out *APIResourceReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIResourceReference. +func (in *APIResourceReference) DeepCopy() *APIResourceReference { + if in == nil { + return nil + } + out := new(APIResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceDefinitions) DeepCopyInto(out *APIServiceDefinitions) { + *out = *in + if in.Owned != nil { + in, out := &in.Owned, &out.Owned + *out = make([]APIServiceDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]APIServiceDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceDefinitions. +func (in *APIServiceDefinitions) DeepCopy() *APIServiceDefinitions { + if in == nil { + return nil + } + out := new(APIServiceDefinitions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIServiceDescription) DeepCopyInto(out *APIServiceDescription) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceReference, len(*in)) + copy(*out, *in) + } + if in.StatusDescriptors != nil { + in, out := &in.StatusDescriptors, &out.StatusDescriptors + *out = make([]StatusDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SpecDescriptors != nil { + in, out := &in.SpecDescriptors, &out.SpecDescriptors + *out = make([]SpecDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ActionDescriptor != nil { + in, out := &in.ActionDescriptor, &out.ActionDescriptor + *out = make([]ActionDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIServiceDescription. +func (in *APIServiceDescription) DeepCopy() *APIServiceDescription { + if in == nil { + return nil + } + out := new(APIServiceDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ActionDescriptor) DeepCopyInto(out *ActionDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActionDescriptor. +func (in *ActionDescriptor) DeepCopy() *ActionDescriptor { + if in == nil { + return nil + } + out := new(ActionDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AppLink) DeepCopyInto(out *AppLink) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppLink. +func (in *AppLink) DeepCopy() *AppLink { + if in == nil { + return nil + } + out := new(AppLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BundleLookup) DeepCopyInto(out *BundleLookup) { + *out = *in + if in.CatalogSourceRef != nil { + in, out := &in.CatalogSourceRef, &out.CatalogSourceRef + *out = new(v1.ObjectReference) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]BundleLookupCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BundleLookup. +func (in *BundleLookup) DeepCopy() *BundleLookup { + if in == nil { + return nil + } + out := new(BundleLookup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BundleLookupCondition) DeepCopyInto(out *BundleLookupCondition) { + *out = *in + if in.LastUpdateTime != nil { + in, out := &in.LastUpdateTime, &out.LastUpdateTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BundleLookupCondition. +func (in *BundleLookupCondition) DeepCopy() *BundleLookupCondition { + if in == nil { + return nil + } + out := new(BundleLookupCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CRDDescription) DeepCopyInto(out *CRDDescription) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]APIResourceReference, len(*in)) + copy(*out, *in) + } + if in.StatusDescriptors != nil { + in, out := &in.StatusDescriptors, &out.StatusDescriptors + *out = make([]StatusDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SpecDescriptors != nil { + in, out := &in.SpecDescriptors, &out.SpecDescriptors + *out = make([]SpecDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ActionDescriptor != nil { + in, out := &in.ActionDescriptor, &out.ActionDescriptor + *out = make([]ActionDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDDescription. +func (in *CRDDescription) DeepCopy() *CRDDescription { + if in == nil { + return nil + } + out := new(CRDDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSource) DeepCopyInto(out *CatalogSource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSource. +func (in *CatalogSource) DeepCopy() *CatalogSource { + if in == nil { + return nil + } + out := new(CatalogSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSource) 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 *CatalogSourceList) DeepCopyInto(out *CatalogSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CatalogSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceList. +func (in *CatalogSourceList) DeepCopy() *CatalogSourceList { + if in == nil { + return nil + } + out := new(CatalogSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CatalogSourceList) 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 *CatalogSourceSpec) DeepCopyInto(out *CatalogSourceSpec) { + *out = *in + if in.GrpcPodConfig != nil { + in, out := &in.GrpcPodConfig, &out.GrpcPodConfig + *out = new(GrpcPodConfig) + (*in).DeepCopyInto(*out) + } + if in.UpdateStrategy != nil { + in, out := &in.UpdateStrategy, &out.UpdateStrategy + *out = new(UpdateStrategy) + (*in).DeepCopyInto(*out) + } + if in.Secrets != nil { + in, out := &in.Secrets, &out.Secrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.Icon = in.Icon +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceSpec. +func (in *CatalogSourceSpec) DeepCopy() *CatalogSourceSpec { + if in == nil { + return nil + } + out := new(CatalogSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CatalogSourceStatus) DeepCopyInto(out *CatalogSourceStatus) { + *out = *in + if in.LatestImageRegistryPoll != nil { + in, out := &in.LatestImageRegistryPoll, &out.LatestImageRegistryPoll + *out = (*in).DeepCopy() + } + if in.ConfigMapResource != nil { + in, out := &in.ConfigMapResource, &out.ConfigMapResource + *out = new(ConfigMapResourceReference) + (*in).DeepCopyInto(*out) + } + if in.RegistryServiceStatus != nil { + in, out := &in.RegistryServiceStatus, &out.RegistryServiceStatus + *out = new(RegistryServiceStatus) + (*in).DeepCopyInto(*out) + } + if in.GRPCConnectionState != nil { + in, out := &in.GRPCConnectionState, &out.GRPCConnectionState + *out = new(GRPCConnectionState) + (*in).DeepCopyInto(*out) + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CatalogSourceStatus. +func (in *CatalogSourceStatus) DeepCopy() *CatalogSourceStatus { + if in == nil { + return nil + } + out := new(CatalogSourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CleanupSpec) DeepCopyInto(out *CleanupSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CleanupSpec. +func (in *CleanupSpec) DeepCopy() *CleanupSpec { + if in == nil { + return nil + } + out := new(CleanupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CleanupStatus) DeepCopyInto(out *CleanupStatus) { + *out = *in + if in.PendingDeletion != nil { + in, out := &in.PendingDeletion, &out.PendingDeletion + *out = make([]ResourceList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CleanupStatus. +func (in *CleanupStatus) DeepCopy() *CleanupStatus { + if in == nil { + return nil + } + out := new(CleanupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersion) DeepCopyInto(out *ClusterServiceVersion) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersion. +func (in *ClusterServiceVersion) DeepCopy() *ClusterServiceVersion { + if in == nil { + return nil + } + out := new(ClusterServiceVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterServiceVersion) 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 *ClusterServiceVersionCondition) DeepCopyInto(out *ClusterServiceVersionCondition) { + *out = *in + if in.LastUpdateTime != nil { + in, out := &in.LastUpdateTime, &out.LastUpdateTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionCondition. +func (in *ClusterServiceVersionCondition) DeepCopy() *ClusterServiceVersionCondition { + if in == nil { + return nil + } + out := new(ClusterServiceVersionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionList) DeepCopyInto(out *ClusterServiceVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterServiceVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionList. +func (in *ClusterServiceVersionList) DeepCopy() *ClusterServiceVersionList { + if in == nil { + return nil + } + out := new(ClusterServiceVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterServiceVersionList) 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 *ClusterServiceVersionSpec) DeepCopyInto(out *ClusterServiceVersionSpec) { + *out = *in + in.InstallStrategy.DeepCopyInto(&out.InstallStrategy) + in.Version.DeepCopyInto(&out.Version) + in.CustomResourceDefinitions.DeepCopyInto(&out.CustomResourceDefinitions) + in.APIServiceDefinitions.DeepCopyInto(&out.APIServiceDefinitions) + if in.WebhookDefinitions != nil { + in, out := &in.WebhookDefinitions, &out.WebhookDefinitions + *out = make([]WebhookDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NativeAPIs != nil { + in, out := &in.NativeAPIs, &out.NativeAPIs + *out = make([]metav1.GroupVersionKind, len(*in)) + copy(*out, *in) + } + if in.Keywords != nil { + in, out := &in.Keywords, &out.Keywords + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Maintainers != nil { + in, out := &in.Maintainers, &out.Maintainers + *out = make([]Maintainer, len(*in)) + copy(*out, *in) + } + out.Provider = in.Provider + if in.Links != nil { + in, out := &in.Links, &out.Links + *out = make([]AppLink, len(*in)) + copy(*out, *in) + } + if in.Icon != nil { + in, out := &in.Icon, &out.Icon + *out = make([]Icon, len(*in)) + copy(*out, *in) + } + if in.InstallModes != nil { + in, out := &in.InstallModes, &out.InstallModes + *out = make([]InstallMode, len(*in)) + copy(*out, *in) + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + out.Cleanup = in.Cleanup + if in.Skips != nil { + in, out := &in.Skips, &out.Skips + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.RelatedImages != nil { + in, out := &in.RelatedImages, &out.RelatedImages + *out = make([]RelatedImage, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionSpec. +func (in *ClusterServiceVersionSpec) DeepCopy() *ClusterServiceVersionSpec { + if in == nil { + return nil + } + out := new(ClusterServiceVersionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterServiceVersionStatus) DeepCopyInto(out *ClusterServiceVersionStatus) { + *out = *in + if in.LastUpdateTime != nil { + in, out := &in.LastUpdateTime, &out.LastUpdateTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]ClusterServiceVersionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RequirementStatus != nil { + in, out := &in.RequirementStatus, &out.RequirementStatus + *out = make([]RequirementStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CertsLastUpdated != nil { + in, out := &in.CertsLastUpdated, &out.CertsLastUpdated + *out = (*in).DeepCopy() + } + if in.CertsRotateAt != nil { + in, out := &in.CertsRotateAt, &out.CertsRotateAt + *out = (*in).DeepCopy() + } + in.Cleanup.DeepCopyInto(&out.Cleanup) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterServiceVersionStatus. +func (in *ClusterServiceVersionStatus) DeepCopy() *ClusterServiceVersionStatus { + if in == nil { + return nil + } + out := new(ClusterServiceVersionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigMapResourceReference) DeepCopyInto(out *ConfigMapResourceReference) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapResourceReference. +func (in *ConfigMapResourceReference) DeepCopy() *ConfigMapResourceReference { + if in == nil { + return nil + } + out := new(ConfigMapResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomResourceDefinitions) DeepCopyInto(out *CustomResourceDefinitions) { + *out = *in + if in.Owned != nil { + in, out := &in.Owned, &out.Owned + *out = make([]CRDDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]CRDDescription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResourceDefinitions. +func (in *CustomResourceDefinitions) DeepCopy() *CustomResourceDefinitions { + if in == nil { + return nil + } + out := new(CustomResourceDefinitions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DependentStatus) DeepCopyInto(out *DependentStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DependentStatus. +func (in *DependentStatus) DeepCopy() *DependentStatus { + if in == nil { + return nil + } + out := new(DependentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtractContentConfig) DeepCopyInto(out *ExtractContentConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtractContentConfig. +func (in *ExtractContentConfig) DeepCopy() *ExtractContentConfig { + if in == nil { + return nil + } + out := new(ExtractContentConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GRPCConnectionState) DeepCopyInto(out *GRPCConnectionState) { + *out = *in + in.LastConnectTime.DeepCopyInto(&out.LastConnectTime) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GRPCConnectionState. +func (in *GRPCConnectionState) DeepCopy() *GRPCConnectionState { + if in == nil { + return nil + } + out := new(GRPCConnectionState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GrpcPodConfig) DeepCopyInto(out *GrpcPodConfig) { + *out = *in + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.PriorityClassName != nil { + in, out := &in.PriorityClassName, &out.PriorityClassName + *out = new(string) + **out = **in + } + if in.MemoryTarget != nil { + in, out := &in.MemoryTarget, &out.MemoryTarget + x := (*in).DeepCopy() + *out = &x + } + if in.ExtractContent != nil { + in, out := &in.ExtractContent, &out.ExtractContent + *out = new(ExtractContentConfig) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GrpcPodConfig. +func (in *GrpcPodConfig) DeepCopy() *GrpcPodConfig { + if in == nil { + return nil + } + out := new(GrpcPodConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Icon) DeepCopyInto(out *Icon) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Icon. +func (in *Icon) DeepCopy() *Icon { + if in == nil { + return nil + } + out := new(Icon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallMode) DeepCopyInto(out *InstallMode) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallMode. +func (in *InstallMode) DeepCopy() *InstallMode { + if in == nil { + return nil + } + out := new(InstallMode) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in InstallModeSet) DeepCopyInto(out *InstallModeSet) { + { + in := &in + *out = make(InstallModeSet, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallModeSet. +func (in InstallModeSet) DeepCopy() InstallModeSet { + if in == nil { + return nil + } + out := new(InstallModeSet) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlan) DeepCopyInto(out *InstallPlan) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlan. +func (in *InstallPlan) DeepCopy() *InstallPlan { + if in == nil { + return nil + } + out := new(InstallPlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstallPlan) 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 *InstallPlanCondition) DeepCopyInto(out *InstallPlanCondition) { + *out = *in + if in.LastUpdateTime != nil { + in, out := &in.LastUpdateTime, &out.LastUpdateTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanCondition. +func (in *InstallPlanCondition) DeepCopy() *InstallPlanCondition { + if in == nil { + return nil + } + out := new(InstallPlanCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanList) DeepCopyInto(out *InstallPlanList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]InstallPlan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanList. +func (in *InstallPlanList) DeepCopy() *InstallPlanList { + if in == nil { + return nil + } + out := new(InstallPlanList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstallPlanList) 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 *InstallPlanReference) DeepCopyInto(out *InstallPlanReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanReference. +func (in *InstallPlanReference) DeepCopy() *InstallPlanReference { + if in == nil { + return nil + } + out := new(InstallPlanReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanSpec) DeepCopyInto(out *InstallPlanSpec) { + *out = *in + if in.ClusterServiceVersionNames != nil { + in, out := &in.ClusterServiceVersionNames, &out.ClusterServiceVersionNames + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanSpec. +func (in *InstallPlanSpec) DeepCopy() *InstallPlanSpec { + if in == nil { + return nil + } + out := new(InstallPlanSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstallPlanStatus) DeepCopyInto(out *InstallPlanStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]InstallPlanCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CatalogSources != nil { + in, out := &in.CatalogSources, &out.CatalogSources + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Plan != nil { + in, out := &in.Plan, &out.Plan + *out = make([]*Step, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Step) + **out = **in + } + } + } + if in.BundleLookups != nil { + in, out := &in.BundleLookups, &out.BundleLookups + *out = make([]BundleLookup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.AttenuatedServiceAccountRef != nil { + in, out := &in.AttenuatedServiceAccountRef, &out.AttenuatedServiceAccountRef + *out = new(v1.ObjectReference) + **out = **in + } + if in.StartTime != nil { + in, out := &in.StartTime, &out.StartTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstallPlanStatus. +func (in *InstallPlanStatus) DeepCopy() *InstallPlanStatus { + if in == nil { + return nil + } + out := new(InstallPlanStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Maintainer) DeepCopyInto(out *Maintainer) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Maintainer. +func (in *Maintainer) DeepCopy() *Maintainer { + if in == nil { + return nil + } + out := new(Maintainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NamedInstallStrategy) DeepCopyInto(out *NamedInstallStrategy) { + *out = *in + in.StrategySpec.DeepCopyInto(&out.StrategySpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamedInstallStrategy. +func (in *NamedInstallStrategy) DeepCopy() *NamedInstallStrategy { + if in == nil { + return nil + } + out := new(NamedInstallStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistryPoll) DeepCopyInto(out *RegistryPoll) { + *out = *in + if in.Interval != nil { + in, out := &in.Interval, &out.Interval + *out = new(metav1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryPoll. +func (in *RegistryPoll) DeepCopy() *RegistryPoll { + if in == nil { + return nil + } + out := new(RegistryPoll) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistryServiceStatus) DeepCopyInto(out *RegistryServiceStatus) { + *out = *in + in.CreatedAt.DeepCopyInto(&out.CreatedAt) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryServiceStatus. +func (in *RegistryServiceStatus) DeepCopy() *RegistryServiceStatus { + if in == nil { + return nil + } + out := new(RegistryServiceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RelatedImage) DeepCopyInto(out *RelatedImage) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelatedImage. +func (in *RelatedImage) DeepCopy() *RelatedImage { + if in == nil { + return nil + } + out := new(RelatedImage) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RequirementStatus) DeepCopyInto(out *RequirementStatus) { + *out = *in + if in.Dependents != nil { + in, out := &in.Dependents, &out.Dependents + *out = make([]DependentStatus, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RequirementStatus. +func (in *RequirementStatus) DeepCopy() *RequirementStatus { + if in == nil { + return nil + } + out := new(RequirementStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceInstance) DeepCopyInto(out *ResourceInstance) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceInstance. +func (in *ResourceInstance) DeepCopy() *ResourceInstance { + if in == nil { + return nil + } + out := new(ResourceInstance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceList) DeepCopyInto(out *ResourceList) { + *out = *in + if in.Instances != nil { + in, out := &in.Instances, &out.Instances + *out = make([]ResourceInstance, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceList. +func (in *ResourceList) DeepCopy() *ResourceList { + if in == nil { + return nil + } + out := new(ResourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SpecDescriptor) DeepCopyInto(out *SpecDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpecDescriptor. +func (in *SpecDescriptor) DeepCopy() *SpecDescriptor { + if in == nil { + return nil + } + out := new(SpecDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatusDescriptor) DeepCopyInto(out *StatusDescriptor) { + *out = *in + if in.XDescriptors != nil { + in, out := &in.XDescriptors, &out.XDescriptors + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Value != nil { + in, out := &in.Value, &out.Value + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusDescriptor. +func (in *StatusDescriptor) DeepCopy() *StatusDescriptor { + if in == nil { + return nil + } + out := new(StatusDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Step) DeepCopyInto(out *Step) { + *out = *in + out.Resource = in.Resource +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Step. +func (in *Step) DeepCopy() *Step { + if in == nil { + return nil + } + out := new(Step) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StepResource) DeepCopyInto(out *StepResource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepResource. +func (in *StepResource) DeepCopy() *StepResource { + if in == nil { + return nil + } + out := new(StepResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StrategyDeploymentPermissions) DeepCopyInto(out *StrategyDeploymentPermissions) { + *out = *in + if in.Rules != nil { + in, out := &in.Rules, &out.Rules + *out = make([]rbacv1.PolicyRule, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StrategyDeploymentPermissions. +func (in *StrategyDeploymentPermissions) DeepCopy() *StrategyDeploymentPermissions { + if in == nil { + return nil + } + out := new(StrategyDeploymentPermissions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StrategyDeploymentSpec) DeepCopyInto(out *StrategyDeploymentSpec) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) + if in.Label != nil { + in, out := &in.Label, &out.Label + *out = make(labels.Set, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StrategyDeploymentSpec. +func (in *StrategyDeploymentSpec) DeepCopy() *StrategyDeploymentSpec { + if in == nil { + return nil + } + out := new(StrategyDeploymentSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StrategyDetailsDeployment) DeepCopyInto(out *StrategyDetailsDeployment) { + *out = *in + if in.DeploymentSpecs != nil { + in, out := &in.DeploymentSpecs, &out.DeploymentSpecs + *out = make([]StrategyDeploymentSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Permissions != nil { + in, out := &in.Permissions, &out.Permissions + *out = make([]StrategyDeploymentPermissions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ClusterPermissions != nil { + in, out := &in.ClusterPermissions, &out.ClusterPermissions + *out = make([]StrategyDeploymentPermissions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StrategyDetailsDeployment. +func (in *StrategyDetailsDeployment) DeepCopy() *StrategyDetailsDeployment { + if in == nil { + return nil + } + out := new(StrategyDetailsDeployment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Subscription) DeepCopyInto(out *Subscription) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Spec != nil { + in, out := &in.Spec, &out.Spec + *out = new(SubscriptionSpec) + (*in).DeepCopyInto(*out) + } + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription. +func (in *Subscription) DeepCopy() *Subscription { + if in == nil { + return nil + } + out := new(Subscription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Subscription) 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 *SubscriptionCatalogHealth) DeepCopyInto(out *SubscriptionCatalogHealth) { + *out = *in + if in.CatalogSourceRef != nil { + in, out := &in.CatalogSourceRef, &out.CatalogSourceRef + *out = new(v1.ObjectReference) + **out = **in + } + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCatalogHealth. +func (in *SubscriptionCatalogHealth) DeepCopy() *SubscriptionCatalogHealth { + if in == nil { + return nil + } + out := new(SubscriptionCatalogHealth) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionCondition) DeepCopyInto(out *SubscriptionCondition) { + *out = *in + if in.LastHeartbeatTime != nil { + in, out := &in.LastHeartbeatTime, &out.LastHeartbeatTime + *out = (*in).DeepCopy() + } + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCondition. +func (in *SubscriptionCondition) DeepCopy() *SubscriptionCondition { + if in == nil { + return nil + } + out := new(SubscriptionCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionConfig) DeepCopyInto(out *SubscriptionConfig) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.EnvFrom != nil { + in, out := &in.EnvFrom, &out.EnvFrom + *out = make([]v1.EnvFromSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Volumes != nil { + in, out := &in.Volumes, &out.Volumes + *out = make([]v1.Volume, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.VolumeMounts != nil { + in, out := &in.VolumeMounts, &out.VolumeMounts + *out = make([]v1.VolumeMount, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionConfig. +func (in *SubscriptionConfig) DeepCopy() *SubscriptionConfig { + if in == nil { + return nil + } + out := new(SubscriptionConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Subscription, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList. +func (in *SubscriptionList) DeepCopy() *SubscriptionList { + if in == nil { + return nil + } + out := new(SubscriptionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SubscriptionList) 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 *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { + *out = *in + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = new(SubscriptionConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionSpec. +func (in *SubscriptionSpec) DeepCopy() *SubscriptionSpec { + if in == nil { + return nil + } + out := new(SubscriptionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { + *out = *in + if in.Install != nil { + in, out := &in.Install, &out.Install + *out = new(InstallPlanReference) + **out = **in + } + if in.InstallPlanRef != nil { + in, out := &in.InstallPlanRef, &out.InstallPlanRef + *out = new(v1.ObjectReference) + **out = **in + } + if in.CatalogHealth != nil { + in, out := &in.CatalogHealth, &out.CatalogHealth + *out = make([]SubscriptionCatalogHealth, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]SubscriptionCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.LastUpdated.DeepCopyInto(&out.LastUpdated) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionStatus. +func (in *SubscriptionStatus) DeepCopy() *SubscriptionStatus { + if in == nil { + return nil + } + out := new(SubscriptionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpdateStrategy) DeepCopyInto(out *UpdateStrategy) { + *out = *in + if in.RegistryPoll != nil { + in, out := &in.RegistryPoll, &out.RegistryPoll + *out = new(RegistryPoll) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateStrategy. +func (in *UpdateStrategy) DeepCopy() *UpdateStrategy { + if in == nil { + return nil + } + out := new(UpdateStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebhookDescription) DeepCopyInto(out *WebhookDescription) { + *out = *in + if in.TargetPort != nil { + in, out := &in.TargetPort, &out.TargetPort + *out = new(intstr.IntOrString) + **out = **in + } + if in.Rules != nil { + in, out := &in.Rules, &out.Rules + *out = make([]admissionregistrationv1.RuleWithOperations, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.FailurePolicy != nil { + in, out := &in.FailurePolicy, &out.FailurePolicy + *out = new(admissionregistrationv1.FailurePolicyType) + **out = **in + } + if in.MatchPolicy != nil { + in, out := &in.MatchPolicy, &out.MatchPolicy + *out = new(admissionregistrationv1.MatchPolicyType) + **out = **in + } + if in.ObjectSelector != nil { + in, out := &in.ObjectSelector, &out.ObjectSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.SideEffects != nil { + in, out := &in.SideEffects, &out.SideEffects + *out = new(admissionregistrationv1.SideEffectClass) + **out = **in + } + if in.TimeoutSeconds != nil { + in, out := &in.TimeoutSeconds, &out.TimeoutSeconds + *out = new(int32) + **out = **in + } + if in.AdmissionReviewVersions != nil { + in, out := &in.AdmissionReviewVersions, &out.AdmissionReviewVersions + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ReinvocationPolicy != nil { + in, out := &in.ReinvocationPolicy, &out.ReinvocationPolicy + *out = new(admissionregistrationv1.ReinvocationPolicyType) + **out = **in + } + if in.WebhookPath != nil { + in, out := &in.WebhookPath, &out.WebhookPath + *out = new(string) + **out = **in + } + if in.ConversionCRDs != nil { + in, out := &in.ConversionCRDs, &out.ConversionCRDs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookDescription. +func (in *WebhookDescription) DeepCopy() *WebhookDescription { + if in == nil { + return nil + } + out := new(WebhookDescription) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/doc.go new file mode 100644 index 000000000..b5f420c28 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/doc.go @@ -0,0 +1,5 @@ +// +k8s:deepcopy-gen=package + +// Package operators is the internal version of the API. +// +groupName=operators.coreos.com +package operators diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go new file mode 100644 index 000000000..f35e41967 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/packagemanifest_types.go @@ -0,0 +1,155 @@ +package operators + +import ( + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version" + operatorv1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PackageManifestList is a list of PackageManifest objects. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PackageManifestList struct { + metav1.TypeMeta + metav1.ListMeta + // +listType=set + Items []PackageManifest +} + +// PackageManifest holds information about a package, which is a reference to one (or more) +// channels under a single package. +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PackageManifest struct { + metav1.TypeMeta + metav1.ObjectMeta + + Spec PackageManifestSpec + Status PackageManifestStatus +} + +// PackageManifestSpec defines the desired state of PackageManifest +type PackageManifestSpec struct{} + +// PackageManifestStatus represents the current status of the PackageManifest +type PackageManifestStatus struct { + // CatalogSource is the name of the CatalogSource this package belongs to + CatalogSource string + CatalogSourceDisplayName string + CatalogSourcePublisher string + + // CatalogSourceNamespace is the namespace of the owning CatalogSource + CatalogSourceNamespace string + + // Provider is the provider of the PackageManifest's default CSV + Provider AppLink + + // PackageName is the name of the overall package, ala . + PackageName string + + // Channels are the declared channels for the package, ala . + // +listType=set + Channels []PackageChannel + + // DefaultChannel is, if specified, the name of the default channel for the package. The + // default channel will be installed if no other channel is explicitly given. If the package + // has a single channel, then that channel is implicitly the default. + DefaultChannel string +} + +// GetDefaultChannel gets the default channel or returns the only one if there's only one. returns empty string if it +// can't determine the default +func (m PackageManifest) GetDefaultChannel() string { + if m.Status.DefaultChannel != "" { + return m.Status.DefaultChannel + } + if len(m.Status.Channels) == 1 { + return m.Status.Channels[0].Name + } + return "" +} + +// PackageChannel defines a single channel under a package, pointing to a version of that +// package. +type PackageChannel struct { + // Name is the name of the channel, e.g. + Name string + + // CurrentCSV defines a reference to the CSV holding the version of this package currently + // for the channel. + CurrentCSV string + + // CurrentCSVSpec holds the spec of the current CSV + CurrentCSVDesc CSVDescription + + // Entries lists all CSVs in the channel. + Entries []ChannelEntry +} + +// ChannelEntry defines a member of a package channel. +type ChannelEntry struct { + // Name is the name of the bundle for this entry. + Name string + + // Version is the version of the bundle for this entry. + Version string +} + +// CSVDescription defines a description of a CSV +type CSVDescription struct { + // DisplayName is the CSV's display name + DisplayName string + + // Icon is the CSV's base64 encoded icon + // +listType=set + Icon []Icon + + // Version is the CSV's semantic version + Version version.OperatorVersion + + // Provider is the CSV's provider + Provider AppLink + Annotations map[string]string + Keywords []string + Links []AppLink + Maintainers []Maintainer + Maturity string + + // LongDescription is the CSV's description + LongDescription string + + // InstallModes specify supported installation types + InstallModes []operatorv1alpha1.InstallMode + + CustomResourceDefinitions operatorv1alpha1.CustomResourceDefinitions + APIServiceDefinitions operatorv1alpha1.APIServiceDefinitions + NativeAPIs []metav1.GroupVersionKind `json:"nativeApis,omitempty"` + + // Minimum Kubernetes version for operator installation + MinKubeVersion string `json:"minKubeVersion,omitempty"` + + // List of related images + RelatedImages []string `json:"relatedImages,omitempty"` +} + +// AppLink defines a link to an application +type AppLink struct { + Name string + URL string +} + +// Maintainer defines a project maintainer +type Maintainer struct { + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` +} + +// Icon defines a base64 encoded icon and media type +type Icon struct { + Base64Data string + Mediatype string +} + +// IsDefaultChannel returns true if the PackageChannel is the default for the PackageManifest +func (pc PackageChannel) IsDefaultChannel(pm PackageManifest) bool { + return pc.Name == pm.Status.DefaultChannel || len(pm.Status.Channels) == 1 +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/register.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/register.go new file mode 100644 index 000000000..d8e29880a --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/register.go @@ -0,0 +1,36 @@ +package operators + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + Group = "packages.operators.coreos.com" + + // SchemeGroupVersion is the GroupVersion used to register this object + SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: runtime.APIVersionInternal} + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Kind takes an unqualified kind and returns the group-qualified kind. +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns the group-qualified resource. +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + // Add types for each GroupVersion + scheme.AddKnownTypes(SchemeGroupVersion, + &PackageManifest{}, + &PackageManifestList{}, + ) + + return nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/doc.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/doc.go new file mode 100644 index 000000000..69520a640 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/doc.go @@ -0,0 +1,7 @@ +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apis/operators +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +groupName=operators.coreos.com +package v1 diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go new file mode 100644 index 000000000..ab5ce10c6 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/packagemanifest_types.go @@ -0,0 +1,160 @@ +package v1 + +import ( + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version" + operatorv1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// PackageManifestList is a list of PackageManifest objects. +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PackageManifestList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // +listType=set + Items []PackageManifest `json:"items"` +} + +// PackageManifest holds information about a package, which is a reference to one (or more) +// channels under a single package. +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type PackageManifest struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PackageManifestSpec `json:"spec,omitempty"` + Status PackageManifestStatus `json:"status,omitempty"` +} + +// PackageManifestSpec defines the desired state of PackageManifest +type PackageManifestSpec struct{} + +// PackageManifestStatus represents the current status of the PackageManifest +type PackageManifestStatus struct { + // CatalogSource is the name of the CatalogSource this package belongs to + CatalogSource string `json:"catalogSource"` + CatalogSourceDisplayName string `json:"catalogSourceDisplayName"` + CatalogSourcePublisher string `json:"catalogSourcePublisher"` + + // CatalogSourceNamespace is the namespace of the owning CatalogSource + CatalogSourceNamespace string `json:"catalogSourceNamespace"` + + // Provider is the provider of the PackageManifest's default CSV + Provider AppLink `json:"provider,omitempty"` + + // PackageName is the name of the overall package, ala `etcd`. + PackageName string `json:"packageName"` + + // Channels are the declared channels for the package, ala `stable` or `alpha`. + // +listType=set + Channels []PackageChannel `json:"channels"` + + // DefaultChannel is, if specified, the name of the default channel for the package. The + // default channel will be installed if no other channel is explicitly given. If the package + // has a single channel, then that channel is implicitly the default. + DefaultChannel string `json:"defaultChannel"` +} + +// GetDefaultChannel gets the default channel or returns the only one if there's only one. returns empty string if it +// can't determine the default +func (m PackageManifest) GetDefaultChannel() string { + if m.Status.DefaultChannel != "" { + return m.Status.DefaultChannel + } + if len(m.Status.Channels) == 1 { + return m.Status.Channels[0].Name + } + return "" +} + +// PackageChannel defines a single channel under a package, pointing to a version of that +// package. +type PackageChannel struct { + // Name is the name of the channel, e.g. `alpha` or `stable` + Name string `json:"name"` + + // CurrentCSV defines a reference to the CSV holding the version of this package currently + // for the channel. + CurrentCSV string `json:"currentCSV"` + + // CurrentCSVSpec holds the spec of the current CSV + CurrentCSVDesc CSVDescription `json:"currentCSVDesc,omitempty"` + + // Entries lists all CSVs in the channel, with their upgrade edges. + Entries []ChannelEntry `json:"entries"` +} + +// ChannelEntry defines a member of a package channel. +type ChannelEntry struct { + // Name is the name of the bundle for this entry. + Name string `json:"name"` + + // Version is the version of the bundle for this entry. + Version string `json:"version,omitempty"` +} + +// CSVDescription defines a description of a CSV +type CSVDescription struct { + // DisplayName is the CSV's display name + DisplayName string `json:"displayName,omitempty"` + + // Icon is the CSV's base64 encoded icon + // +listType=set + Icon []Icon `json:"icon,omitempty"` + + // Version is the CSV's semantic version + Version version.OperatorVersion `json:"version,omitempty"` + + // Provider is the CSV's provider + Provider AppLink `json:"provider,omitempty"` + // +listType=map + Annotations map[string]string `json:"annotations,omitempty"` + // +listType=set + Keywords []string `json:"keywords,omitempty"` + // +listType=set + Links []AppLink `json:"links,omitempty"` + // +listType=set + Maintainers []Maintainer `json:"maintainers,omitempty"` + Maturity string `json:"maturity,omitempty"` + + // LongDescription is the CSV's description + LongDescription string `json:"description,omitempty"` + + // InstallModes specify supported installation types + // +listType=set + InstallModes []operatorv1alpha1.InstallMode `json:"installModes,omitempty"` + + CustomResourceDefinitions operatorv1alpha1.CustomResourceDefinitions `json:"customresourcedefinitions,omitempty"` + APIServiceDefinitions operatorv1alpha1.APIServiceDefinitions `json:"apiservicedefinitions,omitempty"` + NativeAPIs []metav1.GroupVersionKind `json:"nativeApis,omitempty"` + + // Minimum Kubernetes version for operator installation + MinKubeVersion string `json:"minKubeVersion,omitempty"` + + // List of related images + RelatedImages []string `json:"relatedImages,omitempty"` +} + +// AppLink defines a link to an application +type AppLink struct { + Name string `json:"name,omitempty"` + URL string `json:"url,omitempty"` +} + +// Maintainer defines a project maintainer +type Maintainer struct { + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` +} + +// Icon defines a base64 encoded icon and media type +type Icon struct { + Base64Data string `json:"base64data,omitempty"` + Mediatype string `json:"mediatype,omitempty"` +} + +// IsDefaultChannel returns true if the PackageChannel is the default for the PackageManifest +func (pc PackageChannel) IsDefaultChannel(pm PackageManifest) bool { + return pc.Name == pm.Status.DefaultChannel || len(pm.Status.Channels) == 1 +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go new file mode 100644 index 000000000..9b9a26dee --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/register.go @@ -0,0 +1,45 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators" +) + +const ( + Group = "packages." + operators.GroupName + Version = "v1" + PackageManifestKind = "PackageManifest" + PackageManifestListKind = "PackageManifestList" +) + +// SchemeGroupVersion is the group version used to register these objects. +var SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + localSchemeBuilder = &SchemeBuilder + AddToScheme = localSchemeBuilder.AddToScheme +) + +// Resource takes an unqualified resource and returns a Group-qualified GroupResource. +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypeWithName( + SchemeGroupVersion.WithKind(PackageManifestKind), + &PackageManifest{}, + ) + scheme.AddKnownTypeWithName( + SchemeGroupVersion.WithKind(PackageManifestListKind), + &PackageManifestList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + + return nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go new file mode 100644 index 000000000..a3a631b16 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.conversion.go @@ -0,0 +1,424 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright Red Hat, Inc. + +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 conversion-gen. DO NOT EDIT. + +package v1 + +import ( + unsafe "unsafe" + + v1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + operators "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*AppLink)(nil), (*operators.AppLink)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_AppLink_To_operators_AppLink(a.(*AppLink), b.(*operators.AppLink), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.AppLink)(nil), (*AppLink)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_AppLink_To_v1_AppLink(a.(*operators.AppLink), b.(*AppLink), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*CSVDescription)(nil), (*operators.CSVDescription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_CSVDescription_To_operators_CSVDescription(a.(*CSVDescription), b.(*operators.CSVDescription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.CSVDescription)(nil), (*CSVDescription)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_CSVDescription_To_v1_CSVDescription(a.(*operators.CSVDescription), b.(*CSVDescription), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ChannelEntry)(nil), (*operators.ChannelEntry)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_ChannelEntry_To_operators_ChannelEntry(a.(*ChannelEntry), b.(*operators.ChannelEntry), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.ChannelEntry)(nil), (*ChannelEntry)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_ChannelEntry_To_v1_ChannelEntry(a.(*operators.ChannelEntry), b.(*ChannelEntry), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Icon)(nil), (*operators.Icon)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Icon_To_operators_Icon(a.(*Icon), b.(*operators.Icon), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.Icon)(nil), (*Icon)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_Icon_To_v1_Icon(a.(*operators.Icon), b.(*Icon), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Maintainer)(nil), (*operators.Maintainer)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Maintainer_To_operators_Maintainer(a.(*Maintainer), b.(*operators.Maintainer), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.Maintainer)(nil), (*Maintainer)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_Maintainer_To_v1_Maintainer(a.(*operators.Maintainer), b.(*Maintainer), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PackageChannel)(nil), (*operators.PackageChannel)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_PackageChannel_To_operators_PackageChannel(a.(*PackageChannel), b.(*operators.PackageChannel), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.PackageChannel)(nil), (*PackageChannel)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_PackageChannel_To_v1_PackageChannel(a.(*operators.PackageChannel), b.(*PackageChannel), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PackageManifest)(nil), (*operators.PackageManifest)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_PackageManifest_To_operators_PackageManifest(a.(*PackageManifest), b.(*operators.PackageManifest), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.PackageManifest)(nil), (*PackageManifest)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_PackageManifest_To_v1_PackageManifest(a.(*operators.PackageManifest), b.(*PackageManifest), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PackageManifestList)(nil), (*operators.PackageManifestList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_PackageManifestList_To_operators_PackageManifestList(a.(*PackageManifestList), b.(*operators.PackageManifestList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.PackageManifestList)(nil), (*PackageManifestList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_PackageManifestList_To_v1_PackageManifestList(a.(*operators.PackageManifestList), b.(*PackageManifestList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PackageManifestSpec)(nil), (*operators.PackageManifestSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_PackageManifestSpec_To_operators_PackageManifestSpec(a.(*PackageManifestSpec), b.(*operators.PackageManifestSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.PackageManifestSpec)(nil), (*PackageManifestSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_PackageManifestSpec_To_v1_PackageManifestSpec(a.(*operators.PackageManifestSpec), b.(*PackageManifestSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*PackageManifestStatus)(nil), (*operators.PackageManifestStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_PackageManifestStatus_To_operators_PackageManifestStatus(a.(*PackageManifestStatus), b.(*operators.PackageManifestStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*operators.PackageManifestStatus)(nil), (*PackageManifestStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_operators_PackageManifestStatus_To_v1_PackageManifestStatus(a.(*operators.PackageManifestStatus), b.(*PackageManifestStatus), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1_AppLink_To_operators_AppLink(in *AppLink, out *operators.AppLink, s conversion.Scope) error { + out.Name = in.Name + out.URL = in.URL + return nil +} + +// Convert_v1_AppLink_To_operators_AppLink is an autogenerated conversion function. +func Convert_v1_AppLink_To_operators_AppLink(in *AppLink, out *operators.AppLink, s conversion.Scope) error { + return autoConvert_v1_AppLink_To_operators_AppLink(in, out, s) +} + +func autoConvert_operators_AppLink_To_v1_AppLink(in *operators.AppLink, out *AppLink, s conversion.Scope) error { + out.Name = in.Name + out.URL = in.URL + return nil +} + +// Convert_operators_AppLink_To_v1_AppLink is an autogenerated conversion function. +func Convert_operators_AppLink_To_v1_AppLink(in *operators.AppLink, out *AppLink, s conversion.Scope) error { + return autoConvert_operators_AppLink_To_v1_AppLink(in, out, s) +} + +func autoConvert_v1_CSVDescription_To_operators_CSVDescription(in *CSVDescription, out *operators.CSVDescription, s conversion.Scope) error { + out.DisplayName = in.DisplayName + out.Icon = *(*[]operators.Icon)(unsafe.Pointer(&in.Icon)) + out.Version = in.Version + if err := Convert_v1_AppLink_To_operators_AppLink(&in.Provider, &out.Provider, s); err != nil { + return err + } + out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations)) + out.Keywords = *(*[]string)(unsafe.Pointer(&in.Keywords)) + out.Links = *(*[]operators.AppLink)(unsafe.Pointer(&in.Links)) + out.Maintainers = *(*[]operators.Maintainer)(unsafe.Pointer(&in.Maintainers)) + out.Maturity = in.Maturity + out.LongDescription = in.LongDescription + out.InstallModes = *(*[]v1alpha1.InstallMode)(unsafe.Pointer(&in.InstallModes)) + out.CustomResourceDefinitions = in.CustomResourceDefinitions + out.APIServiceDefinitions = in.APIServiceDefinitions + out.NativeAPIs = *(*[]metav1.GroupVersionKind)(unsafe.Pointer(&in.NativeAPIs)) + out.MinKubeVersion = in.MinKubeVersion + out.RelatedImages = *(*[]string)(unsafe.Pointer(&in.RelatedImages)) + return nil +} + +// Convert_v1_CSVDescription_To_operators_CSVDescription is an autogenerated conversion function. +func Convert_v1_CSVDescription_To_operators_CSVDescription(in *CSVDescription, out *operators.CSVDescription, s conversion.Scope) error { + return autoConvert_v1_CSVDescription_To_operators_CSVDescription(in, out, s) +} + +func autoConvert_operators_CSVDescription_To_v1_CSVDescription(in *operators.CSVDescription, out *CSVDescription, s conversion.Scope) error { + out.DisplayName = in.DisplayName + out.Icon = *(*[]Icon)(unsafe.Pointer(&in.Icon)) + out.Version = in.Version + if err := Convert_operators_AppLink_To_v1_AppLink(&in.Provider, &out.Provider, s); err != nil { + return err + } + out.Annotations = *(*map[string]string)(unsafe.Pointer(&in.Annotations)) + out.Keywords = *(*[]string)(unsafe.Pointer(&in.Keywords)) + out.Links = *(*[]AppLink)(unsafe.Pointer(&in.Links)) + out.Maintainers = *(*[]Maintainer)(unsafe.Pointer(&in.Maintainers)) + out.Maturity = in.Maturity + out.LongDescription = in.LongDescription + out.InstallModes = *(*[]v1alpha1.InstallMode)(unsafe.Pointer(&in.InstallModes)) + out.CustomResourceDefinitions = in.CustomResourceDefinitions + out.APIServiceDefinitions = in.APIServiceDefinitions + out.NativeAPIs = *(*[]metav1.GroupVersionKind)(unsafe.Pointer(&in.NativeAPIs)) + out.MinKubeVersion = in.MinKubeVersion + out.RelatedImages = *(*[]string)(unsafe.Pointer(&in.RelatedImages)) + return nil +} + +// Convert_operators_CSVDescription_To_v1_CSVDescription is an autogenerated conversion function. +func Convert_operators_CSVDescription_To_v1_CSVDescription(in *operators.CSVDescription, out *CSVDescription, s conversion.Scope) error { + return autoConvert_operators_CSVDescription_To_v1_CSVDescription(in, out, s) +} + +func autoConvert_v1_ChannelEntry_To_operators_ChannelEntry(in *ChannelEntry, out *operators.ChannelEntry, s conversion.Scope) error { + out.Name = in.Name + out.Version = in.Version + return nil +} + +// Convert_v1_ChannelEntry_To_operators_ChannelEntry is an autogenerated conversion function. +func Convert_v1_ChannelEntry_To_operators_ChannelEntry(in *ChannelEntry, out *operators.ChannelEntry, s conversion.Scope) error { + return autoConvert_v1_ChannelEntry_To_operators_ChannelEntry(in, out, s) +} + +func autoConvert_operators_ChannelEntry_To_v1_ChannelEntry(in *operators.ChannelEntry, out *ChannelEntry, s conversion.Scope) error { + out.Name = in.Name + out.Version = in.Version + return nil +} + +// Convert_operators_ChannelEntry_To_v1_ChannelEntry is an autogenerated conversion function. +func Convert_operators_ChannelEntry_To_v1_ChannelEntry(in *operators.ChannelEntry, out *ChannelEntry, s conversion.Scope) error { + return autoConvert_operators_ChannelEntry_To_v1_ChannelEntry(in, out, s) +} + +func autoConvert_v1_Icon_To_operators_Icon(in *Icon, out *operators.Icon, s conversion.Scope) error { + out.Base64Data = in.Base64Data + out.Mediatype = in.Mediatype + return nil +} + +// Convert_v1_Icon_To_operators_Icon is an autogenerated conversion function. +func Convert_v1_Icon_To_operators_Icon(in *Icon, out *operators.Icon, s conversion.Scope) error { + return autoConvert_v1_Icon_To_operators_Icon(in, out, s) +} + +func autoConvert_operators_Icon_To_v1_Icon(in *operators.Icon, out *Icon, s conversion.Scope) error { + out.Base64Data = in.Base64Data + out.Mediatype = in.Mediatype + return nil +} + +// Convert_operators_Icon_To_v1_Icon is an autogenerated conversion function. +func Convert_operators_Icon_To_v1_Icon(in *operators.Icon, out *Icon, s conversion.Scope) error { + return autoConvert_operators_Icon_To_v1_Icon(in, out, s) +} + +func autoConvert_v1_Maintainer_To_operators_Maintainer(in *Maintainer, out *operators.Maintainer, s conversion.Scope) error { + out.Name = in.Name + out.Email = in.Email + return nil +} + +// Convert_v1_Maintainer_To_operators_Maintainer is an autogenerated conversion function. +func Convert_v1_Maintainer_To_operators_Maintainer(in *Maintainer, out *operators.Maintainer, s conversion.Scope) error { + return autoConvert_v1_Maintainer_To_operators_Maintainer(in, out, s) +} + +func autoConvert_operators_Maintainer_To_v1_Maintainer(in *operators.Maintainer, out *Maintainer, s conversion.Scope) error { + out.Name = in.Name + out.Email = in.Email + return nil +} + +// Convert_operators_Maintainer_To_v1_Maintainer is an autogenerated conversion function. +func Convert_operators_Maintainer_To_v1_Maintainer(in *operators.Maintainer, out *Maintainer, s conversion.Scope) error { + return autoConvert_operators_Maintainer_To_v1_Maintainer(in, out, s) +} + +func autoConvert_v1_PackageChannel_To_operators_PackageChannel(in *PackageChannel, out *operators.PackageChannel, s conversion.Scope) error { + out.Name = in.Name + out.CurrentCSV = in.CurrentCSV + if err := Convert_v1_CSVDescription_To_operators_CSVDescription(&in.CurrentCSVDesc, &out.CurrentCSVDesc, s); err != nil { + return err + } + out.Entries = *(*[]operators.ChannelEntry)(unsafe.Pointer(&in.Entries)) + return nil +} + +// Convert_v1_PackageChannel_To_operators_PackageChannel is an autogenerated conversion function. +func Convert_v1_PackageChannel_To_operators_PackageChannel(in *PackageChannel, out *operators.PackageChannel, s conversion.Scope) error { + return autoConvert_v1_PackageChannel_To_operators_PackageChannel(in, out, s) +} + +func autoConvert_operators_PackageChannel_To_v1_PackageChannel(in *operators.PackageChannel, out *PackageChannel, s conversion.Scope) error { + out.Name = in.Name + out.CurrentCSV = in.CurrentCSV + if err := Convert_operators_CSVDescription_To_v1_CSVDescription(&in.CurrentCSVDesc, &out.CurrentCSVDesc, s); err != nil { + return err + } + out.Entries = *(*[]ChannelEntry)(unsafe.Pointer(&in.Entries)) + return nil +} + +// Convert_operators_PackageChannel_To_v1_PackageChannel is an autogenerated conversion function. +func Convert_operators_PackageChannel_To_v1_PackageChannel(in *operators.PackageChannel, out *PackageChannel, s conversion.Scope) error { + return autoConvert_operators_PackageChannel_To_v1_PackageChannel(in, out, s) +} + +func autoConvert_v1_PackageManifest_To_operators_PackageManifest(in *PackageManifest, out *operators.PackageManifest, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1_PackageManifestSpec_To_operators_PackageManifestSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1_PackageManifestStatus_To_operators_PackageManifestStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1_PackageManifest_To_operators_PackageManifest is an autogenerated conversion function. +func Convert_v1_PackageManifest_To_operators_PackageManifest(in *PackageManifest, out *operators.PackageManifest, s conversion.Scope) error { + return autoConvert_v1_PackageManifest_To_operators_PackageManifest(in, out, s) +} + +func autoConvert_operators_PackageManifest_To_v1_PackageManifest(in *operators.PackageManifest, out *PackageManifest, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_operators_PackageManifestSpec_To_v1_PackageManifestSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_operators_PackageManifestStatus_To_v1_PackageManifestStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_operators_PackageManifest_To_v1_PackageManifest is an autogenerated conversion function. +func Convert_operators_PackageManifest_To_v1_PackageManifest(in *operators.PackageManifest, out *PackageManifest, s conversion.Scope) error { + return autoConvert_operators_PackageManifest_To_v1_PackageManifest(in, out, s) +} + +func autoConvert_v1_PackageManifestList_To_operators_PackageManifestList(in *PackageManifestList, out *operators.PackageManifestList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]operators.PackageManifest)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1_PackageManifestList_To_operators_PackageManifestList is an autogenerated conversion function. +func Convert_v1_PackageManifestList_To_operators_PackageManifestList(in *PackageManifestList, out *operators.PackageManifestList, s conversion.Scope) error { + return autoConvert_v1_PackageManifestList_To_operators_PackageManifestList(in, out, s) +} + +func autoConvert_operators_PackageManifestList_To_v1_PackageManifestList(in *operators.PackageManifestList, out *PackageManifestList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]PackageManifest)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_operators_PackageManifestList_To_v1_PackageManifestList is an autogenerated conversion function. +func Convert_operators_PackageManifestList_To_v1_PackageManifestList(in *operators.PackageManifestList, out *PackageManifestList, s conversion.Scope) error { + return autoConvert_operators_PackageManifestList_To_v1_PackageManifestList(in, out, s) +} + +func autoConvert_v1_PackageManifestSpec_To_operators_PackageManifestSpec(in *PackageManifestSpec, out *operators.PackageManifestSpec, s conversion.Scope) error { + return nil +} + +// Convert_v1_PackageManifestSpec_To_operators_PackageManifestSpec is an autogenerated conversion function. +func Convert_v1_PackageManifestSpec_To_operators_PackageManifestSpec(in *PackageManifestSpec, out *operators.PackageManifestSpec, s conversion.Scope) error { + return autoConvert_v1_PackageManifestSpec_To_operators_PackageManifestSpec(in, out, s) +} + +func autoConvert_operators_PackageManifestSpec_To_v1_PackageManifestSpec(in *operators.PackageManifestSpec, out *PackageManifestSpec, s conversion.Scope) error { + return nil +} + +// Convert_operators_PackageManifestSpec_To_v1_PackageManifestSpec is an autogenerated conversion function. +func Convert_operators_PackageManifestSpec_To_v1_PackageManifestSpec(in *operators.PackageManifestSpec, out *PackageManifestSpec, s conversion.Scope) error { + return autoConvert_operators_PackageManifestSpec_To_v1_PackageManifestSpec(in, out, s) +} + +func autoConvert_v1_PackageManifestStatus_To_operators_PackageManifestStatus(in *PackageManifestStatus, out *operators.PackageManifestStatus, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceDisplayName = in.CatalogSourceDisplayName + out.CatalogSourcePublisher = in.CatalogSourcePublisher + out.CatalogSourceNamespace = in.CatalogSourceNamespace + if err := Convert_v1_AppLink_To_operators_AppLink(&in.Provider, &out.Provider, s); err != nil { + return err + } + out.PackageName = in.PackageName + out.Channels = *(*[]operators.PackageChannel)(unsafe.Pointer(&in.Channels)) + out.DefaultChannel = in.DefaultChannel + return nil +} + +// Convert_v1_PackageManifestStatus_To_operators_PackageManifestStatus is an autogenerated conversion function. +func Convert_v1_PackageManifestStatus_To_operators_PackageManifestStatus(in *PackageManifestStatus, out *operators.PackageManifestStatus, s conversion.Scope) error { + return autoConvert_v1_PackageManifestStatus_To_operators_PackageManifestStatus(in, out, s) +} + +func autoConvert_operators_PackageManifestStatus_To_v1_PackageManifestStatus(in *operators.PackageManifestStatus, out *PackageManifestStatus, s conversion.Scope) error { + out.CatalogSource = in.CatalogSource + out.CatalogSourceDisplayName = in.CatalogSourceDisplayName + out.CatalogSourcePublisher = in.CatalogSourcePublisher + out.CatalogSourceNamespace = in.CatalogSourceNamespace + if err := Convert_operators_AppLink_To_v1_AppLink(&in.Provider, &out.Provider, s); err != nil { + return err + } + out.PackageName = in.PackageName + out.Channels = *(*[]PackageChannel)(unsafe.Pointer(&in.Channels)) + out.DefaultChannel = in.DefaultChannel + return nil +} + +// Convert_operators_PackageManifestStatus_To_v1_PackageManifestStatus is an autogenerated conversion function. +func Convert_operators_PackageManifestStatus_To_v1_PackageManifestStatus(in *operators.PackageManifestStatus, out *PackageManifestStatus, s conversion.Scope) error { + return autoConvert_operators_PackageManifestStatus_To_v1_PackageManifestStatus(in, out, s) +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go new file mode 100644 index 000000000..c867b5cbd --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.deepcopy.go @@ -0,0 +1,277 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright Red Hat, Inc. + +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 deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + v1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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 *AppLink) DeepCopyInto(out *AppLink) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppLink. +func (in *AppLink) DeepCopy() *AppLink { + if in == nil { + return nil + } + out := new(AppLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CSVDescription) DeepCopyInto(out *CSVDescription) { + *out = *in + if in.Icon != nil { + in, out := &in.Icon, &out.Icon + *out = make([]Icon, len(*in)) + copy(*out, *in) + } + in.Version.DeepCopyInto(&out.Version) + out.Provider = in.Provider + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Keywords != nil { + in, out := &in.Keywords, &out.Keywords + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Links != nil { + in, out := &in.Links, &out.Links + *out = make([]AppLink, len(*in)) + copy(*out, *in) + } + if in.Maintainers != nil { + in, out := &in.Maintainers, &out.Maintainers + *out = make([]Maintainer, len(*in)) + copy(*out, *in) + } + if in.InstallModes != nil { + in, out := &in.InstallModes, &out.InstallModes + *out = make([]v1alpha1.InstallMode, len(*in)) + copy(*out, *in) + } + in.CustomResourceDefinitions.DeepCopyInto(&out.CustomResourceDefinitions) + in.APIServiceDefinitions.DeepCopyInto(&out.APIServiceDefinitions) + if in.NativeAPIs != nil { + in, out := &in.NativeAPIs, &out.NativeAPIs + *out = make([]metav1.GroupVersionKind, len(*in)) + copy(*out, *in) + } + if in.RelatedImages != nil { + in, out := &in.RelatedImages, &out.RelatedImages + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSVDescription. +func (in *CSVDescription) DeepCopy() *CSVDescription { + if in == nil { + return nil + } + out := new(CSVDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChannelEntry) DeepCopyInto(out *ChannelEntry) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelEntry. +func (in *ChannelEntry) DeepCopy() *ChannelEntry { + if in == nil { + return nil + } + out := new(ChannelEntry) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Icon) DeepCopyInto(out *Icon) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Icon. +func (in *Icon) DeepCopy() *Icon { + if in == nil { + return nil + } + out := new(Icon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Maintainer) DeepCopyInto(out *Maintainer) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Maintainer. +func (in *Maintainer) DeepCopy() *Maintainer { + if in == nil { + return nil + } + out := new(Maintainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackageChannel) DeepCopyInto(out *PackageChannel) { + *out = *in + in.CurrentCSVDesc.DeepCopyInto(&out.CurrentCSVDesc) + if in.Entries != nil { + in, out := &in.Entries, &out.Entries + *out = make([]ChannelEntry, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageChannel. +func (in *PackageChannel) DeepCopy() *PackageChannel { + if in == nil { + return nil + } + out := new(PackageChannel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackageManifest) DeepCopyInto(out *PackageManifest) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifest. +func (in *PackageManifest) DeepCopy() *PackageManifest { + if in == nil { + return nil + } + out := new(PackageManifest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PackageManifest) 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 *PackageManifestList) DeepCopyInto(out *PackageManifestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PackageManifest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifestList. +func (in *PackageManifestList) DeepCopy() *PackageManifestList { + if in == nil { + return nil + } + out := new(PackageManifestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PackageManifestList) 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 *PackageManifestSpec) DeepCopyInto(out *PackageManifestSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifestSpec. +func (in *PackageManifestSpec) DeepCopy() *PackageManifestSpec { + if in == nil { + return nil + } + out := new(PackageManifestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackageManifestStatus) DeepCopyInto(out *PackageManifestStatus) { + *out = *in + out.Provider = in.Provider + if in.Channels != nil { + in, out := &in.Channels, &out.Channels + *out = make([]PackageChannel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifestStatus. +func (in *PackageManifestStatus) DeepCopy() *PackageManifestStatus { + if in == nil { + return nil + } + out := new(PackageManifestStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.defaults.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.defaults.go new file mode 100644 index 000000000..698f41d0f --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1/zz_generated.defaults.go @@ -0,0 +1,33 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright Red Hat, Inc. + +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 defaulter-gen. DO NOT EDIT. + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// RegisterDefaults adds defaulters functions to the given scheme. +// Public to allow building arbitrary schemes. +// All generated defaulters are covering - they call all nested defaulters. +func RegisterDefaults(scheme *runtime.Scheme) error { + return nil +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go new file mode 100644 index 000000000..500406b99 --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/zz_generated.deepcopy.go @@ -0,0 +1,277 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright Red Hat, Inc. + +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 deepcopy-gen. DO NOT EDIT. + +package operators + +import ( + v1alpha1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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 *AppLink) DeepCopyInto(out *AppLink) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppLink. +func (in *AppLink) DeepCopy() *AppLink { + if in == nil { + return nil + } + out := new(AppLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CSVDescription) DeepCopyInto(out *CSVDescription) { + *out = *in + if in.Icon != nil { + in, out := &in.Icon, &out.Icon + *out = make([]Icon, len(*in)) + copy(*out, *in) + } + in.Version.DeepCopyInto(&out.Version) + out.Provider = in.Provider + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Keywords != nil { + in, out := &in.Keywords, &out.Keywords + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Links != nil { + in, out := &in.Links, &out.Links + *out = make([]AppLink, len(*in)) + copy(*out, *in) + } + if in.Maintainers != nil { + in, out := &in.Maintainers, &out.Maintainers + *out = make([]Maintainer, len(*in)) + copy(*out, *in) + } + if in.InstallModes != nil { + in, out := &in.InstallModes, &out.InstallModes + *out = make([]v1alpha1.InstallMode, len(*in)) + copy(*out, *in) + } + in.CustomResourceDefinitions.DeepCopyInto(&out.CustomResourceDefinitions) + in.APIServiceDefinitions.DeepCopyInto(&out.APIServiceDefinitions) + if in.NativeAPIs != nil { + in, out := &in.NativeAPIs, &out.NativeAPIs + *out = make([]v1.GroupVersionKind, len(*in)) + copy(*out, *in) + } + if in.RelatedImages != nil { + in, out := &in.RelatedImages, &out.RelatedImages + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSVDescription. +func (in *CSVDescription) DeepCopy() *CSVDescription { + if in == nil { + return nil + } + out := new(CSVDescription) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChannelEntry) DeepCopyInto(out *ChannelEntry) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelEntry. +func (in *ChannelEntry) DeepCopy() *ChannelEntry { + if in == nil { + return nil + } + out := new(ChannelEntry) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Icon) DeepCopyInto(out *Icon) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Icon. +func (in *Icon) DeepCopy() *Icon { + if in == nil { + return nil + } + out := new(Icon) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Maintainer) DeepCopyInto(out *Maintainer) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Maintainer. +func (in *Maintainer) DeepCopy() *Maintainer { + if in == nil { + return nil + } + out := new(Maintainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackageChannel) DeepCopyInto(out *PackageChannel) { + *out = *in + in.CurrentCSVDesc.DeepCopyInto(&out.CurrentCSVDesc) + if in.Entries != nil { + in, out := &in.Entries, &out.Entries + *out = make([]ChannelEntry, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageChannel. +func (in *PackageChannel) DeepCopy() *PackageChannel { + if in == nil { + return nil + } + out := new(PackageChannel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackageManifest) DeepCopyInto(out *PackageManifest) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifest. +func (in *PackageManifest) DeepCopy() *PackageManifest { + if in == nil { + return nil + } + out := new(PackageManifest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PackageManifest) 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 *PackageManifestList) DeepCopyInto(out *PackageManifestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PackageManifest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifestList. +func (in *PackageManifestList) DeepCopy() *PackageManifestList { + if in == nil { + return nil + } + out := new(PackageManifestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PackageManifestList) 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 *PackageManifestSpec) DeepCopyInto(out *PackageManifestSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifestSpec. +func (in *PackageManifestSpec) DeepCopy() *PackageManifestSpec { + if in == nil { + return nil + } + out := new(PackageManifestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PackageManifestStatus) DeepCopyInto(out *PackageManifestStatus) { + *out = *in + out.Provider = in.Provider + if in.Channels != nil { + in, out := &in.Channels, &out.Channels + *out = make([]PackageChannel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageManifestStatus. +func (in *PackageManifestStatus) DeepCopy() *PackageManifestStatus { + if in == nil { + return nil + } + out := new(PackageManifestStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version/version.go b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version/version.go new file mode 100644 index 000000000..a0ffb9fcb --- /dev/null +++ b/vendor/github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version/version.go @@ -0,0 +1,67 @@ +package version + +import ( + "encoding/json" + + semver "github.com/blang/semver/v4" +) + +// +k8s:openapi-gen=true +// OperatorVersion is a wrapper around semver.Version which supports correct +// marshaling to YAML and JSON. +// +kubebuilder:validation:Type=string +type OperatorVersion struct { + semver.Version `json:"-"` +} + +// DeepCopyInto creates a deep-copy of the Version value. +func (v *OperatorVersion) DeepCopyInto(out *OperatorVersion) { + out.Major = v.Major + out.Minor = v.Minor + out.Patch = v.Patch + + if v.Pre != nil { + pre := make([]semver.PRVersion, len(v.Pre)) + copy(pre, v.Pre) + out.Pre = pre + } + + if v.Build != nil { + build := make([]string, len(v.Build)) + copy(build, v.Build) + out.Build = build + } +} + +// MarshalJSON implements the encoding/json.Marshaler interface. +func (v OperatorVersion) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +// UnmarshalJSON implements the encoding/json.Unmarshaler interface. +func (v *OperatorVersion) UnmarshalJSON(data []byte) (err error) { + var versionString string + + if err = json.Unmarshal(data, &versionString); err != nil { + return + } + + version := semver.Version{} + version, err = semver.ParseTolerant(versionString) + if err != nil { + return err + } + v.Version = version + return +} + +// OpenAPISchemaType is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +// +// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators +func (_ OperatorVersion) OpenAPISchemaType() []string { return []string{"string"} } + +// OpenAPISchemaFormat is used by the kube-openapi generator when constructing +// the OpenAPI spec of this type. +// "semver" is not a standard openapi format but tooling may use the value regardless +func (_ OperatorVersion) OpenAPISchemaFormat() string { return "semver" } diff --git a/vendor/modules.txt b/vendor/modules.txt index 7d495c540..59ebba6c9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -279,6 +279,7 @@ github.com/openshift-kni/eco-goinfra/pkg/deployment github.com/openshift-kni/eco-goinfra/pkg/msg github.com/openshift-kni/eco-goinfra/pkg/namespace github.com/openshift-kni/eco-goinfra/pkg/networkpolicy +github.com/openshift-kni/eco-goinfra/pkg/olm github.com/openshift-kni/eco-goinfra/pkg/pod github.com/openshift-kni/eco-goinfra/pkg/rbac github.com/openshift-kni/eco-goinfra/pkg/replicaset @@ -300,6 +301,12 @@ github.com/openshift-kni/eco-goinfra/pkg/schemes/ocs/objectbucket.io github.com/openshift-kni/eco-goinfra/pkg/schemes/ocs/objectbucket.io/v1alpha1 github.com/openshift-kni/eco-goinfra/pkg/schemes/ocs/operatorv1 github.com/openshift-kni/eco-goinfra/pkg/schemes/ocs/provisioner +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1 +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/operators/v1alpha1 +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/package-server/operators/v1 +github.com/openshift-kni/eco-goinfra/pkg/schemes/olm/version github.com/openshift-kni/eco-goinfra/pkg/service github.com/openshift-kni/eco-goinfra/pkg/statefulset github.com/openshift-kni/eco-goinfra/pkg/storage