mirror of
https://github.com/LukeHagar/sailpoint-cli.git
synced 2025-12-09 12:47:44 +00:00
Adding utils for config
This commit is contained in:
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sailpoint-oss/sailpoint-cli/internal/client"
|
||||
"github.com/sailpoint-oss/sailpoint-cli/internal/util"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,7 +26,7 @@ func NewTransformCmd(client client.Client) *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().StringP("transforms-endpoint", "e", viper.GetString("baseurl")+transformsEndpoint, "Override transforms endpoint")
|
||||
cmd.PersistentFlags().StringP("transforms-endpoint", "e", util.GetBasePath()+transformsEndpoint, "Override transforms endpoint")
|
||||
|
||||
cmd.AddCommand(
|
||||
newListCmd(client),
|
||||
|
||||
21
internal/util/config.go
Normal file
21
internal/util/config.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func GetAuthType() string {
|
||||
return strings.ToLower(viper.GetString("authtype"))
|
||||
}
|
||||
|
||||
func GetBasePath() string {
|
||||
switch GetAuthType() {
|
||||
case "oauth":
|
||||
return viper.GetString("oauth.baseurl")
|
||||
case "pat":
|
||||
return viper.GetString("pat.baseurl")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user