Fixed issues with using access token incorrectly

This commit is contained in:
David Allen 2024-06-20 17:46:03 -06:00
parent a9ca2de3fc
commit 88f31d7e26
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
3 changed files with 61 additions and 3 deletions

View file

@ -19,6 +19,22 @@ var serveCmd = &cobra.Command{
Use: "serve",
Short: "Start configurator as a server and listen for requests",
Run: func(cmd *cobra.Command, args []string) {
// make sure that we have a token present before trying to make request
if config.AccessToken == "" {
// TODO: make request to check if request will need token
// check if OCHAMI_ACCESS_TOKEN env var is set if no access token is provided and use that instead
accessToken := os.Getenv("ACCESS_TOKEN")
if accessToken != "" {
config.AccessToken = accessToken
} else {
// TODO: try and fetch token first if it is needed
if verbose {
fmt.Printf("No token found. Attempting to generate config without one...\n")
}
}
}
// use config plugins if none supplied via CLI
if len(pluginPaths) <= 0 {
pluginPaths = append(pluginPaths, config.PluginDirs...)