Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (

INFISICAL_BACKUP_SECRET = "infisical-backup-secrets" // akhilmhdh: @depreciated remove in version v0.30
INFISICAL_BACKUP_SECRET_ENCRYPTION_KEY = "infisical-backup-secret-encryption-key"
INFISICAL_DISABLE_SECRETS_BACKUP_NAME = "INFISICAL_DISABLE_SECRETS_BACKUP"

KUBERNETES_SERVICE_HOST_ENV_NAME = "KUBERNETES_SERVICE_HOST"
KUBERNETES_SERVICE_PORT_HTTPS_ENV_NAME = "KUBERNETES_SERVICE_PORT_HTTPS"
Expand Down
8 changes: 6 additions & 2 deletions packages/util/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func GetAllEnvironmentVariables(params models.GetAllSecretsParameters, projectCo
params.Environment, params.SecretsPath, params.IncludeImport, params.Recursive, params.TagSlugs, true, params.IncludePersonalOverrides)
log.Debug().Msgf("GetAllEnvironmentVariables: Trying to fetch secrets JTW token [err=%s]", err)

if err == nil {
if err == nil && !IsSecretsBackupDisabled() {
backupEncryptionKey, err := GetBackupEncryptionKey()
if err != nil {
return nil, err
Expand All @@ -348,7 +348,7 @@ func GetAllEnvironmentVariables(params models.GetAllSecretsParameters, projectCo
secretsToReturn = res.Secrets
errorToReturn = err
// only attempt to serve cached secrets if no internet connection and if at least one secret cached
if !isConnected {
if !isConnected && !IsSecretsBackupDisabled() {
backupEncryptionKey, _ := GetBackupEncryptionKey()
if backupEncryptionKey != nil {
backedUpSecrets, err := ReadBackupSecrets(params.WorkspaceId, params.Environment, params.SecretsPath, backupEncryptionKey)
Expand Down Expand Up @@ -381,6 +381,10 @@ func GetAllEnvironmentVariables(params models.GetAllSecretsParameters, projectCo
return secretsToReturn, errorToReturn
}

func IsSecretsBackupDisabled() bool {
return os.Getenv(INFISICAL_DISABLE_SECRETS_BACKUP_NAME) != ""
}

func GetBackupEncryptionKey() ([]byte, error) {
encryptionKey, err := GetValueInKeyring(INFISICAL_BACKUP_SECRET_ENCRYPTION_KEY)
if err != nil {
Expand Down
Loading