Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

License get command updates #10464

Merged
merged 2 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion command/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ 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,
fmt.Sprintf("Terminates At|%s", lic.TerminationTime.String()),
fmt.Sprintf("Datacenter|%s", lic.InstallationID),
}
ui.Output(formatKV(output))
Expand Down
26 changes: 5 additions & 21 deletions command/license_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ func (c *LicenseGetCommand) Help() string {
helpText := `
Usage: nomad license get [options]

Gets a new license in Servers and Clients
Gets the license loaded by the server. The command is not forwarded to the
Nomad leader, and will return the license from the specific server being
contacted.

When ACLs are enabled, this command requires a token with the
'operator:read' capability.

-stale=[true|false]
By default the license get command will be forwarded to the Nomad leader.
If -stale is set to true, the command will not be forwarded to the
leader and will return the license from the specific server being
contacted. This option may be useful during upgrade scenarios when a server
is given a new file license and is a follower so the new license has not
yet been propagated to raft.

General Options:

` + generalOptionsUsage(usageOptsDefault|usageOptsNoNamespace)
Expand All @@ -36,10 +30,7 @@ General Options:
}

func (c *LicenseGetCommand) AutocompleteFlags() complete.Flags {
return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient),
complete.Flags{
"-stale": complete.PredictAnything,
})
return complete.Flags{}
}

func (c *LicenseGetCommand) AutocompleteArgs() complete.Predictor {
Expand All @@ -53,13 +44,9 @@ func (c *LicenseGetCommand) Synopsis() string {
func (c *LicenseGetCommand) Name() string { return "license get" }

func (c *LicenseGetCommand) Run(args []string) int {
var stale bool

flags := c.Meta.FlagSet(c.Name(), FlagSetClient)
flags.Usage = func() { c.Ui.Output(c.Help()) }

flags.BoolVar(&stale, "stale", false, "")

if err := flags.Parse(args); err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing flags: %s", err))
return 1
Expand All @@ -71,10 +58,7 @@ func (c *LicenseGetCommand) Run(args []string) int {
return 1
}

q := &api.QueryOptions{
AllowStale: stale,
}
resp, _, err := client.Operator().LicenseGet(q)
resp, _, err := client.Operator().LicenseGet(&api.QueryOptions{})
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting license: %v", err))
return 1
Expand Down