license: show Terminated field in `license get` command (#16892)
This commit is contained in:
parent
62548616d4
commit
04e049caed
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
license: show Terminated field in `license get` command
|
||||
```
|
|
@ -47,20 +47,27 @@ func (l *LicenseCommand) Run(args []string) int {
|
|||
func OutputLicenseReply(ui cli.Ui, resp *api.LicenseReply) int {
|
||||
now := time.Now()
|
||||
expired := resp.License.ExpirationTime.Before(now)
|
||||
outputLicenseInfo(ui, resp.License, expired)
|
||||
terminated := resp.License.TerminationTime.Before(now)
|
||||
outputLicenseInfo(ui, resp.License, expired, terminated)
|
||||
if expired {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func outputLicenseInfo(ui cli.Ui, lic *api.License, expired bool) {
|
||||
func outputLicenseInfo(ui cli.Ui, lic *api.License, expired, terminated bool) {
|
||||
expStr := ""
|
||||
if expired {
|
||||
expStr = fmt.Sprintf("Expired At|%s", lic.ExpirationTime.String())
|
||||
} else {
|
||||
expStr = fmt.Sprintf("Expires At|%s", lic.ExpirationTime.String())
|
||||
}
|
||||
termStr := ""
|
||||
if terminated {
|
||||
termStr = fmt.Sprintf("Terminated At|%s", lic.TerminationTime.String())
|
||||
} else {
|
||||
termStr = fmt.Sprintf("Terminates At|%s", lic.TerminationTime.String())
|
||||
}
|
||||
|
||||
validity := "valid"
|
||||
if expired {
|
||||
|
@ -73,6 +80,7 @@ func outputLicenseInfo(ui cli.Ui, lic *api.License, expired bool) {
|
|||
fmt.Sprintf("Customer ID|%s", lic.CustomerID),
|
||||
fmt.Sprintf("Issued At|%s", lic.IssueTime),
|
||||
expStr,
|
||||
termStr,
|
||||
fmt.Sprintf("Datacenter|%s", lic.InstallationID),
|
||||
}
|
||||
ui.Output(formatKV(output))
|
||||
|
|
|
@ -36,9 +36,8 @@ Product = nomad
|
|||
License Status = valid
|
||||
License ID = e23f63b1-00ec-4e67-e926-c22e7937ceec
|
||||
Customer ID = 350356e5-8aec-bdf4-8510-b205079ccad2
|
||||
Issued At = 2021-03-31 14:21:16.969610774 +0000 UTC
|
||||
Expires At = 2020-05-09 00:00:00 +0000 UTC
|
||||
License ID = e23f63b1-00ec-4e67-e926-c22e7937ceec
|
||||
Customer ID = 350356e5-8aec-bdf4-8510-b205079ccad2
|
||||
Terminates At = 2020-05-10 00:00:00 +0000 UTC
|
||||
Datacenter = *
|
||||
Modules:
|
||||
|
|
Loading…
Reference in New Issue