Skip to content

Commit ee641d3

Browse files
committed
use OCI spec to refer to annotation constants
1 parent 8430ca0 commit ee641d3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cmd/bob/build.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/function61/gokit/os/osutil"
1515
"github.com/function61/turbobob/pkg/bobfile"
1616
"github.com/function61/turbobob/pkg/versioncontrol"
17+
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
1718
"github.com/spf13/cobra"
1819
)
1920

@@ -165,18 +166,18 @@ func buildAndPushOneDockerImage(dockerImage bobfile.DockerImageSpec, buildCtx *B
165166
annotationsKeyValues = append(annotationsKeyValues, fmt.Sprintf("%s=%s", key, value))
166167
}
167168

168-
annotate("org.opencontainers.image.title", buildCtx.Bobfile.ProjectName)
169-
annotate("org.opencontainers.image.created", time.Now().UTC().Format(time.RFC3339))
170-
annotate("org.opencontainers.image.revision", buildCtx.RevisionId.RevisionId)
171-
annotate("org.opencontainers.image.version", buildCtx.RevisionId.FriendlyRevisionId)
172-
annotate("org.opencontainers.image.description", buildCtx.Bobfile.Meta.Description)
169+
annotate(ociv1.AnnotationTitle, buildCtx.Bobfile.ProjectName)
170+
annotate(ociv1.AnnotationCreated, time.Now().UTC().Format(time.RFC3339))
171+
annotate(ociv1.AnnotationRevision, buildCtx.RevisionId.RevisionId)
172+
annotate(ociv1.AnnotationVersion, buildCtx.RevisionId.FriendlyRevisionId)
173+
annotate(ociv1.AnnotationDescription, buildCtx.Bobfile.Meta.Description)
173174

174175
// "URL to get source code for building the image"
175-
annotate("org.opencontainers.image.source", buildCtx.RepositoryURL)
176+
annotate(ociv1.AnnotationSource, buildCtx.RepositoryURL)
176177
// "URL to find more information on the image"
177-
annotate("org.opencontainers.image.url", firstNonEmpty(buildCtx.Bobfile.Meta.Website, buildCtx.RepositoryURL))
178+
annotate(ociv1.AnnotationURL, firstNonEmpty(buildCtx.Bobfile.Meta.Website, buildCtx.RepositoryURL))
178179
// "URL to get documentation on the image"
179-
annotate("org.opencontainers.image.documentation", firstNonEmpty(buildCtx.Bobfile.Meta.Documentation, buildCtx.RepositoryURL))
180+
annotate(ociv1.AnnotationDocumentation, firstNonEmpty(buildCtx.Bobfile.Meta.Documentation, buildCtx.RepositoryURL))
180181

181182
// "" => "."
182183
// "Dockerfile" => "."

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/function61/gokit v0.0.0-20230408192420-6f1204d63c2b
88
github.com/mattn/go-runewidth v0.0.13 // indirect
99
github.com/moby/buildkit v0.10.4
10+
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
1011
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
1112
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4
1213
github.com/spf13/cobra v1.6.1

0 commit comments

Comments
 (0)