Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHEF-1516 Fixed the --chef-license issue #3097

Merged
merged 3 commits into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions components/main-chef-wrapper/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"os"

"github.com/chef/chef-workstation/components/main-chef-wrapper/dist"
"github.com/chef/chef-workstation/components/main-chef-wrapper/platform-lib"
platform_lib "github.com/chef/chef-workstation/components/main-chef-wrapper/platform-lib"
"github.com/spf13/cobra"
)

Expand All @@ -33,14 +33,29 @@ var envCmd = &cobra.Command{
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) >= 1 {
cmd.Help()
os.Exit(0)
flags := []string{"--chef-license",
sanghinitin marked this conversation as resolved.
Show resolved Hide resolved
"--config", "--debug", "--version", "-c", "-d", "-v"}
if contains(flags, args[0]) {
return Runner.PassThroughCommand(dist.WorkstationExec, "", os.Args[1:])
} else {
cmd.Help()
os.Exit(0)
}
}
ReturnEnvironment()
return nil
},
}

func contains(flags []string, flagPassed string) bool {
for _, flag := range flags {
if flag == flagPassed {
return true
}
}
return false
}

func ReturnEnvironment() {
err := platform_lib.RunEnvironment()
if err != nil {
Expand Down