Skip to content

Commit

Permalink
[0.32.0] KOGITO-9862: Manifest gen should not required a cluster conn…
Browse files Browse the repository at this point in the history
…ection (#2007)
  • Loading branch information
ederign authored Oct 6, 2023
1 parent d7d9c8f commit 0b28a10
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/kn-plugin-workflow/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
debug/
kogito-serverless-operator/
TODO.txt
it-tests/temp-tests/
e2e-tests/temp-tests/
dist-it-tests/
28 changes: 24 additions & 4 deletions packages/kn-plugin-workflow/pkg/command/gen_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 0b28a10

Please sign in to comment.