Add builder identity annotations.
Use io.podman.version and fix inspect tests Signed-off-by: caiges <caigesn@gmail.com> Closes: #1917 Approved by: TomSweeneyRedHat
This commit is contained in:
parent
c5244fe0bf
commit
9ff68b3cde
|
@ -162,6 +162,9 @@ func commitCmd(c *cobra.Command, args []string, iopts commitInputOptions) error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add builder identity information.
|
||||||
|
builder.SetLabel(buildah.BuilderIdentityAnnotation, buildah.Version)
|
||||||
|
|
||||||
options := buildah.CommitOptions{
|
options := buildah.CommitOptions{
|
||||||
PreferredManifestType: format,
|
PreferredManifestType: format,
|
||||||
Compression: compress,
|
Compression: compress,
|
||||||
|
|
|
@ -29,6 +29,13 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BuilderIdentityAnnotation is the name of the annotation key containing
|
||||||
|
// the name and version of the producer of the image stored as an
|
||||||
|
// annotation on commit.
|
||||||
|
BuilderIdentityAnnotation = "io.buildah.version"
|
||||||
|
)
|
||||||
|
|
||||||
// CommitOptions can be used to alter how an image is committed.
|
// CommitOptions can be used to alter how an image is committed.
|
||||||
type CommitOptions struct {
|
type CommitOptions struct {
|
||||||
// PreferredManifestType is the preferred type of image manifest. The
|
// PreferredManifestType is the preferred type of image manifest. The
|
||||||
|
|
|
@ -103,3 +103,15 @@ load helpers
|
||||||
buildah rm $cid
|
buildah rm $cid
|
||||||
buildah rmi -a
|
buildah rmi -a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "commit-builder-identity" {
|
||||||
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
||||||
|
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image
|
||||||
|
|
||||||
|
buildah_version=$(buildah --version | awk '{ print $3 }')
|
||||||
|
version=$(buildah inspect --format '{{ index .Docker.Config.Labels "io.buildah.version"}}' alpine-image)
|
||||||
|
|
||||||
|
[ "$version" == "$buildah_version" ]
|
||||||
|
buildah rm $cid
|
||||||
|
buildah rmi -f alpine-image
|
||||||
|
}
|
||||||
|
|
|
@ -14,11 +14,13 @@ load helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "inspect" {
|
@test "inspect" {
|
||||||
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
|
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
|
||||||
run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" alpine-image
|
run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" alpine-image
|
||||||
|
|
||||||
|
buildah_version=$(buildah --version | awk '{ print $3 }')
|
||||||
out1=$(buildah inspect --format '{{.OCIv1.Config}}' alpine)
|
out1=$(buildah inspect --format '{{.OCIv1.Config}}' alpine)
|
||||||
out2=$(buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image)
|
out2=$(buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image | sed "s/io.buildah.version:${buildah_version}//g")
|
||||||
|
|
||||||
[ "$out1" != "" ]
|
[ "$out1" != "" ]
|
||||||
[ "$out1" = "$out2" ]
|
[ "$out1" = "$out2" ]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue