Skip to content

Commit

Permalink
Explicitly fail encryption/decryption if we can't change the manifest
Browse files Browse the repository at this point in the history
We would fail with an internal error anyway, this fails explicitly.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Apr 25, 2023
1 parent 9008597 commit cd5d287
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions copy/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (ic *imageCopier) blobPipelineDecryptionStep(stream *sourceStream, srcInfo
}, nil
}

if ic.cannotModifyManifestReason != "" {
return nil, fmt.Errorf("layer %s should be decrypted, but we can’t modify the manifest: %s", srcInfo.Digest, ic.cannotModifyManifestReason)
}

desc := imgspecv1.Descriptor{
Annotations: stream.info.Annotations,
}
Expand Down Expand Up @@ -83,6 +87,10 @@ func (ic *imageCopier) blobPipelineEncryptionStep(stream *sourceStream, toEncryp
}, nil
}

if ic.cannotModifyManifestReason != "" {
return nil, fmt.Errorf("layer %s should be encrypted, but we can’t modify the manifest: %s", srcInfo.Digest, ic.cannotModifyManifestReason)
}

var annotations map[string]string
if !decryptionStep.decrypting {
annotations = srcInfo.Annotations
Expand Down

0 comments on commit cd5d287

Please sign in to comment.