mirror of
https://github.com/containers/podman.git
synced 2025-10-19 12:12:36 +08:00
add quadlet -version
flag
I recently wanted to check which version of Quadlet I was using and found a `-version` flag to be missing. Since Quadlet and Podman are bundled together, it seems reasonable to me for them to share the same version. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/systemd/parser"
|
"github.com/containers/podman/v4/pkg/systemd/parser"
|
||||||
"github.com/containers/podman/v4/pkg/systemd/quadlet"
|
"github.com/containers/podman/v4/pkg/systemd/quadlet"
|
||||||
|
"github.com/containers/podman/v4/version/rawversion"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This commandline app is the systemd generator (system and user,
|
// This commandline app is the systemd generator (system and user,
|
||||||
@ -27,6 +28,7 @@ var (
|
|||||||
noKmsgFlag bool
|
noKmsgFlag bool
|
||||||
isUserFlag bool // True if run as quadlet-user-generator executable
|
isUserFlag bool // True if run as quadlet-user-generator executable
|
||||||
dryRunFlag bool // True if -dryrun is used
|
dryRunFlag bool // True if -dryrun is used
|
||||||
|
versionFlag bool // True if -version is used
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -298,6 +300,11 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if versionFlag {
|
||||||
|
fmt.Printf("%s\n", rawversion.RawVersion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if verboseFlag || dryRunFlag {
|
if verboseFlag || dryRunFlag {
|
||||||
enableDebug()
|
enableDebug()
|
||||||
}
|
}
|
||||||
@ -389,5 +396,6 @@ func init() {
|
|||||||
flag.BoolVar(&verboseFlag, "v", false, "Print debug information")
|
flag.BoolVar(&verboseFlag, "v", false, "Print debug information")
|
||||||
flag.BoolVar(&noKmsgFlag, "no-kmsg-log", false, "Don't log to kmsg")
|
flag.BoolVar(&noKmsgFlag, "no-kmsg-log", false, "Don't log to kmsg")
|
||||||
flag.BoolVar(&isUserFlag, "user", false, "Run as systemd user")
|
flag.BoolVar(&isUserFlag, "user", false, "Run as systemd user")
|
||||||
flag.BoolVar(&dryRunFlag, "dryrun", false, "run in dryrun mode printing debug information")
|
flag.BoolVar(&dryRunFlag, "dryrun", false, "Run in dryrun mode printing debug information")
|
||||||
|
flag.BoolVar(&versionFlag, "version", false, "Print version information and exit")
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/systemd/parser"
|
"github.com/containers/podman/v4/pkg/systemd/parser"
|
||||||
|
"github.com/containers/podman/v4/version"
|
||||||
"github.com/mattn/go-shellwords"
|
"github.com/mattn/go-shellwords"
|
||||||
|
|
||||||
. "github.com/containers/podman/v4/test/utils"
|
. "github.com/containers/podman/v4/test/utils"
|
||||||
@ -426,6 +427,15 @@ var _ = Describe("quadlet system generator", func() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Describe("quadlet -version", func() {
|
||||||
|
It("Should print correct version", func() {
|
||||||
|
session := podmanTest.Quadlet([]string{"-version"}, "/something")
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
Expect(session.OutputToString()).To(Equal(version.Version.String()))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
Describe("Running quadlet dryrun tests", func() {
|
Describe("Running quadlet dryrun tests", func() {
|
||||||
It("Should exit with an error because of no files are found to parse", func() {
|
It("Should exit with an error because of no files are found to parse", func() {
|
||||||
fileName := "basic.kube"
|
fileName := "basic.kube"
|
||||||
|
Reference in New Issue
Block a user