feature: added offline support for infisical export

This commit is contained in:
Sheen Capadngan
2024-05-02 03:21:20 +08:00
parent a1e8f45a86
commit 88a4fb84e6
4 changed files with 73 additions and 54 deletions
+18
View File
@@ -426,6 +426,24 @@ func getSecretsByKeys(secrets []models.SingleEnvironmentVariable) map[string]mod
return secretMapByName
}
func GetBackupSecretsIfDisconnected(workspaceId string, environment string, encryptionKey []byte) ([]models.SingleEnvironmentVariable) {
isConnected := CheckIsConnectedToInfisicalAPI()
if !isConnected {
secrets, err := ReadBackupSecrets(workspaceId, environment, encryptionKey)
if err != nil {
HandleError(err)
}
if len(secrets) > 0 {
PrintWarning("Unable to fetch latest secret(s) due to connection error, serving secrets from last successful fetch. For more info, run with --debug")
}
return secrets
}
return nil
}
func ExpandSecrets(secrets []models.SingleEnvironmentVariable, auth models.ExpandSecretsAuthentication, projectConfigPathDir string) []models.SingleEnvironmentVariable {
expandedSecs := make(map[string]string)
interpolatedSecs := make(map[string]string)