mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-09-03 00:47:17 +00:00
fix: [sc-112114] registry collector failed to talk to Replicated private registry (#1613)
decode auth for registry secret
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user