当前位置: 首页>>代码示例>>Golang>>正文


Golang BBSConfig.PopulateFlags方法代码示例

本文整理汇总了Golang中github.com/pivotal-cf-experimental/veritas/config_finder.BBSConfig.PopulateFlags方法的典型用法代码示例。如果您正苦于以下问题:Golang BBSConfig.PopulateFlags方法的具体用法?Golang BBSConfig.PopulateFlags怎么用?Golang BBSConfig.PopulateFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/pivotal-cf-experimental/veritas/config_finder.BBSConfig的用法示例。


在下文中一共展示了BBSConfig.PopulateFlags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SetDomainCommand

func SetDomainCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("set-domain", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "set-domain",
		Description: "domain ttl - updates the domain in the BBS (ttl is a duration)",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			if len(args) != 2 {
				say.Fprintln(os.Stderr, 0, say.Red("Expected domain and ttl"))
				os.Exit(1)
			}
			ttl, err := time.ParseDuration(args[1])
			common.ExitIfError("Failed to parse TTL", err)

			err = set_domain.SetDomain(bbsClient, args[0], ttl)
			common.ExitIfError("Failed to submit lrp", err)
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:28,代码来源:set_domain_command.go

示例2: GetDesiredLRPCommand

func GetDesiredLRPCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("get-desired-lrp", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "get-desired-lrp",
		Description: "<process-guid> - get a DesiredLRP",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			if len(args) == 0 {
				say.Fprintln(os.Stderr, 0, say.Red("missing process-guid"))
				os.Exit(1)
			}

			desiredLRP, err := bbsClient.DesiredLRPByProcessGuid(args[0])
			common.ExitIfError("Failed to fetch DesiredLRP", err)

			preview, _ := json.MarshalIndent(desiredLRP, "", "  ")
			say.Println(0, string(preview))
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:29,代码来源:get_desired_lrp_command.go

示例3: FetchStoreCommand

func FetchStoreCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("fetch-store", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "fetch-store",
		Description: "[file] - Fetch contents of the BBS",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			if len(args) == 0 {
				err := fetch_store.Fetch(bbsClient, os.Stdout)
				common.ExitIfError("Failed to fetch store", err)
			} else {
				f, err := os.Create(args[0])
				common.ExitIfError("Could not create file", err)

				err = fetch_store.Fetch(bbsClient, f)
				common.ExitIfError("Failed to fetch store", err)

				f.Close()
			}
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:31,代码来源:fetch_store_command.go

示例4: RemoveLRPCommand

func RemoveLRPCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("remove-lrp", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "remove-lrp",
		Description: "<process-guid> - remove an lrp",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			if len(args) == 0 {
				say.Fprintln(os.Stderr, 0, say.Red("You must specify a process-guid"))
				os.Exit(1)
			} else {
				err := bbsClient.RemoveDesiredLRP(args[0])
				common.ExitIfError("Failed to remove lrp", err)
			}
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:26,代码来源:remove_lrp_command.go

示例5: GetActualLRPCommand

func GetActualLRPCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("get-actual-lrp", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "get-actual-lrp",
		Description: "<process-guid> <optional: index> - get an ActualLRP",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			var index = -1

			if len(args) == 0 {
				say.Fprintln(os.Stderr, 0, say.Red("missing process-guid"))
				os.Exit(1)
			}

			processGuid := args[0]

			if len(args) == 2 {
				index, err = strconv.Atoi(args[1])
				common.ExitIfError("Could not parse index", err)
			}

			if index == -1 {
				actualLRPGroups, err := bbsClient.ActualLRPGroupsByProcessGuid(processGuid)
				common.ExitIfError("Could not fetch ActualLRPs", err)

				for _, actualLRPGroup := range actualLRPGroups {
					actualLRP, _ := actualLRPGroup.Resolve()
					preview, _ := json.MarshalIndent(actualLRP, "", "  ")
					say.Println(0, string(preview))
				}
			} else {
				actualLRPGroup, err := bbsClient.ActualLRPGroupByProcessGuidAndIndex(processGuid, index)
				common.ExitIfError("Could not fetch ActualLRP", err)

				actualLRP, _ := actualLRPGroup.Resolve()
				preview, _ := json.MarshalIndent(actualLRP, "", "  ")
				say.Println(0, string(preview))
			}
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:50,代码来源:get_actual_lrp_command.go

示例6: UpdateDesiredLRPCommand

func UpdateDesiredLRPCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("update-lrp", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "update-lrp",
		Description: "<process-guid> <path to json file> - update a DesiredLRP",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			var raw = []byte{}

			if len(args) == 0 {
				say.Fprintln(os.Stderr, 0, say.Red("missing process-guid"))
				os.Exit(1)
			} else if len(args) == 1 {
				say.Fprintln(os.Stderr, 0, "Reading from stdin...")
				raw, err = ioutil.ReadAll(os.Stdin)
				common.ExitIfError("Failed to read from stdin", err)
			} else {
				raw, err = ioutil.ReadFile(args[1])
				common.ExitIfError("Failed to read from file", err)
			}

			desiredLRPUpdate := &models.DesiredLRPUpdate{}

			err = json.Unmarshal(raw, desiredLRPUpdate)
			common.ExitIfError("Failed to decode DesiredLRPUpdate", err)

			say.Println(0, "Updating %s:", args[0])
			preview, _ := json.MarshalIndent(desiredLRPUpdate, "", "  ")
			say.Println(0, string(preview))

			err = bbsClient.UpdateDesiredLRP(args[0], desiredLRPUpdate)
			common.ExitIfError("Failed to update DesiredLRP", err)
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:44,代码来源:update_desired_lrp_command.go

示例7: CreateDesiredLRPCommand

func CreateDesiredLRPCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
	)

	flagSet := flag.NewFlagSet("desire-lrp", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)

	return common.Command{
		Name:        "desire-lrp",
		Description: "<path to json file> - create a DesiredLRP",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			var raw = []byte{}

			if len(args) == 0 {
				say.Fprintln(os.Stderr, 0, "Reading from stdin...")
				raw, err = ioutil.ReadAll(os.Stdin)
				common.ExitIfError("Failed to read from stdin", err)
			} else {
				raw, err = ioutil.ReadFile(args[0])
				common.ExitIfError("Failed to read from file", err)
			}

			desiredLRP := &models.DesiredLRP{}

			err = json.Unmarshal(raw, desiredLRP)
			common.ExitIfError("Failed to decode DesiredLRP", err)

			say.Println(0, "Desiring:")
			preview, _ := json.MarshalIndent(desiredLRP, "", "  ")
			say.Println(0, string(preview))

			err = bbsClient.DesireLRP(desiredLRP)
			common.ExitIfError("Failed to desire DesiredLRP", err)
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:41,代码来源:create_desired_lrp_command.go

示例8: DumpStoreCommand

func DumpStoreCommand() common.Command {
	var (
		bbsConfig config_finder.BBSConfig
		tasks     bool
		lrps      bool
		rate      time.Duration
		verbose   bool
	)

	flagSet := flag.NewFlagSet("dump-store", flag.ExitOnError)
	bbsConfig.PopulateFlags(flagSet)
	flagSet.BoolVar(&tasks, "tasks", true, "print tasks")
	flagSet.BoolVar(&lrps, "lrps", true, "print lrps")
	flagSet.BoolVar(&verbose, "v", false, "be verbose")
	flagSet.DurationVar(&rate, "rate", time.Duration(0), "rate at which to poll the store")

	return common.Command{
		Name:        "dump-store",
		Description: "- Fetch and print contents of the BBS",
		FlagSet:     flagSet,
		Run: func(args []string) {
			bbsClient, err := config_finder.NewBBS(bbsConfig)
			common.ExitIfError("Could not construct BBS", err)

			if rate == 0 {
				err = dump(bbsClient, verbose, tasks, lrps, false)
				common.ExitIfError("Failed to dump", err)
				return
			}

			ticker := time.NewTicker(rate)
			for {
				<-ticker.C
				err = dump(bbsClient, verbose, tasks, lrps, true)
				if err != nil {
					say.Println(0, say.Red("Failed to dump: %s", err.Error()))
				}
			}
		},
	}
}
开发者ID:mhoran,项目名称:veritas,代码行数:41,代码来源:dump_store_command.go


注:本文中的github.com/pivotal-cf-experimental/veritas/config_finder.BBSConfig.PopulateFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。