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

fix: [sc-112114] registry collector failed to talk to Replicated private registry #1613

Merged
merged 1 commit into from
Sep 13, 2024
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
9 changes: 8 additions & 1 deletion pkg/collect/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ func getImageAuthConfigFromData(imageRef types.ImageReference, pullSecrets *v1be
// docker.io auth uses auth, e.g. auth: <base64_encoded_username_password>
// username and password can't contain colon
// at least according to https://github.com/docker/cli/blob/v27.0.3/cli/config/configfile/file.go#L247
parts := strings.Split(string(auth.Auth), ":")
// fallback to not decode for compatibility
authStr := auth.Auth
decodedAuth, err := base64.StdEncoding.DecodeString(authStr)
if err == nil {
authStr = string(decodedAuth)
}

parts := strings.Split(authStr, ":")
if len(parts) != 2 {
return nil, errors.Errorf("expected 2 parts in the auth string, but found %d", len(parts))
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/collect/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func TestGetImageAuthConfigFromData(t *testing.T) {
expectedPassword: "sa-key",
expectedError: false,
},
{
name: "proxy.replicated.com auth base64 encoded",
imageName: "proxy.replicated.com/app-slug/myimage",
dockerConfigJSON: `{"auths":{"proxy.replicated.com":{"auth":"bGljZW5zZV9pZF8xOmxpY2Vuc2VfaWRfMQ=="}}}`,
expectedUsername: "license_id_1",
expectedPassword: "license_id_1",
expectedError: false,
},
}

for _, test := range tests {
Expand Down
Loading