File: wrapper.go

package info (click to toggle)
golang-github-containers-image 5.28.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,104 kB
  • sloc: sh: 194; makefile: 73
file content (38 lines) | stat: -rw-r--r-- 1,083 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
}