Add version to controller info response
This change adds the GARM server version to the controller info response. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
dcee09281b
commit
42ae3c52d1
10 changed files with 43 additions and 16 deletions
|
|
@ -145,7 +145,10 @@ func renderControllerInfoTable(info params.ControllerInfo) string {
|
|||
if info.ControllerWebhookURL == "" {
|
||||
info.ControllerWebhookURL = "N/A"
|
||||
}
|
||||
|
||||
serverVersion := "v0.0.0-unknown"
|
||||
if info.Version != "" {
|
||||
serverVersion = info.Version
|
||||
}
|
||||
t.AppendHeader(header)
|
||||
t.AppendRow(table.Row{"Controller ID", info.ControllerID})
|
||||
if info.Hostname != "" {
|
||||
|
|
@ -156,6 +159,7 @@ func renderControllerInfoTable(info params.ControllerInfo) string {
|
|||
t.AppendRow(table.Row{"Webhook Base URL", info.WebhookURL})
|
||||
t.AppendRow(table.Row{"Controller Webhook URL", info.ControllerWebhookURL})
|
||||
t.AppendRow(table.Row{"Minimum Job Age Backoff", info.MinimumJobAgeBackoff})
|
||||
t.AppendRow(table.Row{"Version", serverVersion})
|
||||
return t.Render()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ import (
|
|||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var Version string
|
||||
|
||||
var (
|
||||
cfg *config.Config
|
||||
mgr config.Manager
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientControllerInfo "github.com/cloudbase/garm/client/controller_info"
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
)
|
||||
|
||||
// runnerCmd represents the runner command
|
||||
|
|
@ -26,7 +29,18 @@ var versionCmd = &cobra.Command{
|
|||
SilenceUsage: true,
|
||||
Short: "Print version and exit",
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Println(Version)
|
||||
serverVersion := "v0.0.0-unknown"
|
||||
|
||||
if !needsInit {
|
||||
showInfo := apiClientControllerInfo.NewControllerInfoParams()
|
||||
response, err := apiCli.ControllerInfo.ControllerInfo(showInfo, authToken)
|
||||
if err == nil {
|
||||
serverVersion = response.Payload.Version
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("garm-cli: %s\n", appdefaults.GetVersion())
|
||||
fmt.Printf("garm server: %s\n", serverVersion)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,6 @@ var (
|
|||
version = flag.Bool("version", false, "prints version")
|
||||
)
|
||||
|
||||
var Version string
|
||||
|
||||
var signals = []os.Signal{
|
||||
os.Interrupt,
|
||||
syscall.SIGTERM,
|
||||
|
|
@ -179,7 +177,7 @@ func maybeUpdateURLsFromConfig(cfg config.Config, store common.Store) error {
|
|||
func main() {
|
||||
flag.Parse()
|
||||
if *version {
|
||||
fmt.Println(Version)
|
||||
fmt.Println(appdefaults.GetVersion())
|
||||
return
|
||||
}
|
||||
ctx, stop := signal.NotifyContext(context.Background(), signals...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue