From 43e307b84f4855f8f5e368db3f9931a3da87582f Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 9 Dec 2022 09:42:34 -0500 Subject: [PATCH] Add podman buildx version support Fixes: https://github.com/containers/podman/issues/16793 Signed-off-by: Daniel J Walsh --- cmd/podman/images/version.go | 35 +++++++++++++++++++++++++++++++++++ test/system/070-build.bats | 6 ++++++ 2 files changed, 41 insertions(+) create mode 100644 cmd/podman/images/version.go diff --git a/cmd/podman/images/version.go b/cmd/podman/images/version.go new file mode 100644 index 0000000000..eee2c039fe --- /dev/null +++ b/cmd/podman/images/version.go @@ -0,0 +1,35 @@ +package images + +import ( + "fmt" + + "github.com/containers/buildah/define" + "github.com/containers/common/pkg/completion" + "github.com/containers/podman/v4/cmd/podman/registry" + "github.com/containers/podman/v4/cmd/podman/validate" + "github.com/spf13/cobra" +) + +var ( + versionDescription = `Print build version` + versionCmd = &cobra.Command{ + Use: "version", + Args: validate.NoArgs, + Short: "Print build version", + Long: versionDescription, + RunE: version, + ValidArgsFunction: completion.AutocompleteNone, + } +) + +func init() { + registry.Commands = append(registry.Commands, registry.CliCommand{ + Command: versionCmd, + Parent: buildxCmd, + }) +} + +func version(cmd *cobra.Command, args []string) error { + fmt.Printf("%s %s\n", define.Package, define.Version) + return nil +} diff --git a/test/system/070-build.bats b/test/system/070-build.bats index b392fd8e94..9f77df92de 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -43,6 +43,12 @@ VOLUME /a/b/c VOLUME ['/etc/foo', '/etc/bar'] EOF + run_podman info --format '{{ .Host.BuildahVersion}}' + BUILDAH_VERSION=$output + + run_podman buildx version + is "$output" "buildah ${BUILDAH_VERSION}" "buildx version contains Buildah version" + run_podman buildx build --load -t build_test --format=docker $tmpdir is "$output" ".*COMMIT" "COMMIT seen in log"