mirror of
https://github.com/ko-build/ko.git
synced 2025-02-01 19:14:40 +02:00
Use annotation strings from image-spec/specs-go (#407)
This commit is contained in:
parent
24e371ae56
commit
4ff8308086
1
go.mod
1
go.mod
@ -16,6 +16,7 @@ require (
|
|||||||
github.com/klauspost/compress v1.13.1 // indirect
|
github.com/klauspost/compress v1.13.1 // indirect
|
||||||
github.com/mattmoor/dep-notify v0.0.0-20190205035814-a45dec370a17
|
github.com/mattmoor/dep-notify v0.0.0-20190205035814-a45dec370a17
|
||||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||||
|
github.com/opencontainers/image-spec v1.0.2-0.20210730191737-8e42a01fb1b7
|
||||||
github.com/spf13/cobra v1.2.1
|
github.com/spf13/cobra v1.2.1
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/spf13/viper v1.8.1
|
github.com/spf13/viper v1.8.1
|
||||||
|
5
go.sum
5
go.sum
@ -387,8 +387,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-containerregistry v0.5.2-0.20210720200529-2f6fbf77f249 h1:vWUL43oVb6y5SS/wXSYirEZZTonXoKn+ac/hUh/QB+U=
|
|
||||||
github.com/google/go-containerregistry v0.5.2-0.20210720200529-2f6fbf77f249/go.mod h1:euCCtNbZ6tKqi1E72vwDj2xZcN5ttKpZLfa/wSo5iLw=
|
|
||||||
github.com/google/go-containerregistry v0.6.0 h1:niQ+8XD//kKgArIFwDVBXsWVWbde16LPdHMyNwSC8h4=
|
github.com/google/go-containerregistry v0.6.0 h1:niQ+8XD//kKgArIFwDVBXsWVWbde16LPdHMyNwSC8h4=
|
||||||
github.com/google/go-containerregistry v0.6.0/go.mod h1:euCCtNbZ6tKqi1E72vwDj2xZcN5ttKpZLfa/wSo5iLw=
|
github.com/google/go-containerregistry v0.6.0/go.mod h1:euCCtNbZ6tKqi1E72vwDj2xZcN5ttKpZLfa/wSo5iLw=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
@ -594,8 +592,9 @@ github.com/opencontainers/go-digest v1.0.0-rc1.0.20180430190053-c9281466c8b2/go.
|
|||||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
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/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||||
github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||||
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
|
|
||||||
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||||
|
github.com/opencontainers/image-spec v1.0.2-0.20210730191737-8e42a01fb1b7 h1:axgApq2XShTLwQii2zAnIkMPlhGVHbAXHUcHezu5G/k=
|
||||||
|
github.com/opencontainers/image-spec v1.0.2-0.20210730191737-8e42a01fb1b7/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||||
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||||
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||||
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||||
|
@ -42,6 +42,7 @@ import (
|
|||||||
"github.com/google/go-containerregistry/pkg/v1/mutate"
|
"github.com/google/go-containerregistry/pkg/v1/mutate"
|
||||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||||
"github.com/google/go-containerregistry/pkg/v1/types"
|
"github.com/google/go-containerregistry/pkg/v1/types"
|
||||||
|
specsv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,11 +66,6 @@ For more information see:
|
|||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
baseDigestAnnotation = "org.opencontainers.image.base.digest"
|
|
||||||
baseRefAnnotation = "org.opencontainers.image.base.name"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetBase takes an importpath and returns a base image reference and base image (or index).
|
// GetBase takes an importpath and returns a base image reference and base image (or index).
|
||||||
type GetBase func(context.Context, string) (name.Reference, Result, error)
|
type GetBase func(context.Context, string) (name.Reference, Result, error)
|
||||||
|
|
||||||
@ -784,8 +780,8 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, baseRef name.Refe
|
|||||||
}
|
}
|
||||||
|
|
||||||
withApp = mutate.Annotations(withApp, map[string]string{
|
withApp = mutate.Annotations(withApp, map[string]string{
|
||||||
baseRefAnnotation: baseRef.Name(),
|
specsv1.AnnotationBaseImageDigest: baseDigest.String(),
|
||||||
baseDigestAnnotation: baseDigest.String(),
|
specsv1.AnnotationBaseImageName: baseRef.Name(),
|
||||||
}).(v1.Image)
|
}).(v1.Image)
|
||||||
|
|
||||||
// Start from a copy of the base image's config file, and set
|
// Start from a copy of the base image's config file, and set
|
||||||
@ -933,8 +929,8 @@ func (g *gobuild) buildAll(ctx context.Context, ref string, baseRef name.Referen
|
|||||||
// (Docker manifest lists don't support annotations)
|
// (Docker manifest lists don't support annotations)
|
||||||
if baseType == types.OCIImageIndex {
|
if baseType == types.OCIImageIndex {
|
||||||
idx = mutate.Annotations(idx, map[string]string{
|
idx = mutate.Annotations(idx, map[string]string{
|
||||||
baseRefAnnotation: baseRef.Name(),
|
specsv1.AnnotationBaseImageName: baseRef.Name(),
|
||||||
baseDigestAnnotation: baseDigest.String(),
|
specsv1.AnnotationBaseImageDigest: baseDigest.String(),
|
||||||
}).(v1.ImageIndex)
|
}).(v1.ImageIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
"github.com/google/go-containerregistry/pkg/v1/empty"
|
"github.com/google/go-containerregistry/pkg/v1/empty"
|
||||||
"github.com/google/go-containerregistry/pkg/v1/mutate"
|
"github.com/google/go-containerregistry/pkg/v1/mutate"
|
||||||
"github.com/google/go-containerregistry/pkg/v1/random"
|
"github.com/google/go-containerregistry/pkg/v1/random"
|
||||||
|
specsv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func repoRootDir() (string, error) {
|
func repoRootDir() (string, error) {
|
||||||
@ -487,11 +488,11 @@ func validateImage(t *testing.T, img v1.Image, baseLayers int64, creationTime v1
|
|||||||
t.Fatalf("Manifest() = %v", err)
|
t.Fatalf("Manifest() = %v", err)
|
||||||
}
|
}
|
||||||
t.Logf("Got annotations: %v", mf.Annotations)
|
t.Logf("Got annotations: %v", mf.Annotations)
|
||||||
if _, found := mf.Annotations[baseDigestAnnotation]; !found {
|
if _, found := mf.Annotations[specsv1.AnnotationBaseImageDigest]; !found {
|
||||||
t.Errorf("image annotations did not contain base image digest")
|
t.Errorf("image annotations did not contain base image digest")
|
||||||
}
|
}
|
||||||
want := baseRef.Name()
|
want := baseRef.Name()
|
||||||
if got := mf.Annotations[baseRefAnnotation]; got != want {
|
if got := mf.Annotations[specsv1.AnnotationBaseImageName]; got != want {
|
||||||
t.Errorf("base image ref; got %q, want %q", got, want)
|
t.Errorf("base image ref; got %q, want %q", got, want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/annotations.go
generated
vendored
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/annotations.go
generated
vendored
@ -53,4 +53,10 @@ const (
|
|||||||
|
|
||||||
// AnnotationDescription is the annotation key for the human-readable description of the software packaged in the image.
|
// AnnotationDescription is the annotation key for the human-readable description of the software packaged in the image.
|
||||||
AnnotationDescription = "org.opencontainers.image.description"
|
AnnotationDescription = "org.opencontainers.image.description"
|
||||||
|
|
||||||
|
// AnnotationBaseImageDigest is the annotation key for the digest of the image's base image.
|
||||||
|
AnnotationBaseImageDigest = "org.opencontainers.image.base.digest"
|
||||||
|
|
||||||
|
// AnnotationBaseImageName is the annotation key for the image reference of the image's base image.
|
||||||
|
AnnotationBaseImageName = "org.opencontainers.image.base.name"
|
||||||
)
|
)
|
||||||
|
11
vendor/github.com/opencontainers/image-spec/specs-go/v1/config.go
generated
vendored
11
vendor/github.com/opencontainers/image-spec/specs-go/v1/config.go
generated
vendored
@ -89,9 +89,20 @@ type Image struct {
|
|||||||
// Architecture is the CPU architecture which the binaries in this image are built to run on.
|
// Architecture is the CPU architecture which the binaries in this image are built to run on.
|
||||||
Architecture string `json:"architecture"`
|
Architecture string `json:"architecture"`
|
||||||
|
|
||||||
|
// Variant is the variant of the specified CPU architecture which image binaries are intended to run on.
|
||||||
|
Variant string `json:"variant,omitempty"`
|
||||||
|
|
||||||
// OS is the name of the operating system which the image is built to run on.
|
// OS is the name of the operating system which the image is built to run on.
|
||||||
OS string `json:"os"`
|
OS string `json:"os"`
|
||||||
|
|
||||||
|
// OSVersion is an optional field specifying the operating system
|
||||||
|
// version, for example on Windows `10.0.14393.1066`.
|
||||||
|
OSVersion string `json:"os.version,omitempty"`
|
||||||
|
|
||||||
|
// OSFeatures is an optional field specifying an array of strings,
|
||||||
|
// each listing a required OS feature (for example on Windows `win32k`).
|
||||||
|
OSFeatures []string `json:"os.features,omitempty"`
|
||||||
|
|
||||||
// Config defines the execution parameters which should be used as a base when running a container using the image.
|
// Config defines the execution parameters which should be used as a base when running a container using the image.
|
||||||
Config ImageConfig `json:"config,omitempty"`
|
Config ImageConfig `json:"config,omitempty"`
|
||||||
|
|
||||||
|
9
vendor/github.com/opencontainers/image-spec/specs-go/v1/mediatype.go
generated
vendored
9
vendor/github.com/opencontainers/image-spec/specs-go/v1/mediatype.go
generated
vendored
@ -34,6 +34,10 @@ const (
|
|||||||
// referenced by the manifest.
|
// referenced by the manifest.
|
||||||
MediaTypeImageLayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip"
|
MediaTypeImageLayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip"
|
||||||
|
|
||||||
|
// MediaTypeImageLayerZstd is the media type used for zstd compressed
|
||||||
|
// layers referenced by the manifest.
|
||||||
|
MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd"
|
||||||
|
|
||||||
// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
|
// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
|
||||||
// the manifest but with distribution restrictions.
|
// the manifest but with distribution restrictions.
|
||||||
MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar"
|
MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar"
|
||||||
@ -43,6 +47,11 @@ const (
|
|||||||
// restrictions.
|
// restrictions.
|
||||||
MediaTypeImageLayerNonDistributableGzip = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip"
|
MediaTypeImageLayerNonDistributableGzip = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip"
|
||||||
|
|
||||||
|
// MediaTypeImageLayerNonDistributableZstd is the media type for zstd
|
||||||
|
// compressed layers referenced by the manifest but with distribution
|
||||||
|
// restrictions.
|
||||||
|
MediaTypeImageLayerNonDistributableZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd"
|
||||||
|
|
||||||
// MediaTypeImageConfig specifies the media type for the image configuration.
|
// MediaTypeImageConfig specifies the media type for the image configuration.
|
||||||
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
|
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
|
||||||
)
|
)
|
||||||
|
2
vendor/github.com/opencontainers/image-spec/specs-go/version.go
generated
vendored
2
vendor/github.com/opencontainers/image-spec/specs-go/version.go
generated
vendored
@ -25,7 +25,7 @@ const (
|
|||||||
VersionPatch = 1
|
VersionPatch = 1
|
||||||
|
|
||||||
// VersionDev indicates development branch. Releases will be empty string.
|
// VersionDev indicates development branch. Releases will be empty string.
|
||||||
VersionDev = ""
|
VersionDev = "-dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the specification version that the package types support.
|
// Version is the specification version that the package types support.
|
||||||
|
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
@ -199,7 +199,8 @@ github.com/modern-go/concurrent
|
|||||||
github.com/modern-go/reflect2
|
github.com/modern-go/reflect2
|
||||||
# github.com/opencontainers/go-digest v1.0.0
|
# github.com/opencontainers/go-digest v1.0.0
|
||||||
github.com/opencontainers/go-digest
|
github.com/opencontainers/go-digest
|
||||||
# github.com/opencontainers/image-spec v1.0.1
|
# github.com/opencontainers/image-spec v1.0.2-0.20210730191737-8e42a01fb1b7
|
||||||
|
## explicit
|
||||||
github.com/opencontainers/image-spec/specs-go
|
github.com/opencontainers/image-spec/specs-go
|
||||||
github.com/opencontainers/image-spec/specs-go/v1
|
github.com/opencontainers/image-spec/specs-go/v1
|
||||||
# github.com/pelletier/go-toml v1.9.3
|
# github.com/pelletier/go-toml v1.9.3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user