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

fix: correct order of precedence to gate Konnect mode #738

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,11 @@ func sendAnalytics(cmd, kongVersion string, mode mode) error {
}

func inKonnectMode(targetContent *file.Content) bool {
if (targetContent != nil && targetContent.Konnect != nil) ||
konnectConfig.Email != "" ||
if targetContent != nil && targetContent.Konnect != nil {
return true
} else if rootConfig.Address != defaultKongURL {
return false
} else if konnectConfig.Email != "" ||
konnectConfig.Password != "" ||
konnectConfig.Token != "" {
return true
Expand Down
10 changes: 7 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import (
"github.com/spf13/viper"
)

const defaultKonnectURL = "https://us.api.konghq.com"
const (
defaultKongURL = "http://localhost:8001"
defaultKonnectURL = "https://us.api.konghq.com"
)

var (
cfgFile string
Expand All @@ -27,8 +30,9 @@ var (
konnectRuntimeGroup string
)

//nolint:errcheck
// NewRootCmd represents the base command when called without any subcommands
//
//nolint:errcheck
func NewRootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "deck",
Expand All @@ -50,7 +54,7 @@ It can be used to export, import, or sync entities to Kong.`,
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "",
"Config file (default is $HOME/.deck.yaml).")

rootCmd.PersistentFlags().String("kong-addr", "http://localhost:8001",
rootCmd.PersistentFlags().String("kong-addr", defaultKongURL,
"HTTP address of Kong's Admin API.\n"+
"This value can also be set using the environment variable DECK_KONG_ADDR\n"+
" environment variable.")
Expand Down