func configGet(c *manager.Client, noop string, flags parsedFlags) error { out, err := c.GetConfig() if err != nil { return err } if !flags.jsonOutput { return printTemplate(out, configTemplate, &configInfo{}) } return ppJSON(out) }
func globalsGet(c *manager.Client, noop string, flags parsedFlags) error { out, err := c.GetGlobals() if err != nil { return err } if !flags.jsonOutput { return printTemplate(out, globalTemplate, &globalInfo{}) } return ppJSON(out) }
func nodesGet(c *manager.Client, noop string, flags parsedFlags) error { out, err := c.GetAllNodes() if err != nil { return err } if !flags.jsonOutput { return printTemplate(out, multiNodeTemplate, &nodesInfo{}) } return ppJSON(out) }
func nodeGet(c *manager.Client, nodeName string, flags parsedFlags) error { if nodeName == "" { return errUnexpectedArgCount("1", 0) } out, err := c.GetNode(nodeName) if err != nil { return err } if !flags.jsonOutput { return printTemplate(out, oneNodeTemplate, &nodeInfo{}) } return ppJSON(out) }
func configSet(c *manager.Client, args []string, noop parsedFlags) error { var reader io.Reader if args[0] == "-" { reader = bufio.NewReader(os.Stdin) } else { f, err := os.Open(args[0]) if err != nil { return errored.Errorf("failed to open config file. Error: %v", err) } defer func() { f.Close() }() reader = bufio.NewReader(f) } config, err := (&manager.Config{}).MergeFromReader(reader) if err != nil { return err } return c.PostConfig(config) }
func jobGet(c *manager.Client, job string, flags parsedFlags) error { if job == "" { return errUnexpectedArgCount("1", 0) } out, err := c.GetJob(job) if err != nil { return err } // if streaming logs then we just print a short job info followed by the // log stream if flags.streamLogs { if err := printTemplate(out, shortJobTemplate, &jobInfo{}); err != nil { return err } logs, err := c.StreamLogs(job) if err != nil { return err } defer logs.Close() log := make([]byte, 128) for { n, err := logs.Read(log) if n > 0 { fmt.Printf("%s", log[:n]) } if err != nil { break } } return nil } if !flags.jsonOutput { return printTemplate(out, jobTemplate, &jobInfo{}) } return ppJSON(out) }
func nodesDiscover(c *manager.Client, args []string, flags parsedFlags) error { return c.PostNodesDiscover(args, flags.extraVars) }
func nodesUpdate(c *manager.Client, args []string, flags parsedFlags) error { return c.PostNodesUpdate(args, flags.extraVars, flags.hostGroup) }
func nodesDecommission(c *manager.Client, args []string, flags parsedFlags) error { return c.PostNodesDecommission(args, flags.extraVars) }
func nodeUpdate(c *manager.Client, args []string, flags parsedFlags) error { nodeName := args[0] return c.PostNodeUpdate(nodeName, flags.extraVars, flags.hostGroup) }
func nodeDecommission(c *manager.Client, args []string, flags parsedFlags) error { nodeName := args[0] return c.PostNodeDecommission(nodeName, flags.extraVars) }
func globalsSet(c *manager.Client, noop []string, flags parsedFlags) error { return c.PostGlobals(flags.extraVars) }