Skip to content

Commit cd01930

Browse files
WwwsylviashizhMSFT
authored andcommitted
refactor: upgrade go mod to image-spec v1.1.0-rc4 and fix the missing types (#536)
Resolves: #530 Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
1 parent f3d7906 commit cd01930

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ go 1.19
44

55
require (
66
github.com/opencontainers/go-digest v1.0.0
7-
github.com/opencontainers/image-spec v1.1.0-rc.3
7+
github.com/opencontainers/image-spec v1.1.0-rc4
88
golang.org/x/sync v0.3.0
99
)

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
22
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
3-
github.com/opencontainers/image-spec v1.1.0-rc.3 h1:GT9Xon8YrLxz6N7sErbN81V8J4lOQKGUZQmI3ioviqU=
4-
github.com/opencontainers/image-spec v1.1.0-rc.3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
3+
github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0=
4+
github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
55
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
66
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=

internal/spec/artifact.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ package spec
1717

1818
import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
1919

20-
// AnnotationReferrersFiltersApplied is the annotation key for the comma separated list of filters applied by the registry in the referrers listing.
21-
const AnnotationReferrersFiltersApplied = "org.opencontainers.referrers.filtersApplied"
20+
const (
21+
// AnnotationArtifactCreated is the annotation key for the date and time on which the artifact was built, conforming to RFC 3339.
22+
AnnotationArtifactCreated = "org.opencontainers.artifact.created"
23+
24+
// AnnotationArtifactDescription is the annotation key for the human readable description for the artifact.
25+
AnnotationArtifactDescription = "org.opencontainers.artifact.description"
26+
27+
// AnnotationReferrersFiltersApplied is the annotation key for the comma separated list of filters applied by the registry in the referrers listing.
28+
AnnotationReferrersFiltersApplied = "org.opencontainers.referrers.filtersApplied"
29+
)
2230

2331
// MediaTypeArtifactManifest specifies the media type for a content descriptor.
2432
const MediaTypeArtifactManifest = "application/vnd.oci.artifact.manifest.v1+json"

pack.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func packArtifact(ctx context.Context, pusher content.Pusher, artifactType strin
9090
artifactType = MediaTypeUnknownArtifact
9191
}
9292

93-
annotations, err := ensureAnnotationCreated(opts.ManifestAnnotations, ocispec.AnnotationArtifactCreated)
93+
annotations, err := ensureAnnotationCreated(opts.ManifestAnnotations, spec.AnnotationArtifactCreated)
9494
if err != nil {
9595
return ocispec.Descriptor{}, err
9696
}

pack_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func Test_Pack_Default(t *testing.T) {
7777
}
7878

7979
// test created time annotation
80-
createdTime, ok := manifest.Annotations[ocispec.AnnotationArtifactCreated]
80+
createdTime, ok := manifest.Annotations[spec.AnnotationArtifactCreated]
8181
if !ok {
82-
t.Errorf("Annotation %s = %v, want %v", ocispec.AnnotationArtifactCreated, ok, true)
82+
t.Errorf("Annotation %s = %v, want %v", spec.AnnotationArtifactCreated, ok, true)
8383
}
8484
_, err = time.Parse(time.RFC3339, createdTime)
8585
if err != nil {
@@ -98,7 +98,7 @@ func Test_Pack_WithOptions(t *testing.T) {
9898

9999
artifactType := "application/vnd.test"
100100
annotations := map[string]string{
101-
ocispec.AnnotationArtifactCreated: "2000-01-01T00:00:00Z",
101+
spec.AnnotationArtifactCreated: "2000-01-01T00:00:00Z",
102102
}
103103
subjectManifest := []byte(`{"layers":[]}`)
104104
subjectDesc := ocispec.Descriptor{
@@ -216,7 +216,7 @@ func Test_Pack_InvalidDateTimeFormat(t *testing.T) {
216216
ctx := context.Background()
217217
opts := PackOptions{
218218
ManifestAnnotations: map[string]string{
219-
ocispec.AnnotationArtifactCreated: "2000/01/01 00:00:00",
219+
spec.AnnotationArtifactCreated: "2000/01/01 00:00:00",
220220
},
221221
}
222222
artifactType := "application/vnd.test"

0 commit comments

Comments
 (0)