Add support for separate attestation storage repo (#62)
* Add support for separate attestation storage repo * Move mapping file types and parsing to config package * Change signature of Verify to take image/platform * Separate Attestation Resolvers to their own files (registry, layout and referrers) * Add support configuring referrers resolution style in mapping.yaml * Add registry test
This commit is contained in:
@@ -2,7 +2,6 @@ package mirror
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/docker/attest/internal/embed"
|
||||
@@ -30,12 +29,12 @@ func PushImageToRegistry(image v1.Image, imageName string) error {
|
||||
// Parse the image name
|
||||
ref, err := name.ParseReference(imageName)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse image name: %v", err)
|
||||
return fmt.Errorf("Failed to parse image name '%s': %w", imageName, err)
|
||||
}
|
||||
// Get the authenticator from the default Docker keychain
|
||||
auth, err := authn.DefaultKeychain.Resolve(ref.Context())
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get authenticator: %v", err)
|
||||
return fmt.Errorf("Failed to get authenticator: %w", err)
|
||||
}
|
||||
// Push the image to the registry
|
||||
return remote.Write(ref, image, remote.WithAuth(auth))
|
||||
@@ -45,12 +44,12 @@ func PushIndexToRegistry(image v1.ImageIndex, imageName string) error {
|
||||
// Parse the index name
|
||||
ref, err := name.ParseReference(imageName)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse image name: %v", err)
|
||||
return fmt.Errorf("Failed to parse image name: %w", err)
|
||||
}
|
||||
// Get the authenticator from the default Docker keychain
|
||||
auth, err := authn.DefaultKeychain.Resolve(ref.Context())
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get authenticator: %v", err)
|
||||
return fmt.Errorf("Failed to get authenticator: %w", err)
|
||||
}
|
||||
// Push the index to the registry
|
||||
return remote.WriteIndex(ref, image, remote.WithAuth(auth))
|
||||
|
||||
Reference in New Issue
Block a user