Support pulling plugins by digest (#3803)
Previously `WithPlugins` only supported passing image URIs "by tag" -- e.g. `gcr.io/my-repo/my-image:v0.1.2`. With this commit, we add support for pulling "by digest" -- e.g. `gcr.io/my-repo/my-image@sha256:a75f9e8c3ced3943515f249597be389f8233e1258d289b11184796edceaa7dab` Signed-off-by: Eric Fried <efried@redhat.com>pull/3814/head
parent
5601758723
commit
7566962b95
|
@ -0,0 +1 @@
|
|||
Support pulling plugin images by digest
|
|
@ -60,11 +60,18 @@ func getName(image string) string {
|
|||
start = slashIndex + 1
|
||||
}
|
||||
|
||||
// this removes the tag
|
||||
colonIndex := strings.LastIndex(image, ":")
|
||||
// If the image spec is by digest, remove the digest.
|
||||
// If it is by tag, remove the tag.
|
||||
// Otherwise (implicit :latest) leave it alone.
|
||||
end := len(image)
|
||||
if colonIndex > 0 {
|
||||
end = colonIndex
|
||||
atIndex := strings.LastIndex(image, "@")
|
||||
if atIndex > 0 {
|
||||
end = atIndex
|
||||
} else {
|
||||
colonIndex := strings.LastIndex(image, ":")
|
||||
if colonIndex > 0 {
|
||||
end = colonIndex
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/distribution/distribution/blob/main/docs/spec/api.md#overview
|
||||
|
|
|
@ -87,6 +87,11 @@ func TestGetName(t *testing.T) {
|
|||
image: "projects.registry.vmware.com/tanzu.migrator/route-2-httpproxy:myTag",
|
||||
expected: "tanzu-migrator-route-2-httpproxy",
|
||||
},
|
||||
{
|
||||
name: "pull by digest",
|
||||
image: "quay.io/vmware-tanzu/velero@sha256:a75f9e8c3ced3943515f249597be389f8233e1258d289b11184796edceaa7dab",
|
||||
expected: "vmware-tanzu-velero",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
Loading…
Reference in New Issue