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