Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions provider/aws/registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
return nil, log.Error(err)
}

id := fmt.Sprintf("%x", sha256.New().Sum([]byte(server)))
id := legacyServerIdentifier(server)

Check warning on line 78 in provider/aws/registries.go

View check run for this annotation

Codecov / codecov/patch

provider/aws/registries.go#L78

Added line #L78 was not covered by tests

if err := p.SettingPut(fmt.Sprintf("system/registries/%s", id), string(data)); err != nil {
if err := p.SettingPut("system/registries/"+id, string(data)); err != nil {

Check warning on line 80 in provider/aws/registries.go

View check run for this annotation

Codecov / codecov/patch

provider/aws/registries.go#L80

Added line #L80 was not covered by tests
return nil, log.Error(err)
}

Expand All @@ -93,7 +93,8 @@
func (p *Provider) RegistryRemove(server string) error {
log := Logger.At("RegistryRemove").Namespace("server=%q", server).Start()

key := fmt.Sprintf("system/registries/%x", sha256.New().Sum([]byte(server)))
id := legacyServerIdentifier(server)
key := "system/registries/" + id

if _, err := p.SettingExists(key); err != nil {
return log.Error(errorNotFound(fmt.Sprintf("registry not found: %s", server)))
Expand Down Expand Up @@ -135,3 +136,13 @@

return registries, log.Success()
}

var hashOfNothing = sha256.New().Sum(nil)

// legacyServerIdentifier generates a hex string from a server.
// This format is suboptimal, but it must be preserved for compatibility reasons
// as deviation from this format would orphan registry settings.
// This function exist to make the behavior more apparent.
func legacyServerIdentifier(server string) string {
return fmt.Sprintf("%x", append([]byte(server), hashOfNothing[:]...))
}