Merge pull request #47323 from thaJeztah/25.0_backport_plugin-install-digest
[25.0 backport] plugins: Fix panic when fetching by digest
This commit is contained in:
commit
45dede440e
2 changed files with 50 additions and 2 deletions
|
@ -124,6 +124,49 @@ func TestPluginInstall(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("with digest", func(t *testing.T) {
|
||||||
|
ctx := setupTest(t)
|
||||||
|
|
||||||
|
reg := registry.NewV2(t)
|
||||||
|
defer reg.Close()
|
||||||
|
|
||||||
|
name := "test-" + strings.ToLower(t.Name())
|
||||||
|
repo := path.Join(registry.DefaultURL, name+":latest")
|
||||||
|
err := plugin.Create(ctx, client, repo)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
rdr, err := client.PluginPush(ctx, repo, "")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
defer rdr.Close()
|
||||||
|
|
||||||
|
buf := &strings.Builder{}
|
||||||
|
assert.NilError(t, err)
|
||||||
|
var digest string
|
||||||
|
assert.NilError(t, jsonmessage.DisplayJSONMessagesStream(rdr, buf, 0, false, func(j jsonmessage.JSONMessage) {
|
||||||
|
if j.Aux != nil {
|
||||||
|
var r types.PushResult
|
||||||
|
assert.NilError(t, json.Unmarshal(*j.Aux, &r))
|
||||||
|
digest = r.Digest
|
||||||
|
}
|
||||||
|
}), buf)
|
||||||
|
|
||||||
|
err = client.PluginRemove(ctx, repo, types.PluginRemoveOptions{Force: true})
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
rdr, err = client.PluginInstall(ctx, repo, types.PluginInstallOptions{
|
||||||
|
Disabled: true,
|
||||||
|
RemoteRef: repo + "@" + digest,
|
||||||
|
})
|
||||||
|
assert.NilError(t, err)
|
||||||
|
defer rdr.Close()
|
||||||
|
|
||||||
|
_, err = io.Copy(io.Discard, rdr)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
_, _, err = client.PluginInspectWithRaw(ctx, repo)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("with htpasswd", func(t *testing.T) {
|
t.Run("with htpasswd", func(t *testing.T) {
|
||||||
ctx := setupTest(t)
|
ctx := setupTest(t)
|
||||||
|
|
||||||
|
|
|
@ -200,8 +200,13 @@ func withFetchProgress(cs content.Store, out progress.Output, ref reference.Name
|
||||||
switch desc.MediaType {
|
switch desc.MediaType {
|
||||||
case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
|
case ocispec.MediaTypeImageManifest, images.MediaTypeDockerSchema2Manifest:
|
||||||
tn := reference.TagNameOnly(ref)
|
tn := reference.TagNameOnly(ref)
|
||||||
tagged := tn.(reference.Tagged)
|
var tagOrDigest string
|
||||||
progress.Messagef(out, tagged.Tag(), "Pulling from %s", reference.FamiliarName(ref))
|
if tagged, ok := tn.(reference.Tagged); ok {
|
||||||
|
tagOrDigest = tagged.Tag()
|
||||||
|
} else {
|
||||||
|
tagOrDigest = tn.String()
|
||||||
|
}
|
||||||
|
progress.Messagef(out, tagOrDigest, "Pulling from %s", reference.FamiliarName(ref))
|
||||||
progress.Messagef(out, "", "Digest: %s", desc.Digest.String())
|
progress.Messagef(out, "", "Digest: %s", desc.Digest.String())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case
|
case
|
||||||
|
|
Loading…
Reference in a new issue