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

Method ProcessSnapshotVSA

internal/validate/vsa/service.go:94–131  ·  view source on GitHub ↗

ProcessSnapshotVSA processes VSA generation, writing, and attestation for the application snapshot

(ctx context.Context, report applicationsnapshot.Report)

Source from the content-addressed store, hash-verified

92
93// ProcessSnapshotVSA processes VSA generation, writing, and attestation for the application snapshot
94func (s *Service) ProcessSnapshotVSA(ctx context.Context, report applicationsnapshot.Report) (string, error) {
95 generator := applicationsnapshot.NewSnapshotPredicateGenerator(report)
96 writer := applicationsnapshot.NewSnapshotPredicateWriter()
97 writer.FS = s.fs
98
99 // Generate and write Predicate (new format)
100 writtenPath, err := GenerateAndWriteSnapshotPredicate(ctx, generator, writer)
101 if err != nil {
102 return "", fmt.Errorf("failed to generate and write snapshot Predicate: %w", err)
103 }
104
105 // Calculate digest for the snapshot Predicate
106 digest, err := applicationsnapshot.GetVSAPredicateDigest(s.fs, writtenPath)
107 if err != nil {
108 return "", fmt.Errorf("failed to calculate digest for snapshot Predicate: %w", err)
109 }
110
111 // Create attestor and attest Predicate
112 // Use a meaningful name for the snapshot subject
113 snapshotName := "application-snapshot"
114 if report.Snapshot != "" {
115 snapshotName = report.Snapshot
116 }
117 attestor, err := NewAttestor(writtenPath, snapshotName, digest, s.signer)
118 if err != nil {
119 return "", fmt.Errorf("failed to create snapshot attestor: %w", err)
120 }
121
122 envelopePath, err := AttestVSA(ctx, attestor)
123 if err != nil {
124 return "", fmt.Errorf("failed to attest snapshot Predicate: %w", err)
125 }
126
127 log.WithFields(log.Fields{
128 "envelope_path": envelopePath,
129 }).Info("[VSA] Snapshot Predicate attested and envelope written")
130 return envelopePath, nil
131}
132
133// ProcessAllVSAs processes VSAs for all components and the snapshot, returning envelope paths
134func (s *Service) ProcessAllVSAs(ctx context.Context, report applicationsnapshot.Report, getGitURL func(applicationsnapshot.Component) string, getDigest func(applicationsnapshot.Component) (string, error)) (*VSAProcessingResult, error) {

Callers 2

ProcessAllVSAsMethod · 0.95

Calls 8

GetVSAPredicateDigestFunction · 0.92
NewAttestorFunction · 0.85
AttestVSAFunction · 0.85
ErrorfMethod · 0.65
InfoMethod · 0.65

Tested by 1