@@ -23,6 +23,7 @@ import (
23
23
"github.com/google/go-containerregistry/pkg/v1/tarball"
24
24
typesv1 "github.com/google/go-containerregistry/pkg/v1/types"
25
25
26
+ "github.com/docker/labs-brown-tape/attest/manifest"
26
27
attestTypes "github.com/docker/labs-brown-tape/attest/types"
27
28
manifestTypes "github.com/docker/labs-brown-tape/manifest/types"
28
29
)
@@ -223,6 +224,10 @@ func (c *Client) PushArtefact(ctx context.Context, destinationRef, sourceDir str
223
224
}
224
225
defer os .RemoveAll (tmpDir )
225
226
227
+ _ , err = SemVerFromAttestations (ctx , sourceAttestations ... )
228
+ if err != nil {
229
+ return "" , err
230
+ }
226
231
tmpFile := filepath .Join (tmpDir , "artefact.tgz" )
227
232
228
233
outputFile , err := os .OpenFile (tmpFile , os .O_RDWR | os .O_CREATE | os .O_EXCL , regularFileMode )
@@ -348,6 +353,20 @@ func (c *Client) PushArtefact(ctx context.Context, destinationRef, sourceDir str
348
353
return tagAlias .String () + "@" + digest .String (), err
349
354
}
350
355
356
+ func SemVerFromAttestations (ctx context.Context , sourceAttestations ... attestTypes.Statement ) (string , error ) {
357
+ statements := attestTypes .FilterByPredicateType (manifest .ManifestDirPredicateType , sourceAttestations )
358
+ if len (statements ) == 0 {
359
+ return "" , fmt .Errorf ("VCS provinance attestion (%q) not found" , manifest .ManifestDirPredicateType )
360
+ }
361
+ if len (statements ) > 1 {
362
+ return "" , fmt .Errorf ("too many attestations of type %q found, expected 1" , manifest .ManifestDirPredicateType )
363
+ }
364
+
365
+ _ = manifest .MakeDirContentsStatementFrom (statements [0 ])
366
+
367
+ return "" , nil
368
+ }
369
+
351
370
func makeDescriptorWithPlatform () Descriptor {
352
371
return Descriptor {
353
372
Platform : & Platform {
0 commit comments