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

Do-Not-Merge: Use default keychain to authenticate image pulls #78

Closed
wants to merge 1 commit into from

Conversation

fbiville
Copy link
Contributor

Fixes #74.

@fbiville
Copy link
Contributor Author

fbiville commented Dec 11, 2018

This is quite ugly but I've tested this change successfully against a Docker image in a private repository and against GCR.

tokenAtoms := strings.SplitN(string(tokenBytes), ":", 2)
rc, err := d.ImagePull(context.Background(), ref, dockertypes.ImagePullOptions{
RegistryAuth: base64.StdEncoding.EncodeToString([]byte(
fmt.Sprintf(`{"username": "%s", "password": "%s"}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference, _ := name.ParseReference(ref, name.WeakValidation)
authenticator, _ := authn.DefaultKeychain.Resolve(reference.Context().Registry)
encodedHeader, _ := authenticator.Authorization()
encodedToken := strings.Replace(encodedHeader, "Basic ", "", 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fbiville
Copy link
Contributor Author

This should not be merged as there is, I hope, a more robust approach or at least similar library code that does what this change does.

@ekcasey
Copy link
Member

ekcasey commented Dec 12, 2018

Our docker pull code moved to buildpack/lifecycle. I opened a PR with similar changes buildpacks/lifecycle#48.

The implementation is very similar to the one you contributed.

@fbiville
Copy link
Contributor Author

Great news, @ekcasey.
I suppose I can close this PR?

@fbiville fbiville closed this Dec 17, 2018
@fbiville fbiville deleted the issue_74 branch December 17, 2018 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants