MCPcopy Create free account
hub / github.com/hashicorp/vault / Run

Method Run

command/operator_members.go:55–94  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

53}
54
55func (c *OperatorMembersCommand) Run(args []string) int {
56 f := c.Flags()
57
58 if err := f.Parse(args); err != nil {
59 c.UI.Error(err.Error())
60 return 1
61 }
62
63 client, err := c.Client()
64 if err != nil {
65 c.UI.Error(err.Error())
66 return 2
67 }
68
69 resp, err := client.Sys().HAStatus()
70 if err != nil {
71 c.UI.Error(err.Error())
72 return 2
73 }
74
75 switch Format(c.UI) {
76 case "table":
77 out := make([]string, 0)
78 cols := []string{"Host Name", "API Address", "Cluster Address", "Active Node", "Version", "Upgrade Version", "Redundancy Zone", "Last Echo"}
79 out = append(out, strings.Join(cols, " | "))
80 for _, node := range resp.Nodes {
81 cols := []string{node.Hostname, node.APIAddress, node.ClusterAddress, fmt.Sprintf("%t", node.ActiveNode), node.Version, node.UpgradeVersion, node.RedundancyZone}
82 if node.LastEcho != nil {
83 cols = append(cols, node.LastEcho.Format(time.RFC3339))
84 } else {
85 cols = append(cols, "")
86 }
87 out = append(out, strings.Join(cols, " | "))
88 }
89 c.UI.Output(tableOutput(out, nil))
90 return 0
91 default:
92 return OutputData(c.UI, resp)
93 }
94}

Callers

nothing calls this directly

Calls 11

FlagsMethod · 0.95
FormatFunction · 0.85
tableOutputFunction · 0.85
OutputDataFunction · 0.85
HAStatusMethod · 0.80
SysMethod · 0.80
ParseMethod · 0.65
ErrorMethod · 0.65
ClientMethod · 0.65
FormatMethod · 0.65
OutputMethod · 0.65

Tested by

no test coverage detected