talos icon indicating copy to clipboard operation
talos copied to clipboard

JSON/YAML output for `talosctl version`

Open reitermarkus opened this issue 1 year ago • 2 comments

Feature Request

Description

I couldn't find an easy way to programmatically get the currently installed tag using talosctl, so talosctl version should support JSON/YAML output.

Maybe I missed another command which includes this information?

reitermarkus avatar Jul 14 '22 18:07 reitermarkus

Here's a hacked workaround (in my update script):

(
  RELEASE_VERSION=$(wget -qO - "https://api.github.com/repos/siderolabs/talos/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")') &&
  CURRENT_VERSION=$(talosctl version --client | grep 'Tag:' | grep -oP 'v[0-9]+.[0-9]+.[0-9]+') &&
  echo "talosctl released: v$RELEASE_VERSION, current: $CURRENT_VERSION" &&
  if [ "v$RELEASE_VERSION" != $CURRENT_VERSION ]; then
     wget -qnv --show-progress -O ~/bin/talosctl https://github.com/siderolabs/talos/releases/download/v${RELEASE_VERSION}/talosctl-linux-amd64
     chmod +x ~/bin/talosctl
  fi
)

mrwulf avatar Aug 05 '22 23:08 mrwulf

@mrwulf, thanks, I do also have a workaround using grep/awk. To be clear, I am talking about the Server version, not the Client. The Client version is already kept up-to-date by Homebrew in my case.

The JSON/YAML output should of course include both.

For your use case, I would actually argue that the --short flag would be more useful than YAML/JSON output, but in its current form it is not short enough. talosctl version --client --short currently outputs

Client:
Client v1.1.0

I would assume the --short flag to produce actually short output, i.e.

v1.1.0

reitermarkus avatar Aug 06 '22 03:08 reitermarkus