Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

feat: add version cmd #280

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions kardinal-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const (
appLabelKey = "app"
versionLabelKey = "version"
portCheckTimeout = 5 * time.Second
rawVersionUrl = "https://raw.githubusercontent.com/kurtosis-tech/kardinal/refs/heads/main/version.txt"
)

var (
Expand Down Expand Up @@ -622,6 +623,24 @@ var tenantShowCmd = &cobra.Command{
},
}

var versionCmd = &cobra.Command{
tedim52 marked this conversation as resolved.
Show resolved Hide resolved
Use: "version",
Short: "Show version of Kardinal CLI running",
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
resp, err := http.Get(rawVersionUrl)
if err != nil {
log.Fatalf("Error making request for version id: %v", err)
}
defer resp.Body.Close()
version, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response body: %v", err)
}
fmt.Printf("%s\n", string(version))
},
}

func init() {
devMode = false
if os.Getenv("KARDINAL_CLI_DEV_MODE") == "TRUE" {
Expand All @@ -637,6 +656,7 @@ func init() {
rootCmd.AddCommand(reportInstall)
rootCmd.AddCommand(topologyCmd)
rootCmd.AddCommand(tenantCmd)
rootCmd.AddCommand(versionCmd)

flowCmd.AddCommand(listCmd, createCmd, deleteCmd, telepresenceInterceptCmd)
managerCmd.AddCommand(deployManagerCmd, removeManagerCmd)
Expand Down
Loading