check for existing image before pushing to registry#1663
Merged
Conversation
Update `buf alpha plugin push` to first check if an existing image digest exists in the OCI registry. If found, we can re-use it instead of pushing a new tag of the same image. This should also greatly improve the performance of pushing images when the image already exists remotely.
pkwarren
commented
Dec 9, 2022
| Name: plugin.Name, | ||
| Version: plugin.Version, | ||
| Revision: plugin.Revision, | ||
| ImageDigest: plugin.ContainerImageDigest, |
Member
Author
There was a problem hiding this comment.
Added the image digest to the JSON printed representation (useful for debugging).
| return bufprint.NewCuratedPluginPrinter(container.Stdout()).PrintCuratedPlugin(ctx, format, curatedPlugin) | ||
| } | ||
|
|
||
| func createCuratedPluginRequest( |
Member
Author
There was a problem hiding this comment.
Refactored this out to a helper method.
| }, nil | ||
| } | ||
|
|
||
| func pushImage( |
Member
Author
There was a problem hiding this comment.
Refactored this out to a helper method.
| // - For each tag: | ||
| // - Fetch image: GET /v2/{owner}/{plugin}/manifests/{tag} | ||
| // - If image manifest matches imageID, we can use the image digest for the image. | ||
| func findExistingDigestForImageID(ctx context.Context, plugin *bufpluginconfig.Config, imageID string) (string, error) { |
Member
Author
There was a problem hiding this comment.
This is the new method which looks up an existing digest for an image ID.
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &InspectResponse{ImageID: inspect.ID}, nil |
Member
Author
There was a problem hiding this comment.
Doing an inspect here allows us to check for an image ID in the OCI registry no matter if we pass a .zip file or an image with the -image flag.
mfridman
approved these changes
Dec 9, 2022
Monirul1
pushed a commit
to Monirul1/buf
that referenced
this pull request
Apr 30, 2023
Update `buf alpha plugin push` to first check if an existing image digest exists in the OCI registry. If found, we can re-use it instead of pushing a new tag of the same image. This should also greatly improve the performance of pushing images when the image already exists remotely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update
buf alpha plugin pushto first check if an existing image digest exists in the OCI registry. If found, we can re-use it instead of pushing a new tag of the same image.This should also greatly improve the performance of pushing images when the image already exists remotely.