Skip to content

Commit

Permalink
FIxed the --chef-license issue (#3097)
Browse files Browse the repository at this point in the history
* redirecting to chef-cli for --chef-license flag

Signed-off-by: nikhil2611 <[email protected]>

* souting to cli for all flags

Signed-off-by: nikhil2611 <[email protected]>

* updated the variables name

Signed-off-by: nikhil2611 <[email protected]>

---------

Signed-off-by: nikhil2611 <[email protected]>
  • Loading branch information
nikhil2611 authored Apr 17, 2023
1 parent 9d89dd3 commit 52fa7f6
Showing 1 changed file with 18 additions and 3 deletions.
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",
"--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

0 comments on commit 52fa7f6

Please sign in to comment.