mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Add error for when no login/no token
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func HandleError(err error, messages ...string) {
|
||||
PrintErrorAndExit(1, err, messages...)
|
||||
}
|
||||
|
||||
func PrintErrorAndExit(exitCode int, err error, messages ...string) {
|
||||
printError(err)
|
||||
|
||||
if len(messages) > 0 {
|
||||
for _, message := range messages {
|
||||
fmt.Println(message)
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
|
||||
func PrintMessageAndExit(messages ...string) {
|
||||
if len(messages) > 0 {
|
||||
for _, message := range messages {
|
||||
fmt.Println(message)
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func printError(e error) {
|
||||
color.Red("Hmm, we ran into an error: %v", e)
|
||||
}
|
||||
@@ -117,9 +117,11 @@ func GetAllEnvironmentVariables(envName string) ([]models.SingleEnvironmentVaria
|
||||
secrets, err := GetPlainTextSecretsViaJTW(loggedInUserDetails.UserCredentials.JTWToken, loggedInUserDetails.UserCredentials.PrivateKey, workspaceFile.WorkspaceId, envName)
|
||||
return secrets, err
|
||||
|
||||
} else {
|
||||
} else if infisicalToken != "" {
|
||||
log.Debug("Trying to fetch secrets using service token")
|
||||
return GetPlainTextSecretsViaServiceToken(infisicalToken)
|
||||
} else {
|
||||
return nil, fmt.Errorf("unable to fetch secrets because we could not find a service token or a logged in user")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user