MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Load

Method Load

pkg/policies/group_loader.go:42–67  ·  view source on GitHub ↗
(_ context.Context, attachment *v1.PolicyGroupAttachment)

Source from the content-addressed store, hash-verified

40type FileGroupLoader struct{}
41
42func (l *FileGroupLoader) Load(_ context.Context, attachment *v1.PolicyGroupAttachment) (*v1.PolicyGroup, *PolicyDescriptor, error) {
43 var (
44 raw []byte
45 err error
46 )
47
48 // First remove the digest if present
49 ref, wantDigest := ExtractDigest(attachment.GetRef())
50 filePath, err := ensureScheme(ref, fileScheme)
51 if err != nil {
52 return nil, nil, err
53 }
54
55 raw, err = os.ReadFile(filepath.Clean(filePath))
56 if err != nil {
57 return nil, nil, fmt.Errorf("loading policy spec: %w", err)
58 }
59
60 var group v1.PolicyGroup
61 d, err := unmarshallResource(raw, ref, wantDigest, &group)
62 if err != nil {
63 return nil, nil, fmt.Errorf("unmarshalling policy spec: %w", err)
64 }
65
66 return &group, d, nil
67}
68
69// HTTPSGroupLoader loader loads policies from HTTP or HTTPS references
70type HTTPSGroupLoader struct{}

Callers

nothing calls this directly

Calls 4

ExtractDigestFunction · 0.85
ensureSchemeFunction · 0.85
unmarshallResourceFunction · 0.85
GetRefMethod · 0.45

Tested by

no test coverage detected