本文整理汇总了Golang中github.com/pivotal-cf-experimental/veritas/config_finder.BBSConfig类的典型用法代码示例。如果您正苦于以下问题:Golang BBSConfig类的具体用法?Golang BBSConfig怎么用?Golang BBSConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BBSConfig类的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)
},
}
}
示例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))
},
}
}
示例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()
}
},
}
}
示例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)
}
},
}
}
示例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))
}
},
}
}
示例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)
},
}
}
示例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)
},
}
}
示例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()))
}
}
},
}
}