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"