(_ context.Context, attachment *v1.PolicyGroupAttachment)
| 40 | type FileGroupLoader struct{} |
| 41 | |
| 42 | func (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 |
| 70 | type HTTPSGroupLoader struct{} |
nothing calls this directly
no test coverage detected