You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2021/07/16 10:50:06 UTC
[camel-k] branch main updated: #2358: Possible to skip configuring
of registry when installing via cli
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 8f917ee #2358: Possible to skip configuring of registry when installing via cli
8f917ee is described below
commit 8f917eea69f9f7574e7943f8bcc4f7751360241b
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Mon Jul 12 17:53:06 2021 +0100
#2358: Possible to skip configuring of registry when installing via cli
* install.go
* Use of --skip-registry-setup switch will bypass all configuration in
relation to the registry and leave a blank structure in the newly
installed platform
* Includes tests
* Makefile
* Makes the IMAGE_NAME and VERSION overrideable on the cli
---
e2e/common/cli/install_test.go | 15 +++++++++++++++
pkg/cmd/install.go | 31 +++++++++++++++++++------------
pkg/cmd/install_test.go | 7 +++++++
pkg/install/operator.go | 4 ++--
script/Makefile | 4 ++--
5 files changed, 45 insertions(+), 16 deletions(-)
diff --git a/e2e/common/cli/install_test.go b/e2e/common/cli/install_test.go
index 34fd08e..8666ec0 100644
--- a/e2e/common/cli/install_test.go
+++ b/e2e/common/cli/install_test.go
@@ -27,6 +27,7 @@ import (
. "github.com/onsi/gomega"
. "github.com/apache/camel-k/e2e/support"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
func TestBasicInstallation(t *testing.T) {
@@ -60,3 +61,17 @@ func TestMavenRepositoryInstallation(t *testing.T) {
}).Should(ContainSubstring("https://my.repo.org/public/"))
})
}
+
+/*
+ * Expert mode where user does not want a registry configured
+ * so the Platform will have an empty Registry structure
+ */
+func TestSkipRegistryInstallation(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ Expect(Kamel("install", "-n", ns, "--skip-registry-setup").Execute()).To(Succeed())
+ Eventually(Platform(ns)).ShouldNot(BeNil())
+ Eventually(func() v1.IntegrationPlatformRegistrySpec {
+ return Platform(ns)().Spec.Build.Registry
+ }, TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformRegistrySpec{}))
+ })
+}
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 26d3a16..46c492b 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -74,6 +74,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
cmd.Flags().String("cluster-type", "", "Set explicitly the cluster type to Kubernetes or OpenShift")
cmd.Flags().Bool("skip-operator-setup", false, "Do not install the operator in the namespace (in case there's a global one)")
cmd.Flags().Bool("skip-cluster-setup", false, "Skip the cluster-setup phase")
+ cmd.Flags().Bool("skip-registry-setup", false, "Skip the registry-setup phase (may negatively impact building of integrations)")
cmd.Flags().Bool("example", false, "Install example integration")
cmd.Flags().Bool("global", false, "Configure the operator to watch all namespaces. No integration platform is created. You can run integrations in a namespace by installing an integration platform: 'kamel install --skip-operator-setup -n my-namespace'")
cmd.Flags().Bool("force", false, "Force replacement of configuration resources when already present.")
@@ -152,6 +153,7 @@ type installCmdOptions struct {
ClusterSetupOnly bool `mapstructure:"cluster-setup"`
SkipOperatorSetup bool `mapstructure:"skip-operator-setup"`
SkipClusterSetup bool `mapstructure:"skip-cluster-setup"`
+ SkipRegistrySetup bool `mapstructure:"skip-registry-setup"`
ExampleSetup bool `mapstructure:"example"`
Global bool `mapstructure:"global"`
KanikoBuildCache bool `mapstructure:"kaniko-build-cache"`
@@ -291,21 +293,26 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
}
generatedSecretName := ""
- if o.registryAuth.IsSet() {
- regData := o.registryAuth
- regData.Registry = o.registry.Address
- generatedSecretName, err = install.RegistrySecretOrCollect(o.Context, c, namespace, regData, collection, o.Force)
- if err != nil {
- return err
- }
- } else if o.RegistryAuthFile != "" {
- generatedSecretName, err = install.RegistrySecretFromFileOrCollect(o.Context, c, namespace, o.RegistryAuthFile, collection, o.Force)
- if err != nil {
- return err
+
+ if !o.SkipRegistrySetup {
+ if o.registryAuth.IsSet() {
+ regData := o.registryAuth
+ regData.Registry = o.registry.Address
+ generatedSecretName, err = install.RegistrySecretOrCollect(o.Context, c, namespace, regData, collection, o.Force)
+ if err != nil {
+ return err
+ }
+ } else if o.RegistryAuthFile != "" {
+ generatedSecretName, err = install.RegistrySecretFromFileOrCollect(o.Context, c, namespace, o.RegistryAuthFile, collection, o.Force)
+ if err != nil {
+ return err
+ }
}
+ } else if o.SkipRegistrySetup {
+ fmt.Fprintln(cobraCmd.OutOrStdout(), "Camel K operator registry setup skipped")
}
- platform, err := install.PlatformOrCollect(o.Context, c, o.ClusterType, namespace, o.registry, collection)
+ platform, err := install.PlatformOrCollect(o.Context, c, o.ClusterType, namespace, o.SkipRegistrySetup, o.registry, collection)
if err != nil {
return err
}
diff --git a/pkg/cmd/install_test.go b/pkg/cmd/install_test.go
index c0d0ed2..de3561b 100644
--- a/pkg/cmd/install_test.go
+++ b/pkg/cmd/install_test.go
@@ -314,6 +314,13 @@ func TestInstallSkipOperatorSetupFlag(t *testing.T) {
assert.Equal(t, true, installCmdOptions.SkipOperatorSetup)
}
+func TestInstallSkipRegistrySetupFlag(t *testing.T) {
+ installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
+ _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--skip-registry-setup")
+ assert.Nil(t, err)
+ assert.Equal(t, true, installCmdOptions.SkipRegistrySetup)
+}
+
func TestInstallTraitProfileFlag(t *testing.T) {
installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdInstall, "--trait-profile", "someString")
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 54dc2df..513deef 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -410,7 +410,7 @@ func installServiceBindings(ctx context.Context, c client.Client, namespace stri
// PlatformOrCollect --
// nolint: lll
-func PlatformOrCollect(ctx context.Context, c client.Client, clusterType string, namespace string, registry v1.IntegrationPlatformRegistrySpec, collection *kubernetes.Collection) (*v1.IntegrationPlatform, error) {
+func PlatformOrCollect(ctx context.Context, c client.Client, clusterType string, namespace string, skipRegistrySetup bool, registry v1.IntegrationPlatformRegistrySpec, collection *kubernetes.Collection) (*v1.IntegrationPlatform, error) {
isOpenShift, err := isOpenShift(c, clusterType)
if err != nil {
return nil, err
@@ -421,7 +421,7 @@ func PlatformOrCollect(ctx context.Context, c client.Client, clusterType string,
}
pl := platformObject.(*v1.IntegrationPlatform)
- if !isOpenShift {
+ if !isOpenShift && !skipRegistrySetup {
pl.Spec.Build.Registry = registry
// Kubernetes only (Minikube)
diff --git a/script/Makefile b/script/Makefile
index c50cb82..d07d922 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -14,7 +14,7 @@
# limitations under the License.
VERSIONFILE := pkg/util/defaults/defaults.go
-VERSION := 1.5.0-SNAPSHOT
+VERSION ?= 1.5.0-SNAPSHOT
OPERATOR_VERSION := $(subst -SNAPSHOT,,$(VERSION))
LAST_RELEASED_VERSION := 1.4.1
RUNTIME_VERSION := 1.8.0
@@ -23,7 +23,7 @@ KANIKO_VERSION := 0.17.1
INSTALL_DEFAULT_KAMELETS := true
BASE_IMAGE := adoptopenjdk/openjdk11:slim
LOCAL_REPOSITORY := /tmp/artifacts/m2
-IMAGE_NAME := docker.io/apache/camel-k
+IMAGE_NAME ?= docker.io/apache/camel-k
METADATA_IMAGE_NAME := $(IMAGE_NAME)-metadata
RELEASE_GIT_REMOTE := upstream
GIT_COMMIT := $(shell git rev-list -1 HEAD)