loadPolicyConfig loads the policy configuration from multiple sources
(ctx context.Context, data *validateVSAData)
| 395 | |
| 396 | // loadPolicyConfig loads the policy configuration from multiple sources |
| 397 | func loadPolicyConfig(ctx context.Context, data *validateVSAData) error { |
| 398 | // Resolve policy configuration using the standard utility function |
| 399 | policyConfiguration, err := validate_utils.GetPolicyConfig(ctx, data.policyConfig) |
| 400 | if err != nil { |
| 401 | return fmt.Errorf("failed to get policy configuration: %w", err) |
| 402 | } |
| 403 | |
| 404 | // Use the standard policy processing like other validation commands |
| 405 | policyOptions := policy.Options{ |
| 406 | EffectiveTime: data.effectiveTime, |
| 407 | PolicyRef: policyConfiguration, // Use the resolved policy configuration |
| 408 | PublicKey: data.publicKeyPath, // Use the available publicKeyPath field |
| 409 | // Note: RekorURL is not available in VSA command, will use default |
| 410 | } |
| 411 | |
| 412 | // Process policy using the standard PreProcessPolicy function |
| 413 | processedPolicy, _, err := policy.PreProcessPolicy(ctx, policyOptions) |
| 414 | if err != nil { |
| 415 | return fmt.Errorf("failed to process policy: %w", err) |
| 416 | } |
| 417 | |
| 418 | // Store the policy spec for comparison |
| 419 | data.policySpec = processedPolicy.Spec() |
| 420 | |
| 421 | return nil |
| 422 | } |
| 423 | |
| 424 | // extractVSAIdentifier extracts the VSA identifier from args or data |
| 425 | func extractVSAIdentifier(data *validateVSAData, args []string) string { |
no test coverage detected