Skip to content

Commit

Permalink
update as code review suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Mar 18, 2024
1 parent 902df54 commit 1007c8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
9 changes: 9 additions & 0 deletions internal/services/containerapps/container_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ func (r ContainerAppResource) CustomizeDiff() sdk.ResourceFunc {
}
}
}

for _, s := range app.Secrets {
if s.KeyVaultSecretId != "" && s.Identity == "" {
return fmt.Errorf("secret %s must supply identity for key vault secret id", s.Name)
}
if s.KeyVaultSecretId == "" && s.Identity != "" {
return fmt.Errorf("secret %s must supply key vault secret id when specifying identity", s.Name)
}
}
return nil
},
}
Expand Down
13 changes: 0 additions & 13 deletions internal/services/containerapps/helpers/container_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -2631,16 +2631,6 @@ func SecretsDataSourceSchema() *pluginsdk.Schema {
}
}

func validateContainerSecret(s Secret) error {
if s.KeyVaultSecretId != "" && s.Identity == "" {
return fmt.Errorf("must supply identity for key vault secret id")
}
if s.KeyVaultSecretId == "" && s.Identity != "" {
return fmt.Errorf("must supply key vault secret id when specifying identity")
}
return nil
}

func ExpandContainerSecrets(input []Secret) (*[]containerapps.Secret, error) {
if len(input) == 0 {
return nil, nil
Expand All @@ -2649,9 +2639,6 @@ func ExpandContainerSecrets(input []Secret) (*[]containerapps.Secret, error) {
result := make([]containerapps.Secret, 0)

for _, v := range input {
if err := validateContainerSecret(v); err != nil {
return nil, err
}
result = append(result, containerapps.Secret{
Identity: pointer.To(v.Identity),
KeyVaultUrl: pointer.To(v.KeyVaultSecretId),
Expand Down

0 comments on commit 1007c8a

Please sign in to comment.