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

Fixing issue in init command. #117

Merged
merged 1 commit into from
Oct 13, 2019
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
16 changes: 6 additions & 10 deletions import-export-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,21 @@ const RootCmdShortDesc = "CLI for Importing and Exporting APIs and Applications"
const RootCmdLongDesc = utils.ProjectName + ` is a Command Line Tool for Importing and Exporting APIs and Applications between different environments of WSO2 API Manager
(Dev, Production, Staging, QA etc.)`


//Get config to check mode
var configVars = utils.GetMainConfigFromFile(utils.MainConfigFilePath)

// This represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: utils.ProjectName,
Args: func(cmd *cobra.Command, args []string) error {
if configVars.Config.KubernetesMode {
if isK8sEnabled() {
return cobra.ArbitraryArgs(cmd, args)
} else {
return cobra.NoArgs(cmd, args)
}
},
DisableFlagParsing: setDisableFlagParsing(),
DisableFlagParsing: isK8sEnabled(),
Short: RootCmdShortDesc,
Long: RootCmdLongDesc,
Run: func(cmd *cobra.Command, args []string) {
if configVars.Config.KubernetesMode {
if isK8sEnabled() {
executeKubernetes(args...)
} else {
cmd.Help()
Expand Down Expand Up @@ -186,9 +182,9 @@ func initConfig() {
}

//disable flags when the mode set to kubernetes
func setDisableFlagParsing() bool {
func isK8sEnabled() bool {
//Get config to check mode
configVars = utils.GetMainConfigFromFileSilently(utils.MainConfigFilePath)
configVars := utils.GetMainConfigFromFileSilently(utils.MainConfigFilePath)
if configVars != nil && configVars.Config.KubernetesMode {
return true
} else {
Expand All @@ -209,4 +205,4 @@ func executeKubernetes(arg ...string) {
if err != nil {
utils.HandleErrorAndExit("Error executing kubernetes commands ", err)
}
}
}