當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Store.ListAssignments方法代碼示例

本文整理匯總了Golang中github.com/litl/galaxy/config.Store.ListAssignments方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.ListAssignments方法的具體用法?Golang Store.ListAssignments怎麽用?Golang Store.ListAssignments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/litl/galaxy/config.Store的用法示例。


在下文中一共展示了Store.ListAssignments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AppList

func AppList(configStore *config.Store, env string) error {

	envs := []string{env}

	if env == "" {
		var err error
		envs, err = configStore.ListEnvs()
		if err != nil {
			return err
		}
	}

	columns := []string{"NAME | ENV | VERSION | IMAGE ID | CONFIG | POOLS "}

	for _, env := range envs {

		appList, err := configStore.ListApps(env)
		if err != nil {
			return err
		}

		pools, err := configStore.ListPools(env)
		if err != nil {
			return err
		}

		for _, app := range appList {
			name := app.Name()
			versionDeployed := app.Version()
			versionID := app.VersionID()
			if len(versionID) > 12 {
				versionID = versionID[:12]
			}

			assignments := []string{}
			for _, pool := range pools {
				aa, err := configStore.ListAssignments(env, pool)
				if err != nil {
					return err
				}
				if utils.StringInSlice(app.Name(), aa) {
					assignments = append(assignments, pool)
				}
			}

			columns = append(columns, strings.Join([]string{
				name,
				env,
				versionDeployed,
				versionID,
				strconv.FormatInt(app.ID(), 10),
				strings.Join(assignments, ","),
			}, " | "))
		}
	}
	output := columnize.SimpleFormat(columns)
	fmt.Println(output)
	return nil
}
開發者ID:carriercomm,項目名稱:galaxy,代碼行數:59,代碼來源:app.go

示例2: ListPools

// TODO: shouldn't the command cmd be printing the output, and not the package?
// The app, config, host, and runtime sections all do this too. (otherwise we
// should just combine the two packages). And why do we print the output here,
// but print the error in main???
func ListPools(configStore *config.Store, env string) error {
	var envs []string
	var err error

	if env != "" {
		envs = []string{env}
	} else {
		envs, err = configStore.ListEnvs()
		if err != nil {
			return err
		}

	}

	columns := []string{"ENV | POOL | APPS "}

	for _, env := range envs {

		pools, err := configStore.ListPools(env)
		if err != nil {
			return fmt.Errorf("ERROR: cannot list pools: %s", err)
		}

		if len(pools) == 0 {
			columns = append(columns, strings.Join([]string{
				env,
				"",
				""}, " | "))
			continue
		}

		for _, pool := range pools {

			assigments, err := configStore.ListAssignments(env, pool)
			if err != nil {
				fmt.Printf("ERROR: cannot list pool assignments for %s/%s: %s", env, pool, err)
			}

			columns = append(columns, strings.Join([]string{
				env,
				pool,
				strings.Join(assigments, ",")}, " | "))

		}
	}
	fmt.Println(columnize.SimpleFormat(columns))
	return nil
}
開發者ID:sguzwf,項目名稱:galaxy,代碼行數:52,代碼來源:pool.go


注:本文中的github.com/litl/galaxy/config.Store.ListAssignments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。