-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add private.UnparsedImage, use it for signature handling
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
- Loading branch information
Showing
15 changed files
with
100 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package unparsedimage | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/containers/image/v5/internal/private" | ||
"github.com/containers/image/v5/internal/signature" | ||
"github.com/containers/image/v5/types" | ||
) | ||
|
||
// wrapped provides the private.UnparsedImage operations | ||
// for an object that only implements types.UnparsedImage | ||
type wrapped struct { | ||
types.UnparsedImage | ||
} | ||
|
||
// FromPublic(unparsed) returns an object that provides the private.UnparsedImage API | ||
func FromPublic(unparsed types.UnparsedImage) private.UnparsedImage { | ||
if unparsed2, ok := unparsed.(private.UnparsedImage); ok { | ||
return unparsed2 | ||
} | ||
return &wrapped{ | ||
UnparsedImage: unparsed, | ||
} | ||
} | ||
|
||
// UntrustedSignatures is like ImageSource.GetSignaturesWithFormat, but the result is cached; it is OK to call this however often you need. | ||
func (w *wrapped) UntrustedSignatures(ctx context.Context) ([]signature.Signature, error) { | ||
sigs, err := w.Signatures(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res := []signature.Signature{} | ||
for _, sig := range sigs { | ||
res = append(res, signature.SimpleSigningFromBlob(sig)) | ||
} | ||
return res, nil | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.