예제 #1
0
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)
}
예제 #2
0
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)
}
예제 #3
0
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)
}
예제 #4
0
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)
}
예제 #5
0
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)
}
예제 #6
0
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)
}
예제 #7
0
func nodesDiscover(c *manager.Client, args []string, flags parsedFlags) error {
	return c.PostNodesDiscover(args, flags.extraVars)
}
예제 #8
0
func nodesUpdate(c *manager.Client, args []string, flags parsedFlags) error {
	return c.PostNodesUpdate(args, flags.extraVars, flags.hostGroup)
}
예제 #9
0
func nodesDecommission(c *manager.Client, args []string, flags parsedFlags) error {
	return c.PostNodesDecommission(args, flags.extraVars)
}
예제 #10
0
func nodeUpdate(c *manager.Client, args []string, flags parsedFlags) error {
	nodeName := args[0]
	return c.PostNodeUpdate(nodeName, flags.extraVars, flags.hostGroup)
}
예제 #11
0
func nodeDecommission(c *manager.Client, args []string, flags parsedFlags) error {
	nodeName := args[0]
	return c.PostNodeDecommission(nodeName, flags.extraVars)
}
예제 #12
0
func globalsSet(c *manager.Client, noop []string, flags parsedFlags) error {
	return c.PostGlobals(flags.extraVars)
}