Skip to content

Commit

Permalink
reverting to set. dont store kv secret value
Browse files Browse the repository at this point in the history
  • Loading branch information
x-delfino authored and lonegunmanb committed Feb 6, 2024
1 parent 511fedc commit bddecb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions internal/services/containerapps/container_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2023-05-01/containerapps"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2023-05-01/managedenvironments"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/helpers"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/validate"
Expand Down Expand Up @@ -474,8 +475,8 @@ func (r ContainerAppResource) CustomizeDiff() sdk.ResourceFunc {

if metadata.ResourceDiff.HasChange("secret") {
stateSecretsRaw, configSecretsRaw := metadata.ResourceDiff.GetChange("secret")
stateSecrets := stateSecretsRaw.([]interface{})
configSecrets := configSecretsRaw.([]interface{})
stateSecrets := stateSecretsRaw.(*schema.Set).List()
configSecrets := configSecretsRaw.(*schema.Set).List()
// Check there's not less
if len(configSecrets) < len(stateSecrets) {
return fmt.Errorf("cannot remove secrets from Container Apps at this time due to a limitation in the Container Apps Service. Please see `https://github.com/microsoft/azure-container-apps/issues/395` for more details")
Expand Down
13 changes: 8 additions & 5 deletions internal/services/containerapps/helpers/container_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ type Secret struct {

func SecretsSchema() *pluginsdk.Schema {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Optional: true,
Sensitive: true,
Elem: &pluginsdk.Resource{
Expand Down Expand Up @@ -2597,7 +2597,7 @@ func SecretsSchema() *pluginsdk.Schema {

func SecretsDataSourceSchema() *pluginsdk.Schema {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Computed: true,
Sensitive: true,
Elem: &pluginsdk.Resource{
Expand Down Expand Up @@ -2810,12 +2810,15 @@ func FlattenContainerAppSecrets(input *containerapps.SecretsCollection) []Secret
}
result := make([]Secret, 0)
for _, v := range input.Value {
result = append(result, Secret{
secret := Secret{
Identity: pointer.From(v.Identity),
KeyVaultSecretId: pointer.From(v.KeyVaultUrl),
Name: pointer.From(v.Name),
Value: pointer.From(v.Value),
})
}
if v.KeyVaultUrl == nil {
secret.Value = pointer.From(v.Value)
}
result = append(result, secret)
}

return result
Expand Down

0 comments on commit bddecb3

Please sign in to comment.