Skip to content

Commit

Permalink
feat(cli): add flag --skip-default-kamelets-setup to kamel install
Browse files Browse the repository at this point in the history
  • Loading branch information
tadayosi committed Feb 2, 2022
1 parent ece8d65 commit 4e42561
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 35 deletions.
8 changes: 8 additions & 0 deletions e2e/common/cli/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}
77 changes: 42 additions & 35 deletions pkg/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 4e42561

Please sign in to comment.