Skip to content
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
4 changes: 0 additions & 4 deletions app/cli/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ var confOptions = struct {
viperKey: "organization",
flagName: "org",
},
platformAPI: &confOpt{
viperKey: "platform.API",
flagName: "platform",
},
}

type confOpt struct {
Expand Down
28 changes: 11 additions & 17 deletions app/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ import (
)

var (
flagCfgFile string
flagDebug bool
flagOutputFormat string
ActionOpts *action.ActionsOpts
logger zerolog.Logger
defaultCPAPI = "api.cp.chainloop.dev:443"
defaultCASAPI = "api.cas.chainloop.dev:443"
defaultPlatformAPI = "api.app.chainloop.dev:443"
apiToken string
flagYes bool
flagCfgFile string
flagDebug bool
flagOutputFormat string
ActionOpts *action.ActionsOpts
logger zerolog.Logger
defaultCPAPI = "api.cp.chainloop.dev:443"
defaultCASAPI = "api.cas.chainloop.dev:443"
apiToken string
flagYes bool
)

const (
Expand Down Expand Up @@ -106,7 +105,7 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
logger.Warn().Msg("API contacted in insecure mode")
}

authToken, isUserToken, err := loadControlplaneAuthToken(cmd)
authToken, isUserToken, err := LoadAuthToken(cmd)
if err != nil {
return err
}
Expand Down Expand Up @@ -224,11 +223,6 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
cobra.CheckErr(viper.BindPFlag(confOptions.CASCA.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.CASCA.flagName)))
cobra.CheckErr(viper.BindEnv(confOptions.CASCA.viperKey, calculateEnvVarName(confOptions.CASCA.viperKey)))

// Platform API configuration
rootCmd.PersistentFlags().String(confOptions.platformAPI.flagName, defaultPlatformAPI, fmt.Sprintf("URL for the Platform API ($%s)", calculateEnvVarName(confOptions.platformAPI.viperKey)))
cobra.CheckErr(viper.BindPFlag(confOptions.platformAPI.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.platformAPI.flagName)))
cobra.CheckErr(viper.BindEnv(confOptions.platformAPI.viperKey, calculateEnvVarName(confOptions.platformAPI.viperKey)))

rootCmd.PersistentFlags().BoolP("insecure", "i", false, fmt.Sprintf("Skip TLS transport during connection to the control plane ($%s)", calculateEnvVarName(confOptions.insecure.viperKey)))
cobra.CheckErr(viper.BindPFlag(confOptions.insecure.viperKey, rootCmd.PersistentFlags().Lookup("insecure")))
cobra.CheckErr(viper.BindEnv(confOptions.insecure.viperKey, calculateEnvVarName(confOptions.insecure.viperKey)))
Expand Down Expand Up @@ -359,7 +353,7 @@ func cleanup(conn *grpc.ClientConn) error {
// 2.2 Load the token from the environment variable and from the auth login config file
// 2.3 if they both exist, we default to the user token
// 2.4 otherwise to the one that's set
func loadControlplaneAuthToken(cmd *cobra.Command) (string, bool, error) {
func LoadAuthToken(cmd *cobra.Command) (string, bool, error) {
// Load the APIToken from the env variable
apiTokenFromVar := os.Getenv(tokenEnvVarName)

Expand Down
Loading
Loading