Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix: Helper function for getting service token

Daniel Hougaard522a03c2ad5d
diff --git a/cli/packages/util/helper.go b/cli/packages/util/helper.go
index 043db468e0..413afb2b88 100644
--- a/cli/packages/util/helper.go
+++ b/cli/packages/util/helper.go
@@ -11,6 +11,7 @@ import (
"strings"
"github.com/Infisical/infisical-merge/packages/models"
+ "github.com/spf13/cobra"
)
type DecodedSymmetricEncryptionDetails = struct {
@@ -63,6 +64,20 @@ func IsSecretTypeValid(s string) bool {
return false
}
+func GetInfisicalServiceToken(cmd *cobra.Command) (serviceToken string, err error) {
+ infisicalToken, err := cmd.Flags().GetString("token")
+
+ if infisicalToken == "" {
+ infisicalToken = os.Getenv(INFISICAL_TOKEN_NAME)
+ }
+
+ if err != nil {
+ return "", err
+ }
+
+ return infisicalToken, nil
+}
+
// Checks if the passed in email already exists in the users slice
func ConfigContainsEmail(users []models.LoggedInUser, email string) bool {
for _, value := range users {