Files
openlan/cmd/api/v5/version.go
Daniel Ding d8140ddf08
Some checks failed
Coverage CI / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
Ubuntu CI / build (push) Has been cancelled
fix: display expire time.
2025-09-23 19:38:29 +08:00

42 lines
810 B
Go
Executable File

package v5
import (
"github.com/luscis/openlan/cmd/api"
"github.com/luscis/openlan/pkg/schema"
"github.com/urfave/cli/v2"
)
type Version struct {
Cmd
}
func (v Version) Url(prefix, name string) string {
return prefix + "/api/version"
}
func (v Version) Tmpl() string {
return `Version : {{ .Version }}
Build at : {{ .Date}}
Expire at: {{ .Expire }}
`
}
func (v Version) List(c *cli.Context) error {
url := v.Url(c.String("url"), "")
clt := v.NewHttp(c.String("token"))
var item schema.Version
if err := clt.GetJSON(url, &item); err != nil {
return err
}
return v.Out(item, c.String("format"), v.Tmpl())
}
func (v Version) Commands(app *api.App) {
app.Command(&cli.Command{
Name: "version",
Aliases: []string{"v"},
Usage: "show version information",
Action: v.List,
})
}