Skip to content

Commit

Permalink
Update manifest code with new type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamstah committed Nov 22, 2021
1 parent 2adfd7f commit 02c5e17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions copy/manifest.go
Expand Up @@ -79,10 +79,10 @@ func (ic *imageCopier) determineManifestConversion(ctx context.Context, destSupp
if _, ok := supportedByDest[srcType]; ok {
prioritizedTypes.append(srcType)
}
if !ic.canModifyManifest {
// We could also drop the !ic.canModifyManifest check and have the caller
if ic.canModifyManifest != "" {
// We could also drop this check and have the caller
// make the choice; it is already doing that to an extent, to improve error
// messages. But it is nice to hide the “if !ic.canModifyManifest, do no conversion”
// messages. But it is nice to hide the “if we can't modify, do no conversion”
// special case in here; the caller can then worry (or not) only about a good UI.
logrus.Debugf("We can't modify the manifest, hoping for the best...")
return srcType, []string{}, nil // Take our chances - FIXME? Or should we fail without trying?
Expand Down
8 changes: 4 additions & 4 deletions copy/manifest_test.go
Expand Up @@ -145,7 +145,7 @@ func TestDetermineManifestConversion(t *testing.T) {
ic := &imageCopier{
manifestUpdates: &types.ManifestUpdateOptions{},
src: src,
canModifyManifest: true,
canModifyManifest: "",
}
preferredMIMEType, otherCandidates, err := ic.determineManifestConversion(context.Background(), c.destTypes, "", false)
require.NoError(t, err, c.description)
Expand All @@ -164,7 +164,7 @@ func TestDetermineManifestConversion(t *testing.T) {
ic := &imageCopier{
manifestUpdates: &types.ManifestUpdateOptions{},
src: src,
canModifyManifest: false,
canModifyManifest: "Preserving digests",
}
preferredMIMEType, otherCandidates, err := ic.determineManifestConversion(context.Background(), c.destTypes, "", false)
require.NoError(t, err, c.description)
Expand All @@ -179,7 +179,7 @@ func TestDetermineManifestConversion(t *testing.T) {
ic := &imageCopier{
manifestUpdates: &types.ManifestUpdateOptions{},
src: src,
canModifyManifest: true,
canModifyManifest: "",
}
preferredMIMEType, otherCandidates, err := ic.determineManifestConversion(context.Background(), c.destTypes, v1.MediaTypeImageManifest, false)
require.NoError(t, err, c.description)
Expand All @@ -192,7 +192,7 @@ func TestDetermineManifestConversion(t *testing.T) {
ic := imageCopier{
manifestUpdates: &types.ManifestUpdateOptions{},
src: fakeImageSource(""),
canModifyManifest: true,
canModifyManifest: "",
}
_, _, err := ic.determineManifestConversion(context.Background(), supportS1S2, "", false)
assert.Error(t, err)
Expand Down

0 comments on commit 02c5e17

Please sign in to comment.