From ca164958ce3fc8c0c4418109ac8a55a0c0f7c5ae Mon Sep 17 00:00:00 2001 From: kubevirt-bot Date: Thu, 5 Mar 2020 10:29:10 +0100 Subject: [PATCH] Hide internal CRDs (#479) With github.com/operator-framework/operator-lifecycle-manager/pull/1097 OM supports a mechanism to hide internal CRDs on OLM console. Start using it. By default only - hyperconvergeds.hco.kubevirt.io - v2vvmwares.kubevirt.io - hostpathprovisioners.hostpathprovisioner.kubevirt.io are going to be visible. The list of visible CRDs can be override as a CLI parameter to the csv-merger tool. Signed-off-by: Simone Tiraboschi --- ...operator.v1.0.0.clusterserviceversion.yaml | 3 ++- tools/csv-merger/csv-merger.go | 27 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/deploy/olm-catalog/kubevirt-hyperconverged/1.0.0/kubevirt-hyperconverged-operator.v1.0.0.clusterserviceversion.yaml b/deploy/olm-catalog/kubevirt-hyperconverged/1.0.0/kubevirt-hyperconverged-operator.v1.0.0.clusterserviceversion.yaml index baad128725..c72b76af21 100644 --- a/deploy/olm-catalog/kubevirt-hyperconverged/1.0.0/kubevirt-hyperconverged-operator.v1.0.0.clusterserviceversion.yaml +++ b/deploy/olm-catalog/kubevirt-hyperconverged/1.0.0/kubevirt-hyperconverged-operator.v1.0.0.clusterserviceversion.yaml @@ -9,7 +9,7 @@ metadata: categories: OpenShift Optional certified: "false" containerImage: quay.io/kubevirt/hyperconverged-cluster-operator:latest - createdAt: "2020-03-04 08:25:27" + createdAt: "2020-03-04 23:40:03" description: |- **HyperConverged Cluster Operator** is an Operator pattern for managing multi-operator products. Specifcally, the HyperConverged Cluster Operator manages the deployment of KubeVirt, @@ -76,6 +76,7 @@ metadata: KubeVirt is distributed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt). operatorframework.io/suggested-namespace: kubevirt-hyperconverged + operators.operatorframework.io/internal-objects: '["networkaddonsconfigs.networkaddonsoperator.network.kubevirt.io","kubevirts.kubevirt.io","kubevirtcommontemplatesbundles.ssp.kubevirt.io","kubevirtmetricsaggregations.ssp.kubevirt.io","kubevirtnodelabellerbundles.ssp.kubevirt.io","kubevirttemplatevalidators.ssp.kubevirt.io","cdis.cdi.kubevirt.io","nodemaintenances.kubevirt.io"]' repository: https://github.com/kubevirt/hyperconverged-cluster-operator support: "false" name: kubevirt-hyperconverged-operator.v1.0.0 diff --git a/tools/csv-merger/csv-merger.go b/tools/csv-merger/csv-merger.go index 089d6d4966..b3729369b3 100644 --- a/tools/csv-merger/csv-merger.go +++ b/tools/csv-merger/csv-merger.go @@ -83,7 +83,9 @@ var ( namespace = flag.String("namespace", "kubevirt-hyperconverged", "Namespace") crdDisplay = flag.String("crd-display", "KubeVirt HyperConverged Cluster", "Label show in OLM UI about the primary CRD") csvOverrides = flag.String("csv-overrides", "", "CSV like string with punctual changes that will be recursively applied (if possible)") - relatedImagesList = flag.String("related-images-list", "", + visibleCRDList = flag.String("visible-crds-list", "hyperconvergeds.hco.kubevirt.io,v2vvmwares.kubevirt.io,hostpathprovisioners.hostpathprovisioner.kubevirt.io", + "Comma separated list of all the CRDs that should be visible in OLM console") + relatedImagesList = flag.String("related-images-list", "", "Comma separated list of all the images referred in the CSV (just the image pull URLs or eventually a set of 'image|name' collations)") ) @@ -221,6 +223,29 @@ func main() { } } + hidden_crds := []string{} + visible_crds := strings.Split(*visibleCRDList, ",") + for _, owned := range csvExtended.Spec.CustomResourceDefinitions.Owned { + found := false + for _, name := range visible_crds { + if owned.Name == name { + found = true + } + } + if !found { + hidden_crds = append( + hidden_crds, + owned.Name, + ) + } + } + + hidden_crds_j, err := json.Marshal(hidden_crds) + if err != nil { + panic(err) + } + csvExtended.Annotations["operators.operatorframework.io/internal-objects"] = string(hidden_crds_j) + dfound := false efound := false for _, deployment := range installStrategyBase.DeploymentSpecs {