Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pkg/sysregistries/system_registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ type tomlConfig struct {
} `toml:"registries"`
}

// normalizeRegistries removes a trailing slash from registries, which is a
// normalizeRegistries removes trailing slashes from registries, which is a
// common pitfall when configuring registries (e.g., "docker.io/library/).
func normalizeRegistries(regs *registries) {
for i := range regs.Registries {
regs.Registries[i] = strings.TrimSuffix(regs.Registries[i], "/")
regs.Registries[i] = strings.TrimRight(regs.Registries[i], "/")
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/sysregistries/system_registries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func TestGetRegistriesWithBadData(t *testing.T) {
}

func TestGetRegistriesWithTrailingSlash(t *testing.T) {
answer := []string{"no-slash.com:5000/path", "one-slash.com", "two-slashes.com/"}
answer := []string{"no-slash.com:5000/path", "one-slash.com", "two-slashes.com", "three-slashes.com:5000"}
testConfig = []byte(`[registries.search]
registries= ['no-slash.com:5000/path', 'one-slash.com/', 'two-slashes.com//']
registries= ['no-slash.com:5000/path', 'one-slash.com', 'two-slashes.com//', 'three-slashes.com:5000///']
`)
// note: only one trailing gets removed
registriesConfig, err := GetRegistries(nil)
Expand Down