diff --git a/packages/kn-plugin-workflow/.gitignore b/packages/kn-plugin-workflow/.gitignore index 00bd0b786d7..1a4d60ae174 100644 --- a/packages/kn-plugin-workflow/.gitignore +++ b/packages/kn-plugin-workflow/.gitignore @@ -1,4 +1,5 @@ debug/ kogito-serverless-operator/ TODO.txt -it-tests/temp-tests/ +e2e-tests/temp-tests/ +dist-it-tests/ diff --git a/packages/kn-plugin-workflow/pkg/command/gen_manifest.go b/packages/kn-plugin-workflow/pkg/command/gen_manifest.go index 0884d2bd354..78b6980fb38 100644 --- a/packages/kn-plugin-workflow/pkg/command/gen_manifest.go +++ b/packages/kn-plugin-workflow/pkg/command/gen_manifest.go @@ -50,9 +50,10 @@ func NewGenManifest() *cobra.Command { SuggestFor: []string{"gen-manifests", "generate-manifest"}, //nolint:misspell } - cmd.Run = func(cmd *cobra.Command, args []string) { - generateManifestsCmd(cmd, args) + cmd.RunE = func(cmd *cobra.Command, args []string) error { + return generateManifestsCmd(cmd, args) } + cmd.Flags().StringP("namespace", "n", "", "Target namespace of your deployment.") cmd.Flags().StringP("manifestPath", "c", "", "Target directory of your generated Operator manifests.") cmd.Flags().StringP("supportFilesFolder", "s", "", "Specify a custom support files folder") @@ -72,8 +73,8 @@ func generateManifestsCmd(cmd *cobra.Command, args []string) error { fmt.Println("šŸ› ļøļø Generating a list of Operator manifests for a SonataFlow project...") fmt.Printf("šŸ“‚ Manifests will be generated in %s\n", cfg.ManifestPath) - if err := checkEnvironment(&cfg); err != nil { - return fmt.Errorf("āŒ ERROR: checking environment: %w", err) + if err := setupEnvironment(&cfg); err != nil { + return fmt.Errorf("āŒ ERROR: setup environment: %w", err) } if err := generateManifests(&cfg); err != nil { @@ -116,6 +117,25 @@ func runGenManifestCmdConfig(cmd *cobra.Command) (cfg DeployUndeployCmdConfig, e return cfg, nil } +func setupEnvironment(cfg *DeployUndeployCmdConfig) error { + fmt.Println("\nšŸ”Ž Checking your environment...") + + //setup namespace + if len(cfg.NameSpace) == 0 { + if defaultNamespace, err := common.GetKubectlNamespace(); err == nil { + cfg.NameSpace = defaultNamespace + fmt.Printf(" - āœ… resolved namespace: %s\n", cfg.NameSpace) + } else { + cfg.NameSpace = "default" + fmt.Printf(" - āœ… resolved namespace (default): %s\n", cfg.NameSpace) + } + } else { + fmt.Printf(" - āœ… resolved namespace: %s\n", cfg.NameSpace) + } + + return nil +} + func resolveManifestDir(folderName string) (string, error) { if folderName == "" { folderName = "manifests"