本文整理汇总了Golang中github.com/apache/brooklyn-client/error_handler.ErrorExit函数的典型用法代码示例。如果您正苦于以下问题:Golang ErrorExit函数的具体用法?Golang ErrorExit怎么用?Golang ErrorExit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorExit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Run
func (cmd *Deploy) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
var create models.TaskSummary
var err error
var blueprint []byte
if c.Args().First() == "" {
error_handler.ErrorExit("A filename or URL or '-' must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
}
if c.Args().First() == "-" {
blueprint, err = ioutil.ReadAll(os.Stdin)
if err != nil {
error_handler.ErrorExit(err)
}
create, err = application.CreateFromBytes(cmd.network, blueprint)
} else {
create, err = application.Create(cmd.network, c.Args().First())
}
if nil != err {
if httpErr, ok := err.(net.HttpError); ok {
error_handler.ErrorExit(strings.Join([]string{httpErr.Status, httpErr.Body}, "\n"), httpErr.Code)
} else {
error_handler.ErrorExit(err)
}
}
table := terminal.NewTable([]string{"Id:", create.EntityId})
table.Add("Name:", create.EntityDisplayName)
table.Add("Status:", create.CurrentStatus)
table.Print()
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:32,代码来源:deploy.go
示例2: show
func (cmd *Application) show(appName string) {
application, err := application.Application(cmd.network, appName)
if nil != err {
error_handler.ErrorExit(err)
}
entity, err := entities.GetEntity(cmd.network, appName, appName)
if nil != err {
error_handler.ErrorExit(err)
}
state, err := entity_sensors.CurrentState(cmd.network, appName, appName)
if nil != err {
error_handler.ErrorExit(err)
}
location, err := locations.GetLocation(cmd.network, application.Spec.Locations[0])
if nil != err {
error_handler.ErrorExit(err)
}
table := terminal.NewTable([]string{"Id:", application.Id})
table.Add("Name:", application.Spec.Name)
table.Add("Status:", string(application.Status))
if serviceUp, ok := state[serviceIsUpStr]; ok {
table.Add("ServiceUp:", fmt.Sprintf("%v", serviceUp))
}
table.Add("Type:", application.Spec.Type)
table.Add("CatalogItemId:", entity.CatalogItemId)
table.Add("LocationId:", strings.Join(application.Spec.Locations, ", "))
table.Add("LocationName:", location.Name)
table.Add("LocationSpec:", location.Spec)
table.Add("LocationType:", location.Type)
table.Print()
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:31,代码来源:application.go
示例3: Run
func (cmd *Config) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
if c.Args().Present() {
configValue, err := entity_config.ConfigValue(cmd.network, scope.Application, scope.Entity, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
displayValue, err := stringRepresentation(configValue)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(displayValue)
} else {
config, err := entity_config.ConfigCurrentState(cmd.network, scope.Application, scope.Entity)
if nil != err {
error_handler.ErrorExit(err)
}
table := terminal.NewTable([]string{"Key", "Value"})
for key, value := range config {
table.Add(key, fmt.Sprintf("%v", value))
}
table.Print()
}
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:28,代码来源:config.go
示例4: Run
func (cmd *Login) Run(scope scope.Scope, c *cli.Context) {
if !c.Args().Present() {
error_handler.ErrorExit("A URL must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
}
// If an argument was not supplied, it is set to empty string
cmd.network.BrooklynUrl = c.Args().Get(0)
cmd.network.BrooklynUser = c.Args().Get(1)
cmd.network.BrooklynPass = c.Args().Get(2)
cmd.network.SkipSslChecks = c.GlobalBool("skipSslChecks")
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
// Strip off trailing '/' from URL if present.
if cmd.network.BrooklynUrl[len(cmd.network.BrooklynUrl)-1] == '/' {
if len(cmd.network.BrooklynUrl) == 1 {
error_handler.ErrorExit("URL must not be a single \"/\" character", error_handler.CLIUsageErrorExitCode)
}
cmd.network.BrooklynUrl = cmd.network.BrooklynUrl[0 : len(cmd.network.BrooklynUrl)-1]
}
// Prompt for password if not supplied (password is not echoed to screen
if cmd.network.BrooklynUser != "" && cmd.network.BrooklynPass == "" {
fmt.Print("Enter Password: ")
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
error_handler.ErrorExit(err)
}
fmt.Printf("\n")
cmd.network.BrooklynPass = string(bytePassword)
}
if cmd.config.Map == nil {
cmd.config.Map = make(map[string]interface{})
}
// now persist these credentials to the yaml file
auth, ok := cmd.config.Map["auth"].(map[string]interface{})
if !ok {
auth = make(map[string]interface{})
cmd.config.Map["auth"] = auth
}
auth[cmd.network.BrooklynUrl] = map[string]string{
"username": cmd.network.BrooklynUser,
"password": cmd.network.BrooklynPass,
}
cmd.config.Map["target"] = cmd.network.BrooklynUrl
cmd.config.Map["skipSslChecks"] = cmd.network.SkipSslChecks
cmd.config.Write()
loginVersion, err := version.Version(cmd.network)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Printf("Connected to Brooklyn version %s at %s\n", loginVersion.Version, cmd.network.BrooklynUrl)
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:59,代码来源:login.go
示例5: Run
func (cmd *SetConfig) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
response, err := entity_config.SetConfig(cmd.network, scope.Application, scope.Entity, scope.Config, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(response)
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:10,代码来源:set.go
示例6: Run
func (cmd *Tree) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
trees, err := application.Tree(cmd.network)
if nil != err {
error_handler.ErrorExit(err)
}
cmd.printTrees(trees, "")
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:10,代码来源:tree.go
示例7: Run
func (cmd *Delete) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
del, err := application.Delete(cmd.network, scope.Application)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(del)
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:10,代码来源:delete.go
示例8: Run
func (cmd *AddCatalog) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
create, err := catalog.AddCatalog(cmd.network, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(create)
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:10,代码来源:add-catalog.go
示例9: Run
func (cmd *Spec) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
spec, err := entities.Spec(cmd.network, scope.Application, scope.Entity)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(spec)
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:10,代码来源:spec.go
示例10: Run
func (cmd *Rename) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
rename, err := entities.Rename(cmd.network, scope.Application, scope.Entity, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(rename)
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:10,代码来源:rename.go
示例11: Run
func (cmd *StopPolicy) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
spec, err := entity_policies.StopPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(spec)
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:10,代码来源:stop-policy.go
示例12: Run
func (cmd *ActivityStreamStdout) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdout")
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(activityStream)
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:10,代码来源:activity-stream.go
示例13: Run
func (cmd *Version) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
version, err := version.Version(cmd.network)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(version.Version)
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:10,代码来源:version.go
示例14: Run
func (cmd *Access) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
access, err := access_control.Access(cmd.network)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println("Location Provisioning Allowed:", access.LocationProvisioningAllowed)
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:10,代码来源:access.go
示例15: show
func (cmd *Sensor) show(application, entity, sensor string) {
sensorValue, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor)
if nil != err {
error_handler.ErrorExit(err)
}
displayValue, err := stringRepresentation(sensorValue)
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(displayValue)
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:11,代码来源:sensor.go
示例16: Run
func (cmd *AddChildren) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
activity, err := entities.AddChildren(cmd.network, scope.Application, scope.Entity, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status"})
table.Add(activity.Id, activity.DisplayName, time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), activity.CurrentStatus)
table.Print()
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:13,代码来源:add-children.go
示例17: Run
func (cmd *Locations) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
locationList, err := locations.LocationList(cmd.network)
if nil != err {
error_handler.ErrorExit(err)
}
table := terminal.NewTable([]string{"Id", "Name", "Spec"})
for _, location := range locationList {
table.Add(location.Id, location.Name, location.Spec)
}
table.Print()
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:14,代码来源:locations.go
示例18: Run
func (cmd *Catalog) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
catalog, err := catalog.Catalog(cmd.network)
if nil != err {
error_handler.ErrorExit(err)
}
table := terminal.NewTable([]string{"Id", "Name", "Description"})
for _, app := range catalog {
table.Add(app.Id, app.Name, app.Description)
}
table.Print()
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:14,代码来源:catalog.go
示例19: Run
func (cmd *Restart) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
parms := c.StringSlice("param")
invoke(cmd.network, scope.Application, scope.Entity, restartEffector, parms)
}
开发者ID:CMoH,项目名称:brooklyn-client,代码行数:7,代码来源:invoke.go
示例20: show
func (cmd *Activity) show(activityId string) {
activity, err := activities.Activity(cmd.network, activityId)
if nil != err {
error_handler.ErrorExit(err)
}
table := terminal.NewTable([]string{"Id:", activity.Id})
table.Add("DisplayName:", activity.DisplayName)
table.Add("Description:", activity.Description)
table.Add("EntityId:", activity.EntityId)
table.Add("EntityDisplayName:", activity.EntityDisplayName)
table.Add("Submitted:", time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate))
table.Add("Started:", time.Unix(activity.StartTimeUtc/1000, 0).Format(time.UnixDate))
table.Add("Ended:", time.Unix(activity.EndTimeUtc/1000, 0).Format(time.UnixDate))
table.Add("CurrentStatus:", activity.CurrentStatus)
table.Add("IsError:", strconv.FormatBool(activity.IsError))
table.Add("IsCancelled:", strconv.FormatBool(activity.IsCancelled))
table.Add("SubmittedByTask:", activity.SubmittedByTask.Metadata.Id)
if activity.Streams["stdin"].Metadata.Size > 0 ||
activity.Streams["stdout"].Metadata.Size > 0 ||
activity.Streams["stderr"].Metadata.Size > 0 ||
activity.Streams["env"].Metadata.Size > 0 {
table.Add("Streams:", fmt.Sprintf("stdin: %d, stdout: %d, stderr: %d, env %d",
activity.Streams["stdin"].Metadata.Size,
activity.Streams["stdout"].Metadata.Size,
activity.Streams["stderr"].Metadata.Size,
activity.Streams["env"].Metadata.Size))
} else {
table.Add("Streams:", "")
}
table.Add("DetailedStatus:", fmt.Sprintf("\"%s\"", activity.DetailedStatus))
table.Print()
}
开发者ID:ahgittin,项目名称:brooklyn-client,代码行数:33,代码来源:activity.go
注:本文中的github.com/apache/brooklyn-client/error_handler.ErrorExit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论