Skip to content

Commit

Permalink
refactor: upgrade go mod to image-spec v1.1.0-rc4 and fix the missi…
Browse files Browse the repository at this point in the history
…ng types (#536)

Resolves: #530

Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia authored and shizhMSFT committed Jul 4, 2023
1 parent f3d7906 commit cd01930
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
12 changes: 10 additions & 2 deletions internal/spec/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit cd01930

Please sign in to comment.