示例#1
0
文件: mq.go 项目: stengland/ironcli
func (mc *mqCmd) Config() error {
	mc.settings = config.ConfigWithEnv("iron_mq", *envFlag)

	if *projectIDFlag != "" {
		mc.settings.ProjectId = *projectIDFlag
	}

	if *tokenFlag != "" {
		mc.settings.Token = *tokenFlag
	}

	if mc.settings.ProjectId == "" {
		return errors.New("did not find project id in any config files or env variables")
	}
	if mc.settings.Token == "" {
		return errors.New("did not find token in any config files or env variables")
	}

	if !isPipedOut() {
		fmt.Printf("%sConfiguring client\n", LINES)
		pName, err := mqProjectName(mc.settings)
		if err != nil {
			return err
		}
		if pName == "" {
			fmt.Printf("%sCould not find project name.", BLANKS)
		} else {
			fmt.Printf(`%sProject '%s' with id='%s'`, BLANKS, pName, mc.settings.ProjectId)
		}
		fmt.Println()
	}
	return nil
}
示例#2
0
文件: commands.go 项目: ches/ironcli
// All Commands will do similar configuration
func (bc *command) Config() error {
	bc.wrkr.Settings = config.ConfigWithEnv("iron_worker", *envFlag)
	if *projectIDFlag != "" {
		bc.wrkr.Settings.ProjectId = *projectIDFlag
	}
	if *tokenFlag != "" {
		bc.wrkr.Settings.Token = *tokenFlag
	}

	if bc.wrkr.Settings.ProjectId == "" {
		return errors.New("did not find project id in any config files or env variables")
	}
	if bc.wrkr.Settings.Token == "" {
		return errors.New("did not find token in any config files or env variables")
	}

	bc.hud_URL_str = `Check https://hud.iron.io/tq/projects/` + bc.wrkr.Settings.ProjectId + "/"

	fmt.Println(LINES, `Configuring client`)

	pName, err := projectName(bc.wrkr.Settings)
	if err != nil {
		return err
	}

	fmt.Printf(`%s Project '%s' with id='%s'`, BLANKS, pName, bc.wrkr.Settings.ProjectId)
	fmt.Println()
	return nil
}