This is an automated email from the ASF dual-hosted git repository.
tsato 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 50047bd feat(cli): add flag --skip-default-kamelets-setup to kamel
install
50047bd is described below
commit 50047bd78089c6051b8704ddcddcafc6e5c71e91
Author: Tadayoshi Sato <[email protected]>
AuthorDate: Thu Feb 3 15:00:50 2022 +0900
feat(cli): add flag --skip-default-kamelets-setup to kamel install
Fix #2560
---
e2e/common/cli/install_test.go | 8 +++++
pkg/cmd/install.go | 77 +++++++++++++++++++++++-------------------
pkg/cmd/install_test.go | 8 +++++
3 files changed, 58 insertions(+), 35 deletions(-)
diff --git a/e2e/common/cli/install_test.go b/e2e/common/cli/install_test.go
index 3b4d061..8d99b78 100644
--- a/e2e/common/cli/install_test.go
+++ b/e2e/common/cli/install_test.go
@@ -76,3 +76,11 @@ func TestSkipRegistryInstallation(t *testing.T) {
}, TestTimeoutMedium).Should(Equal(v1.RegistrySpec{}))
})
}
+
+func TestInstallSkipDefaultKameletsInstallation(t *testing.T) {
+ WithNewTestNamespace(t, func(ns string) {
+ Expect(Kamel("install", "-n", ns,
"--skip-default-kamelets-setup").Execute()).To(Succeed())
+ Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+ Expect(KameletList(ns)()).Should(BeEmpty())
+ })
+}
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 878c15d..92ad2c4 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -82,6 +82,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions)
(*cobra.Command, *installCmdO
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("skip-default-kamelets-setup", false, "Skip
installation of the default Kamelets from catalog")
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.")
@@ -156,41 +157,42 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions)
(*cobra.Command, *installCmdO
type installCmdOptions struct {
*RootCmdOptions
- Wait bool `mapstructure:"wait"`
- 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"`
- Save bool `mapstructure:"save" kamel:"omitsave"`
- Force bool `mapstructure:"force"`
- Olm bool `mapstructure:"olm"`
- ClusterType string `mapstructure:"cluster-type"`
- OutputFormat string `mapstructure:"output"`
- RuntimeVersion string `mapstructure:"runtime-version"`
- BaseImage string `mapstructure:"base-image"`
- OperatorImage string `mapstructure:"operator-image"`
- OperatorImagePullPolicy string
`mapstructure:"operator-image-pull-policy"`
- BuildStrategy string `mapstructure:"build-strategy"`
- BuildPublishStrategy string `mapstructure:"build-publish-strategy"`
- BuildTimeout string `mapstructure:"build-timeout"`
- MavenExtensions []string `mapstructure:"maven-extensions"`
- MavenLocalRepository string `mapstructure:"maven-local-repository"`
- MavenProperties []string `mapstructure:"maven-properties"`
- MavenRepositories []string `mapstructure:"maven-repositories"`
- MavenSettings string `mapstructure:"maven-settings"`
- MavenCASecret string `mapstructure:"maven-ca-secret"`
- MavenCLIOptions []string `mapstructure:"maven-cli-options"`
- HealthPort int32 `mapstructure:"health-port"`
- Monitoring bool `mapstructure:"monitoring"`
- MonitoringPort int32 `mapstructure:"monitoring-port"`
- TraitProfile string `mapstructure:"trait-profile"`
- Tolerations []string `mapstructure:"tolerations"`
- NodeSelectors []string `mapstructure:"node-selectors"`
- ResourcesRequirements []string `mapstructure:"operator-resources"`
- EnvVars []string `mapstructure:"operator-env-vars"`
+ Wait bool `mapstructure:"wait"`
+ ClusterSetupOnly bool `mapstructure:"cluster-setup"`
+ SkipOperatorSetup bool `mapstructure:"skip-operator-setup"`
+ SkipClusterSetup bool `mapstructure:"skip-cluster-setup"`
+ SkipRegistrySetup bool `mapstructure:"skip-registry-setup"`
+ SkipDefaultKameletsSetup bool
`mapstructure:"skip-default-kamelets-setup"`
+ ExampleSetup bool `mapstructure:"example"`
+ Global bool `mapstructure:"global"`
+ KanikoBuildCache bool `mapstructure:"kaniko-build-cache"`
+ Save bool `mapstructure:"save" kamel:"omitsave"`
+ Force bool `mapstructure:"force"`
+ Olm bool `mapstructure:"olm"`
+ ClusterType string `mapstructure:"cluster-type"`
+ OutputFormat string `mapstructure:"output"`
+ RuntimeVersion string `mapstructure:"runtime-version"`
+ BaseImage string `mapstructure:"base-image"`
+ OperatorImage string `mapstructure:"operator-image"`
+ OperatorImagePullPolicy string
`mapstructure:"operator-image-pull-policy"`
+ BuildStrategy string `mapstructure:"build-strategy"`
+ BuildPublishStrategy string
`mapstructure:"build-publish-strategy"`
+ BuildTimeout string `mapstructure:"build-timeout"`
+ MavenExtensions []string `mapstructure:"maven-extensions"`
+ MavenLocalRepository string
`mapstructure:"maven-local-repository"`
+ MavenProperties []string `mapstructure:"maven-properties"`
+ MavenRepositories []string `mapstructure:"maven-repositories"`
+ MavenSettings string `mapstructure:"maven-settings"`
+ MavenCASecret string `mapstructure:"maven-ca-secret"`
+ MavenCLIOptions []string `mapstructure:"maven-cli-options"`
+ HealthPort int32 `mapstructure:"health-port"`
+ Monitoring bool `mapstructure:"monitoring"`
+ MonitoringPort int32 `mapstructure:"monitoring-port"`
+ TraitProfile string `mapstructure:"trait-profile"`
+ Tolerations []string `mapstructure:"tolerations"`
+ NodeSelectors []string `mapstructure:"node-selectors"`
+ ResourcesRequirements []string `mapstructure:"operator-resources"`
+ EnvVars []string `mapstructure:"operator-env-vars"`
registry v1.RegistrySpec
registryAuth registry.Auth
@@ -209,6 +211,11 @@ func (o *installCmdOptions) install(cobraCmd
*cobra.Command, _ []string) error {
// Let's use a client provider during cluster installation, to
eliminate the problem of CRD object caching
clientProvider := client.Provider{Get: o.NewCmdClient}
+ // --skip-default-kamelets-setup is a syntax sugar for
'--operator-env-vars KAMEL_INSTALL_DEFAULT_KAMELETS=false'
+ if o.SkipDefaultKameletsSetup {
+ o.EnvVars = append(o.EnvVars,
"KAMEL_INSTALL_DEFAULT_KAMELETS=false")
+ }
+
installViaOLM := false
if o.Olm {
var err error
diff --git a/pkg/cmd/install_test.go b/pkg/cmd/install_test.go
index 58fe06e..874b153 100644
--- a/pkg/cmd/install_test.go
+++ b/pkg/cmd/install_test.go
@@ -63,6 +63,7 @@ func TestInstallNoFlag(t *testing.T) {
assert.Equal(t, false, installCmdOptions.ClusterSetupOnly)
assert.Equal(t, false, installCmdOptions.SkipOperatorSetup)
assert.Equal(t, false, installCmdOptions.SkipClusterSetup)
+ assert.Equal(t, false, installCmdOptions.SkipDefaultKameletsSetup)
assert.Equal(t, false, installCmdOptions.ExampleSetup)
assert.Equal(t, false, installCmdOptions.Global)
assert.Equal(t, false, installCmdOptions.KanikoBuildCache)
@@ -317,6 +318,13 @@ func TestInstallSkipRegistrySetupFlag(t *testing.T) {
assert.Equal(t, true, installCmdOptions.SkipRegistrySetup)
}
+func TestInstallSkipDefaultKameletsSetupFlag(t *testing.T) {
+ installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
+ _, err := test.ExecuteCommand(rootCmd, cmdInstall,
"--skip-default-kamelets-setup")
+ assert.Nil(t, err)
+ assert.Equal(t, true, installCmdOptions.SkipDefaultKameletsSetup)
+}
+
func TestInstallTraitProfileFlag(t *testing.T) {
installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdInstall, "--trait-profile",
"someString")