github.com/hernad/nomad@v1.6.112/command/system_reconcile_summaries.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package command 5 6 import ( 7 "fmt" 8 "strings" 9 10 "github.com/posener/complete" 11 ) 12 13 type SystemReconcileSummariesCommand struct { 14 Meta 15 } 16 17 func (c *SystemReconcileSummariesCommand) Help() string { 18 helpText := ` 19 Usage: nomad system reconcile summaries [options] 20 21 Reconciles the summaries of all registered jobs. 22 23 If ACLs are enabled, this option requires a management token. 24 25 General Options: 26 27 ` + generalOptionsUsage(usageOptsDefault|usageOptsNoNamespace) 28 return strings.TrimSpace(helpText) 29 } 30 31 func (c *SystemReconcileSummariesCommand) Synopsis() string { 32 return "Reconciles the summaries of all registered jobs" 33 } 34 35 func (c *SystemReconcileSummariesCommand) AutocompleteFlags() complete.Flags { 36 return c.Meta.AutocompleteFlags(FlagSetClient) 37 } 38 39 func (c *SystemReconcileSummariesCommand) AutocompleteArgs() complete.Predictor { 40 return complete.PredictNothing 41 } 42 43 func (c *SystemReconcileSummariesCommand) Name() string { return "system reconcile summaries" } 44 45 func (c *SystemReconcileSummariesCommand) Run(args []string) int { 46 flags := c.Meta.FlagSet(c.Name(), FlagSetClient) 47 flags.Usage = func() { c.Ui.Output(c.Help()) } 48 49 if err := flags.Parse(args); err != nil { 50 return 1 51 } 52 53 if args = flags.Args(); len(args) > 0 { 54 c.Ui.Error("This command takes no arguments") 55 c.Ui.Error(commandErrorText(c)) 56 } 57 58 // Get the HTTP client 59 client, err := c.Meta.Client() 60 if err != nil { 61 c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err)) 62 return 1 63 } 64 65 if err := client.System().ReconcileSummaries(); err != nil { 66 c.Ui.Error(fmt.Sprintf("Error running system summary reconciliation: %s", err)) 67 return 1 68 } 69 return 0 70 }