From c0b2c3c5d60d2bd906891b8e2b6827b4ac76e342 Mon Sep 17 00:00:00 2001 From: awgreene Date: Wed, 28 Aug 2019 13:42:37 -0400 Subject: [PATCH] [CatalogSource] Set Global Catalog NS with EnvVar This commit introduces a change that makes it possible to configure the Global Catalog Namespace by adding the CATALOG_NAMESPACE environment variable to the catalog-operator deployment. --- Documentation/install/install.md | 4 ++++ cmd/catalog/main.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/install/install.md b/Documentation/install/install.md index e3b022defa..665cd21eaf 100644 --- a/Documentation/install/install.md +++ b/Documentation/install/install.md @@ -87,6 +87,10 @@ To configure a release of OLM for installation in a cluster: The above steps are automated for official releases with `make ver=0.3.0 release`, which will output new versions of manifests in `deploy/tectonic-alm-operator/manifests/$(ver)`. +## Overriding the Global Catalog Namespace + +It is possible to override the Global Catalog Namespace by setting the `GLOBAL_CATALOG_NAMESPACE` environment variable in the catalog operator deployment. + ## Subscribe to a Package and Channel Cloud Services can be installed from the catalog by subscribing to a channel in the corresponding package. diff --git a/cmd/catalog/main.go b/cmd/catalog/main.go index 7bf09e5e78..e47e8d141b 100644 --- a/cmd/catalog/main.go +++ b/cmd/catalog/main.go @@ -26,6 +26,7 @@ import ( ) const ( + catalogNamespaceEnvVarName = "GLOBAL_CATALOG_NAMESPACE" defaultWakeupInterval = 15 * time.Minute defaultCatalogNamespace = "openshift-operator-lifecycle-manager" defaultConfigMapServerImage = "quay.io/operatorframework/configmap-operator-registry:latest" @@ -103,6 +104,12 @@ func main() { } logger.Infof("log level %s", logger.Level) + // If the catalogNamespaceEnvVarName environment variable is set, then update the value of catalogNamespace. + if catalogNamespaceEnvVarValue := os.Getenv(catalogNamespaceEnvVarName); catalogNamespaceEnvVarValue != "" { + logger.Infof("%s environment variable is set. Updating Global Catalog Namespace to %s", catalogNamespaceEnvVarName, catalogNamespaceEnvVarValue) + *catalogNamespace = catalogNamespaceEnvVarValue + } + var useTLS bool if *tlsCertPath != "" && *tlsKeyPath == "" || *tlsCertPath == "" && *tlsKeyPath != "" { logger.Warn("both --tls-key and --tls-crt must be provided for TLS to be enabled, falling back to non-https")