Skip to content

Commit

Permalink
Add Azure Artifacts credentials after credential metadata is added (#291
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JamieMagee authored Mar 5, 2024
1 parent 8e85cac commit 44efe37
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cmd/dependabot/internal/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,22 @@ func processInput(input *model.Input, flags *UpdateFlags) {
"host": "dev.azure.com",
})
}
}

// Calculate the credentials-metadata as it cannot be provided by the user anymore.
input.Job.CredentialsMetadata = []model.Credential{}
for _, credential := range input.Credentials {
entry := make(map[string]any)
for k, v := range credential {
// Updater does not get credentials.
if k != "username" && k != "token" && k != "password" && k != "key" && k != "auth-key" {
entry[k] = v
}
}
input.Job.CredentialsMetadata = append(input.Job.CredentialsMetadata, entry)
}

if hasLocalAzureToken && azureRepo != nil {
// Add the Azure Artifacts credentials for each host if the package manager is supported.
if _, ok := azureArtifactsPackageManagerCredentialType[input.Job.PackageManager]; ok {
// All Azure Artifacts hosts
Expand All @@ -363,19 +378,6 @@ func processInput(input *model.Input, flags *UpdateFlags) {
log.Printf("Skipping Azure Artifacts credentials for %s package manager.", input.Job.PackageManager)
}
}

// Calculate the credentials-metadata as it cannot be provided by the user anymore.
input.Job.CredentialsMetadata = []model.Credential{}
for _, credential := range input.Credentials {
entry := make(map[string]any)
for k, v := range credential {
// Updater does not get credentials.
if k != "username" && k != "token" && k != "password" && k != "key" && k != "auth-key" {
entry[k] = v
}
}
input.Job.CredentialsMetadata = append(input.Job.CredentialsMetadata, entry)
}
}

func doesStdinHaveData() bool {
Expand Down

0 comments on commit 44efe37

Please sign in to comment.