[GitHub] [camel-k] squakez commented on a diff in pull request #3631: feat(cli): Allow to set build publish strategy options from install cmd

2022-09-13 Thread GitBox


squakez commented on code in PR #3631:
URL: https://github.com/apache/camel-k/pull/3631#discussion_r969820383


##
pkg/cmd/install.go:
##
@@ -734,6 +723,37 @@ func (o *installCmdOptions) validate(_ *cobra.Command, _ 
[]string) error {
return result
 }
 
+// addBuildPublishStrategyOptions parses and adds all the build publish 
strategy options to the given IntegrationPlatformBuildSpec.
+func (o *installCmdOptions) addBuildPublishStrategyOptions(build 
*v1.IntegrationPlatformBuildSpec) error {
+   for _, option := range o.BuildPublishStrategyOptions {
+   kv := strings.Split(option, "=")
+   if len(kv) == 2 {
+   key := kv[0]
+   if 
builder.IsSupportedPublishStrategyOption(build.PublishStrategy, key) {
+   build.AddOption(key, kv[1])
+   } else {
+   return fmt.Errorf("build publish strategy 
option '%s' not supported. %s", option, 
supportedOptionsAsString(build.PublishStrategy))
+   }
+   } else {
+   return fmt.Errorf("build publish strategy option '%s' 
not in the expected format (name=value)", option)
+   }
+   }
+   return nil
+}
+
+// supportedOptionsAsString provides all the supported options for the given 
strategy as string.
+func supportedOptionsAsString(strategy 
v1.IntegrationPlatformBuildPublishStrategy) string {

Review Comment:
   +1 on this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [camel-k] squakez commented on a diff in pull request #3631: feat(cli): Allow to set build publish strategy options from install cmd

2022-09-13 Thread GitBox


squakez commented on code in PR #3631:
URL: https://github.com/apache/camel-k/pull/3631#discussion_r969396018


##
pkg/cmd/install.go:
##
@@ -108,16 +108,12 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) 
(*cobra.Command, *installCmdO
cmd.Flags().String("operator-image-pull-policy", "", "Set the operator 
ImagePullPolicy used for the operator deployment")
cmd.Flags().String("build-strategy", "", "Set the build strategy")
cmd.Flags().String("build-publish-strategy", "", "Set the build publish 
strategy")
+   cmd.Flags().StringArray("build-publish-strategy-option", nil, "Add a 
build publish strategy option, as ")
cmd.Flags().String("build-timeout", "", "Set how long the build process 
can last")
cmd.Flags().String("trait-profile", "", "The profile to use for traits")
 
// Kaniko
-   cmd.Flags().Bool("kaniko-build-cache", false, "To enable or disable the 
Kaniko cache")
-   cmd.Flags().String("kaniko-executor-image", "", "The docker image of 
the Kaniko executor")
-   cmd.Flags().String("kaniko-warmer-image", "", "The docker image of the 
Kaniko warmer")
-
-   // Buildah
-   cmd.Flags().String("buildah-image", "", "The docker image to use for 
Buildah")

Review Comment:
   Cannot recall if this one was present in 1.10 release already. If so, we 
should not remove but add a deprecation notice.



##
pkg/cmd/install.go:
##
@@ -171,47 +167,45 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) 
(*cobra.Command, *installCmdO
 
 type installCmdOptions struct {
*RootCmdOptions
-   Wait bool `mapstructure:"wait"`
-   BuildahImage string   `mapstructure:"buildah-image"`
-   ClusterSetupOnly bool `mapstructure:"cluster-setup"`
-   SkipOperatorSetupbool `mapstructure:"skip-operator-setup"`
-   SkipClusterSetup bool `mapstructure:"skip-cluster-setup"`
-   SkipRegistrySetupbool `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"`
-   KanikoExecutorImage  string   `mapstructure:"kaniko-executor-image"`
-   KanikoWarmerImagestring   `mapstructure:"kaniko-warmer-image"`
-   Save bool `mapstructure:"save" kamel:"omitsave"`
-   Forcebool `mapstructure:"force"`
-   Olm  bool `mapstructure:"olm"`
-   ClusterType  string   `mapstructure:"cluster-type"`
-   OutputFormat string   `mapstructure:"output"`
-   RuntimeVersion   string   `mapstructure:"runtime-version"`
-   BaseImagestring   `mapstructure:"base-image"`
-   OperatorID   string   `mapstructure:"operator-id"`
-   OperatorImagestring   `mapstructure:"operator-image"`
-   OperatorImagePullPolicy  string   
`mapstructure:"operator-image-pull-policy"`
-   BuildStrategystring   `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"`
-   MavenSettingsstring   `mapstructure:"maven-settings"`
-   MavenCASecretstring   `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"`
-   LogLevel string   `mapstructure:"log-level"`
-   EnvVars  []string `mapstructure:"operator-env-vars"`
+   Waitbool `mapstructure:"wait"`
+   ClusterSetupOnlybool `mapstructure:"cluster-setup"`
+   SkipOperatorSetup   bool 
`mapstructure:"skip-operator-setup"`
+   SkipClusterSetupbool `mapstructure:"skip-cluster-setup"`
+   SkipRegistr