diff --git a/go.mod b/go.mod index 35971e63..747de6eb 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.19 require ( github.com/opencontainers/go-digest v1.0.0 - github.com/opencontainers/image-spec v1.1.0-rc.3 + github.com/opencontainers/image-spec v1.1.0-rc4 golang.org/x/sync v0.3.0 ) diff --git a/go.sum b/go.sum index bc26d7f8..e391513b 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc.3 h1:GT9Xon8YrLxz6N7sErbN81V8J4lOQKGUZQmI3ioviqU= -github.com/opencontainers/image-spec v1.1.0-rc.3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= +github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= diff --git a/internal/spec/artifact.go b/internal/spec/artifact.go index 8aa8e79e..7f801fd9 100644 --- a/internal/spec/artifact.go +++ b/internal/spec/artifact.go @@ -17,8 +17,16 @@ package spec import ocispec "github.com/opencontainers/image-spec/specs-go/v1" -// AnnotationReferrersFiltersApplied is the annotation key for the comma separated list of filters applied by the registry in the referrers listing. -const AnnotationReferrersFiltersApplied = "org.opencontainers.referrers.filtersApplied" +const ( + // AnnotationArtifactCreated is the annotation key for the date and time on which the artifact was built, conforming to RFC 3339. + AnnotationArtifactCreated = "org.opencontainers.artifact.created" + + // AnnotationArtifactDescription is the annotation key for the human readable description for the artifact. + AnnotationArtifactDescription = "org.opencontainers.artifact.description" + + // AnnotationReferrersFiltersApplied is the annotation key for the comma separated list of filters applied by the registry in the referrers listing. + AnnotationReferrersFiltersApplied = "org.opencontainers.referrers.filtersApplied" +) // MediaTypeArtifactManifest specifies the media type for a content descriptor. const MediaTypeArtifactManifest = "application/vnd.oci.artifact.manifest.v1+json" diff --git a/pack.go b/pack.go index 81fc12ca..872afa51 100644 --- a/pack.go +++ b/pack.go @@ -90,7 +90,7 @@ func packArtifact(ctx context.Context, pusher content.Pusher, artifactType strin artifactType = MediaTypeUnknownArtifact } - annotations, err := ensureAnnotationCreated(opts.ManifestAnnotations, ocispec.AnnotationArtifactCreated) + annotations, err := ensureAnnotationCreated(opts.ManifestAnnotations, spec.AnnotationArtifactCreated) if err != nil { return ocispec.Descriptor{}, err } diff --git a/pack_test.go b/pack_test.go index 582ef128..505f1b79 100644 --- a/pack_test.go +++ b/pack_test.go @@ -77,9 +77,9 @@ func Test_Pack_Default(t *testing.T) { } // test created time annotation - createdTime, ok := manifest.Annotations[ocispec.AnnotationArtifactCreated] + createdTime, ok := manifest.Annotations[spec.AnnotationArtifactCreated] if !ok { - t.Errorf("Annotation %s = %v, want %v", ocispec.AnnotationArtifactCreated, ok, true) + t.Errorf("Annotation %s = %v, want %v", spec.AnnotationArtifactCreated, ok, true) } _, err = time.Parse(time.RFC3339, createdTime) if err != nil { @@ -98,7 +98,7 @@ func Test_Pack_WithOptions(t *testing.T) { artifactType := "application/vnd.test" annotations := map[string]string{ - ocispec.AnnotationArtifactCreated: "2000-01-01T00:00:00Z", + spec.AnnotationArtifactCreated: "2000-01-01T00:00:00Z", } subjectManifest := []byte(`{"layers":[]}`) subjectDesc := ocispec.Descriptor{ @@ -216,7 +216,7 @@ func Test_Pack_InvalidDateTimeFormat(t *testing.T) { ctx := context.Background() opts := PackOptions{ ManifestAnnotations: map[string]string{ - ocispec.AnnotationArtifactCreated: "2000/01/01 00:00:00", + spec.AnnotationArtifactCreated: "2000/01/01 00:00:00", }, } artifactType := "application/vnd.test"