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

resolve image digests using HEAD request #4

Merged
merged 2 commits into from
Jan 16, 2021
Merged

Conversation

danisla
Copy link
Member

@danisla danisla commented Jan 15, 2021

  • migrate from list operation to HEAD operation to get image digest
  • add user agent Selkies_Controller/1.0 to GCR requests.

Closes #2
Closes #3

client := &http.Client{}
req, err := http.NewRequest("HEAD", url, nil)
req.Header.Set("User-Agent", "Selkies_Controller/1.0")
req.Header.Set("Accept", "application/vnd.docker.distribution.manifest.v2+json")

Choose a reason for hiding this comment

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

This will only work for certain kinds of images. I don't have enough context to know if that's fine, but e.g. this will break for multi-platform images that aren't linux/amd64, older schema 1 images (less of a concern, nowadays), or images that use OCI media types.

If this only ever talks to GCR/AR, you can use * or */* to indicate that you don't care about the media type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks this explains the weird behavior I was seeing. Without the Accept request header, I was getting docker-content-digest values back that didn't match the GCR digests. The response content-type was application/vnd.docker.distribution.manifest.v1+prettyjws

I just confirmed that adding '/' fixes this.

@danisla danisla merged commit 28b18a4 into master Jan 16, 2021
@danisla danisla deleted the optimize-image-puller-1 branch January 16, 2021 21:42
jkwong888 pushed a commit to jkwong888/selkies that referenced this pull request Jan 27, 2022
Add missing step in setup instructions
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.

Please set a user-agent for requests to GCR Use a simple HEAD request to resolve tags to digests
2 participants