MCPcopy Index your code
hub / github.com/chainloop-dev/chainloop / LoadPolicyGroup

Function LoadPolicyGroup

pkg/policies/policy_groups.go:242–259  ·  view source on GitHub ↗

LoadPolicyGroup loads a group (unmarshalls it) from a group attachment

(ctx context.Context, att *v1.PolicyGroupAttachment, opts *LoadPolicyGroupOptions)

Source from the content-addressed store, hash-verified

240
241// LoadPolicyGroup loads a group (unmarshalls it) from a group attachment
242func LoadPolicyGroup(ctx context.Context, att *v1.PolicyGroupAttachment, opts *LoadPolicyGroupOptions) (*v1.PolicyGroup, *PolicyDescriptor, error) {
243 loader, err := getGroupLoader(att, opts)
244 if err != nil {
245 return nil, nil, fmt.Errorf("failed to get a loader for policy group: %w", err)
246 }
247
248 group, ref, err := loader.Load(ctx, att)
249 if err != nil {
250 return nil, nil, fmt.Errorf("failed to load policy group: %w", err)
251 }
252
253 // Validate just in case
254 if err = validateResource(group); err != nil {
255 return nil, nil, err
256 }
257
258 return group, ref, nil
259}
260
261// getGroupLoader creates a suitable group loader for a group attachment
262func getGroupLoader(attachment *v1.PolicyGroupAttachment, opts *LoadPolicyGroupOptions) (GroupLoader, error) {

Callers 4

VerifyMaterialMethod · 0.85
VerifyStatementMethod · 0.85
TestLoadGroupSpecMethod · 0.85

Calls 3

getGroupLoaderFunction · 0.85
validateResourceFunction · 0.85
LoadMethod · 0.65

Tested by 1

TestLoadGroupSpecMethod · 0.68