MCPcopy Create free account
hub / github.com/conforma/cli / loadPolicyConfig

Function loadPolicyConfig

cmd/validate/vsa.go:397–422  ·  view source on GitHub ↗

loadPolicyConfig loads the policy configuration from multiple sources

(ctx context.Context, data *validateVSAData)

Source from the content-addressed store, hash-verified

395
396// loadPolicyConfig loads the policy configuration from multiple sources
397func 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
425func extractVSAIdentifier(data *validateVSAData, args []string) string {

Callers 1

runValidateVSAFunction · 0.85

Calls 3

PreProcessPolicyFunction · 0.92
ErrorfMethod · 0.65
SpecMethod · 0.65

Tested by

no test coverage detected