当前位置: 首页>>代码示例>>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;未经允许,请勿转载。