Skip to content

Commit

Permalink
fix python-index not added to metadata (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman authored Jan 2, 2024
1 parent c7aa6e7 commit f8419d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
20 changes: 6 additions & 14 deletions cmd/dependabot/internal/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,20 +363,12 @@ func processInput(input *model.Input, flags *UpdateFlags) {
if len(input.Job.CredentialsMetadata) == 0 {
log.Println("Adding missing credentials-metadata into job definition")
for _, credential := range input.Credentials {
entry := map[string]any{
"type": credential["type"],
}
if credential["host"] != nil {
entry["host"] = credential["host"]
}
if credential["url"] != nil {
entry["url"] = credential["url"]
}
if credential["registry"] != nil {
entry["registry"] = credential["registry"]
}
if credential["replaces-base"] != nil {
entry["replaces-base"] = credential["replaces-base"]
entry := make(map[string]any)
for k, v := range credential {
// Updater does not get credentials.
if k != "token" && k != "password" {
entry[k] = v
}
}
input.Job.CredentialsMetadata = append(input.Job.CredentialsMetadata, entry)
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/dependabot/internal/cmd/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func Test_processInput(t *testing.T) {
"host": "example.com",
"registry": "registry.example.com",
"url": "https://example.com",
"python-index": "https://example.com",
"replaces-base": "true",
"password": "password",
},
Expand All @@ -77,13 +78,14 @@ func Test_processInput(t *testing.T) {
if len(input.Job.CredentialsMetadata) != 1 {
t.Fatal("expected credentials metadata to be added")
}
if !reflect.DeepEqual(input.Job.CredentialsMetadata[0], model.Credential{
if !reflect.DeepEqual(input.Job.CredentialsMetadata, []model.Credential{{
"type": "git_source",
"host": "example.com",
"registry": "registry.example.com",
"url": "https://example.com",
"python-index": "https://example.com",
"replaces-base": "true",
}) {
}}) {
t.Error("expected credentials metadata to be added")
}
})
Expand Down

0 comments on commit f8419d2

Please sign in to comment.