shouldSkipPolicy checks if a policy should be skipped based on the skip list It handles both embedded and referenced policies by loading the policy spec when needed
(ctx context.Context, attachment *v1.PolicyAttachment, skipList []string)
| 365 | // shouldSkipPolicy checks if a policy should be skipped based on the skip list |
| 366 | // It handles both embedded and referenced policies by loading the policy spec when needed |
| 367 | func (pgv *PolicyGroupVerifier) shouldSkipPolicy(ctx context.Context, attachment *v1.PolicyAttachment, skipList []string) (bool, string, error) { |
| 368 | if len(skipList) == 0 { |
| 369 | return false, "", nil |
| 370 | } |
| 371 | |
| 372 | policy, _, err := pgv.loadPolicySpec(ctx, attachment) |
| 373 | if err != nil { |
| 374 | return false, "", fmt.Errorf("failed to load policy to get name: %w", err) |
| 375 | } |
| 376 | |
| 377 | policyName := policy.GetMetadata().GetName() |
| 378 | if slices.Contains(skipList, policyName) { |
| 379 | return true, policyName, nil |
| 380 | } |
| 381 | |
| 382 | return false, "", nil |
| 383 | } |
no test coverage detected