Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Fix] - azuredevops_variable_group - Exclude disabled secrets #947

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ func expandVariableGroupParameters(clients *client.AggregatedClient, d *schema.R
variableGroup.ProviderData = taskagent.AzureKeyVaultVariableGroupProviderData{
ServiceEndpointId: &serviceEndpointUUID,
Vault: &kvName,
LastRefreshedOn: &azuredevops.Time{Time: time.Now()},
}

variableGroup.Type = converter.String(azureKeyVaultType)
Expand All @@ -437,7 +438,7 @@ func expandVariableGroupParameters(clients *client.AggregatedClient, d *schema.R
}

if len(invalidVariables) > 0 {
return nil, nil, fmt.Errorf("Invalid Key Vault secret: ( %s ) , can not find in Azure Key Vault: ( %s ) ",
return nil, nil, fmt.Errorf("Invalid Key Vault secret: ( %s ) , can not find in Azure Key Vault or the secret has been disbled: ( %s ) ",
strings.Join(invalidVariables, ","),
kvName)
} else {
Expand Down Expand Up @@ -678,6 +679,10 @@ func searchAzureKVSecrets(clients *client.AggregatedClient, projectID, kvName, s
IsSecret: converter.Bool(true),
Enabled: secret.Enabled,
}

if secret.ContentType == nil {
kvVariable.ContentType = converter.String("")
}
if secret.Expire != nil {
kvVariable.Expires = &azuredevops.Time{
Time: time.Unix(*secret.Expire, 0),
Expand All @@ -691,7 +696,7 @@ func searchAzureKVSecrets(clients *client.AggregatedClient, projectID, kvName, s
if len(secretNames) == 0 {
break
}
if _, ok := secretNames[name]; ok {
if _, ok := secretNames[name]; ok && *secret.Enabled {
kvSecrets[name] = secret
delete(secretNames, name)
}
Expand Down