2024-04-22 12:22:15 -05:00
|
|
|
package oci
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
att "github.com/docker/attest/pkg/attestation"
|
|
|
|
|
v1 "github.com/google/go-containerregistry/pkg/v1"
|
|
|
|
|
)
|
|
|
|
|
|
2024-06-13 16:10:41 +01:00
|
|
|
type AttestationManifests struct {
|
|
|
|
|
Manifests []*AttestationManifest
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-22 12:22:15 -05:00
|
|
|
type AttestationManifest struct {
|
|
|
|
|
// attestation image details
|
|
|
|
|
Image v1.Image
|
|
|
|
|
Manifest *v1.Manifest
|
|
|
|
|
Descriptor *v1.Descriptor
|
|
|
|
|
// details of subect image
|
|
|
|
|
Name string
|
|
|
|
|
Digest string
|
|
|
|
|
Platform *v1.Platform
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AttestationResolver interface {
|
2024-06-21 11:29:16 +01:00
|
|
|
ImageDetailsResolver
|
|
|
|
|
Attestations(ctx context.Context, mediaType string) ([]*att.Envelope, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ImageDetailsResolver interface {
|
2024-04-22 12:22:15 -05:00
|
|
|
ImageName(ctx context.Context) (string, error)
|
2024-06-21 11:29:16 +01:00
|
|
|
ImagePlatform(ctx context.Context) (*v1.Platform, error)
|
2024-04-22 12:22:15 -05:00
|
|
|
ImageDigest(ctx context.Context) (string, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type MockResolver struct {
|
|
|
|
|
Envs []*att.Envelope
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r MockResolver) Attestations(ctx context.Context, mediaType string) ([]*att.Envelope, error) {
|
|
|
|
|
return r.Envs, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r MockResolver) ImageName(ctx context.Context) (string, error) {
|
|
|
|
|
return "library/alpine:latest", nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r MockResolver) ImageDigest(ctx context.Context) (string, error) {
|
|
|
|
|
return "sha256:test-digest", nil
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-21 11:29:16 +01:00
|
|
|
func (r MockResolver) ImagePlatform(ctx context.Context) (*v1.Platform, error) {
|
2024-05-31 11:02:14 +01:00
|
|
|
return ParsePlatform("linux/amd64")
|
2024-04-22 12:22:15 -05:00
|
|
|
}
|