2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-12-18 21:16:23 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/posener/complete"
|
|
|
|
)
|
|
|
|
|
|
|
|
type OperatorAutopilotGetCommand struct {
|
|
|
|
Meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *OperatorAutopilotGetCommand) AutocompleteFlags() complete.Flags {
|
|
|
|
return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *OperatorAutopilotGetCommand) AutocompleteArgs() complete.Predictor {
|
|
|
|
return complete.PredictNothing
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:02:11 +00:00
|
|
|
func (c *OperatorAutopilotGetCommand) Name() string { return "operator autopilot get-config" }
|
2017-12-18 21:16:23 +00:00
|
|
|
func (c *OperatorAutopilotGetCommand) Run(args []string) int {
|
|
|
|
flags := c.Meta.FlagSet("autopilot", FlagSetClient)
|
|
|
|
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
|
|
|
|
|
|
|
if err := flags.Parse(args); err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Failed to parse args: %v", err))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up a client.
|
|
|
|
client, err := c.Meta.Client()
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fetch the current configuration.
|
2018-02-08 00:47:44 +00:00
|
|
|
config, _, err := client.Operator().AutopilotGetConfiguration(nil)
|
2017-12-18 21:16:23 +00:00
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error querying Autopilot configuration: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
c.Ui.Output(fmt.Sprintf("CleanupDeadServers = %v", config.CleanupDeadServers))
|
|
|
|
c.Ui.Output(fmt.Sprintf("LastContactThreshold = %v", config.LastContactThreshold.String()))
|
|
|
|
c.Ui.Output(fmt.Sprintf("MaxTrailingLogs = %v", config.MaxTrailingLogs))
|
2020-02-16 21:23:20 +00:00
|
|
|
c.Ui.Output(fmt.Sprintf("MinQuorum = %v", config.MinQuorum))
|
2017-12-18 21:16:23 +00:00
|
|
|
c.Ui.Output(fmt.Sprintf("ServerStabilizationTime = %v", config.ServerStabilizationTime.String()))
|
2018-01-30 03:53:34 +00:00
|
|
|
c.Ui.Output(fmt.Sprintf("EnableRedundancyZones = %v", config.EnableRedundancyZones))
|
2017-12-18 21:16:23 +00:00
|
|
|
c.Ui.Output(fmt.Sprintf("DisableUpgradeMigration = %v", config.DisableUpgradeMigration))
|
2018-01-30 03:53:34 +00:00
|
|
|
c.Ui.Output(fmt.Sprintf("EnableCustomUpgrades = %v", config.EnableCustomUpgrades))
|
2017-12-18 21:16:23 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *OperatorAutopilotGetCommand) Synopsis() string {
|
|
|
|
return "Display the current Autopilot configuration"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *OperatorAutopilotGetCommand) Help() string {
|
|
|
|
helpText := `
|
2018-01-17 08:20:13 +00:00
|
|
|
Usage: nomad operator autopilot get-config [options]
|
2017-12-18 21:16:23 +00:00
|
|
|
|
|
|
|
Displays the current Autopilot configuration.
|
|
|
|
|
2020-11-19 21:38:08 +00:00
|
|
|
If ACLs are enabled, this command requires a token with the 'operator:read'
|
|
|
|
capability.
|
|
|
|
|
2017-12-18 21:16:23 +00:00
|
|
|
General Options:
|
|
|
|
|
2020-11-19 16:15:23 +00:00
|
|
|
` + generalOptionsUsage(usageOptsDefault|usageOptsNoNamespace)
|
2017-12-18 21:16:23 +00:00
|
|
|
|
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|