github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/command/system_reconcile_summaries.go (about)

     1  package command
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/posener/complete"
     8  )
     9  
    10  type SystemReconcileSummariesCommand struct {
    11  	Meta
    12  }
    13  
    14  func (c *SystemReconcileSummariesCommand) Help() string {
    15  	helpText := `
    16  Usage: nomad system reconcile summaries [options]
    17  
    18    Reconciles the summaries of all registered jobs.
    19  
    20    If ACLs are enabled, this option requires a management token.
    21  
    22  General Options:
    23  
    24    ` + generalOptionsUsage(usageOptsDefault|usageOptsNoNamespace)
    25  	return strings.TrimSpace(helpText)
    26  }
    27  
    28  func (c *SystemReconcileSummariesCommand) Synopsis() string {
    29  	return "Reconciles the summaries of all registered jobs"
    30  }
    31  
    32  func (c *SystemReconcileSummariesCommand) AutocompleteFlags() complete.Flags {
    33  	return c.Meta.AutocompleteFlags(FlagSetClient)
    34  }
    35  
    36  func (c *SystemReconcileSummariesCommand) AutocompleteArgs() complete.Predictor {
    37  	return complete.PredictNothing
    38  }
    39  
    40  func (c *SystemReconcileSummariesCommand) Name() string { return "system reconcile summaries" }
    41  
    42  func (c *SystemReconcileSummariesCommand) Run(args []string) int {
    43  
    44  	// Get the HTTP client
    45  	client, err := c.Meta.Client()
    46  	if err != nil {
    47  		c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err))
    48  		return 1
    49  	}
    50  
    51  	if err := client.System().ReconcileSummaries(); err != nil {
    52  		c.Ui.Error(fmt.Sprintf("Error running system summary reconciliation: %s", err))
    53  		return 1
    54  	}
    55  	return 0
    56  }