-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add secret support to Terraform Providers (backend updates) (#7695)
# Description Added backend updates for secret support to Terraform Providers configuration. This includes processing secrets in recipeConfig under specific Provider configurations and environment variables. It also updates existing functions which add secrets to .gitConfig for private terraform modules. Design Document: radius-project/design-notes#47 ## Type of change - This pull request fixes a bug in Radius and has an approved issue #6539 . Fixes: #6539
- Loading branch information
1 parent
ccc385f
commit b183209
Showing
22 changed files
with
1,303 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package configloader | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/radius-project/radius/pkg/corerp/api/v20231001preview" | ||
"github.com/radius-project/radius/pkg/to" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_populateSecretData(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
secretKeys []string | ||
secrets *v20231001preview.SecretStoresClientListSecretsResponse | ||
secretStoreID string | ||
expectedSecrets map[string]map[string]string | ||
expectError bool | ||
expectedErrMsg string | ||
}{ | ||
{ | ||
name: "success", | ||
secretKeys: []string{"secretKey1", "secretKey2"}, | ||
secrets: &v20231001preview.SecretStoresClientListSecretsResponse{ | ||
SecretStoreListSecretsResult: v20231001preview.SecretStoreListSecretsResult{ | ||
Data: map[string]*v20231001preview.SecretValueProperties{ | ||
"secretKey1": { | ||
Value: to.Ptr("secretValue1"), | ||
}, | ||
"secretKey2": { | ||
Value: to.Ptr("secretValue2"), | ||
}, | ||
}}, | ||
}, | ||
secretStoreID: "testSecretStore", | ||
expectedSecrets: map[string]map[string]string{ | ||
"testSecretStore": { | ||
"secretKey1": "secretValue1", | ||
"secretKey2": "secretValue2", | ||
}, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
name: "fail with nil secrets input", | ||
secretKeys: []string{"secretKey1"}, | ||
secrets: nil, | ||
secretStoreID: "testSecretStore", | ||
expectedSecrets: nil, | ||
expectError: true, | ||
expectedErrMsg: "secrets not found for secret store ID 'testSecretStore'", | ||
}, | ||
{ | ||
name: "missing secret key", | ||
secretKeys: []string{"missingKey"}, | ||
secrets: &v20231001preview.SecretStoresClientListSecretsResponse{ | ||
SecretStoreListSecretsResult: v20231001preview.SecretStoreListSecretsResult{}, | ||
}, | ||
secretStoreID: "testSecretStore", | ||
expectedSecrets: nil, | ||
expectError: true, | ||
expectedErrMsg: "a secret key was not found in secret store 'testSecretStore'", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
secretData, err := populateSecretData(tt.secretStoreID, tt.secretKeys, tt.secrets) | ||
if tt.expectError { | ||
require.EqualError(t, err, tt.expectedErrMsg) | ||
} else { | ||
require.NoError(t, err) | ||
require.Equal(t, tt.expectedSecrets, secretData) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.