Feat: Login support for all auth methods

This commit is contained in:
Daniel Hougaard
2024-06-16 07:41:07 +02:00
parent 44a898fb15
commit 2ae45dc1cc
2 changed files with 17 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ const (
// Generic env variable used for auth methods that require a machine identity ID
INFISICAL_MACHINE_IDENTITY_ID_NAME = "INFISICAL_MACHINE_IDENTITY_ID"
// For auth methods that require a machine identity ID
INFISICAL_MACHINE_IDENTITY_ID_NAME = "INFISICAL_MACHINE_IDENTITY_ID"
SECRET_TYPE_PERSONAL = "personal"
SECRET_TYPE_SHARED = "shared"
KEYRING_SERVICE_NAME = "infisical"

View File

@@ -273,3 +273,17 @@ func GetEnvVarOrFileContent(envName string, filePath string) (string, error) {
return fileContent, nil
}
func GetCmdFlagOrEnv(cmd *cobra.Command, flag, envName string) (string, error) {
value, flagsErr := cmd.Flags().GetString(flag)
if flagsErr != nil {
return "", flagsErr
}
if value == "" {
value = os.Getenv(envName)
}
if value == "" {
return "", fmt.Errorf("please provide %s flag", flag)
}
return value, nil
}