Skip to content

Commit ffe7958

Browse files
committed
Allow user to get version without a server
1 parent 857b133 commit ffe7958

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

docs/content/reference/pgo_version.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Operator Version: v5.5.0
3838
### Options
3939

4040
```
41-
-h, --help help for version
41+
--client If true, shows client version only (no server required).
42+
-h, --help help for version
4243
```
4344

4445
### Options inherited from parent commands

internal/cmd/version.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func newVersionCommand(config *internal.Config) *cobra.Command {
4747
// No arguments for 'version'
4848
cmd.Args = cobra.NoArgs
4949

50+
var clientOnly bool
51+
cmd.Flags().BoolVar(&clientOnly, "client", false, "If true, shows client version only (no server required).")
52+
5053
cmd.Example = internal.FormatExample(fmt.Sprintf(`# Request the version of the client and the operator
5154
pgo version
5255
@@ -57,6 +60,9 @@ Operator Version: v5.5.0`, clientVersion))
5760
cmd.RunE = func(cmd *cobra.Command, args []string) error {
5861

5962
cmd.Printf("Client Version: %s\n", clientVersion)
63+
if clientOnly {
64+
return nil
65+
}
6066

6167
ctx := context.Background()
6268
restConfig, err := config.ToRESTConfig()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
# The following test should check that the client version output is returned
5+
# when a kubernetes cluster is not available
6+
- script: |
7+
contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; }
8+
9+
VERSION_OUTPUT=$(KUBECONFIG=blah kubectl pgo version --client)
10+
11+
{ contains "${VERSION_OUTPUT}" "Client Version:"; } || {
12+
echo ${VERSION_OUTPUT}
13+
exit 1
14+
}

0 commit comments

Comments
 (0)