本文整理汇总了Golang中github.com/Bowery/bowery/rollbar.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: logoutRun
func logoutRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
dev, err := db.GetDeveloper()
if err != nil && err != errors.ErrNoDeveloper {
rollbar.Report(err)
return 1
}
if err == nil {
log.Println("", "Logging you out",
strings.Split(dev.Developer.Name, " ")[0]+".")
} else {
log.Println("yellow", "No user logged in.")
}
dev.Token = ""
dev.Developer = nil
err = dev.Save()
if err != nil {
rollbar.Report(err)
return 1
}
keen.AddEvent("bowery logout", map[string]*db.Developer{"user": dev})
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:26,代码来源:logout.go
示例2: removeRun
func removeRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
force := Cmds["remove"].Force
if len(args) <= 0 {
fmt.Fprintln(os.Stderr,
"Usage: bowery "+Cmds["remove"].Usage, "\n\n"+Cmds["remove"].Short)
return 2 // --help uses 2.
}
services, err := db.GetServices()
if err != nil {
rollbar.Report(err)
return 1
}
for _, name := range args {
_, ok := services.Data[name]
if !ok {
log.Println("yellow", "Service", name, "doesn't exist, skipping.")
continue
}
if !force {
ok, err = prompt.Ask("Are you sure you want to remove " + name)
if err != nil {
rollbar.Report(err)
return 1
}
if !ok {
log.Println("yellow", "Skipping", name)
continue
}
}
delete(services.Data, name)
log.Println("", "Removed service", name)
}
err = services.Save()
if err != nil {
rollbar.Report(err)
return 1
}
keen.AddEvent("bowery remove", map[string]interface{}{
"toRemove": args,
"existing": services.Data,
})
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:50,代码来源:remove.go
示例3: loginRun
func loginRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
dev, err := db.GetDeveloper()
if err != nil && err != errors.ErrNoDeveloper {
rollbar.Report(err)
return 1
}
// If dev was found then check if token is up to date.
if err == nil {
ok, err := devUpToDate(dev)
if err != nil {
rollbar.Report(err)
return 1
}
if ok {
log.Println("", "You're logged in as",
strings.Split(dev.Developer.Name, " ")[0]+".")
return 0
} else {
log.Println("yellow", "Oops! Your login information is out of date.")
}
}
err = getToken(dev)
if err != nil {
rollbar.Report(err)
return 1
}
err = updateDeveloper(dev)
if err != nil {
rollbar.Report(err)
return 1
}
keen.AddEvent("bowery login", map[string]*db.Developer{"user": dev})
log.Println("magenta", "Hey there", strings.Split(dev.Developer.Name, " ")[0],
"you're logged in now.")
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:42,代码来源:login.go
示例4: inviteRun
func inviteRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
keen.AddEvent("bowery invite", make(map[string]string))
err := sys.OpenPath("mailto:?subject=You%20should%20try%20out%20Bowery&body=Hey!%20I've%20been%20using%20Bowery%20and%20thought%20you'd%20like%20to%20test%20it%20out%3A%0A%0Ahttp%3A%2F%2Fbowery.io")
if err != nil {
rollbar.Report(err)
return 1
}
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:11,代码来源:invite.go
示例5: cleanRun
func cleanRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
db.GetState() // Do this to ensure we're at the root of the app.
contents, _ := ioutil.ReadFile(filepath.Join(".bowery", "state"))
if len(contents) > 0 {
keen.AddEvent("bowery clean", map[string]string{
"contents": string(contents),
})
}
err := os.RemoveAll(".bowery")
if err != nil {
rollbar.Report(err)
return 1
}
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:18,代码来源:clean.go
示例6: saveRun
func saveRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
if len(args) <= 0 {
fmt.Fprintln(os.Stderr,
"Usage: bowery "+Cmds["save"].Usage, "\n\n"+Cmds["save"].Short)
return 2
}
dev, err := getDeveloper()
if err != nil {
rollbar.Report(err)
return 1
}
state, err := db.GetState()
if err != nil {
rollbar.Report(err)
return 1
}
// Create slices of service names, and find the requested service.
var service *schemas.Service
services := make([]string, len(state.App.Services))
for i, v := range state.App.Services {
services[i] = v.Name
if args[0] == v.Name {
service = v
break
}
}
// Handle no service found.
if service == nil {
log.Fprintln(os.Stderr, "red", errors.ErrInvalidService, args[0])
log.Println("yellow", "Valid services:", strings.Join(services, ", "))
return 1
}
log.Debug("Found service", service.Name, "public addr:", service.PublicAddr)
// Get image name
log.Println("yellow", "What would you like to call this image?")
imageName, err := prompt.Basic("Image Name", true)
if err != nil {
rollbar.Report(err)
return 1
}
log.Debug("Collected Image Name", imageName)
imageDesc, err := prompt.Basic("Description", true)
if err != nil {
rollbar.Report(err)
return 1
}
log.Debug("Collected Description", imageDesc)
log.Println("yellow", "A new image is being created and saved to our registry...")
log.Println("yellow", "This may take a couple minutes.")
err = api.SaveService(state, dev, service.Name, service.PublicAddr, imageName, imageDesc)
if err != nil {
errmsg := err.Error()
if errmsg == imageName+" is an invalid service name" ||
errmsg == "Image already exists" {
log.Println("yellow", err)
} else {
rollbar.Report(err)
}
return 1
}
log.Println("yellow", imageName+" successfully created.")
keen.AddEvent("bowery save", map[string]string{
"serviceName": service.Name,
"imageName": imageName,
"appId": state.App.ID,
})
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:79,代码来源:save.go
示例7: updateRun
func updateRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
keen.AddEvent("cli update", map[string]string{"installed": version.Version})
ver, err := api.GetVersion()
if err != nil {
rollbar.Report(err)
return 1
}
if ver == version.Version {
log.Println("", "Bowery is up to date.")
return 0
}
log.Println("yellow", "Bowery is out of date. Updating to", ver, "now...")
newVer, releaseNotes, err := api.DownloadNewVersion(ver)
if err != nil {
rollbar.Report(err)
return 1
}
exec, err := osext.Executable()
if err != nil {
rollbar.Report(errors.NewStackError(err))
return 1
}
tempExec := filepath.Join(filepath.Dir(exec), ".old_bowery"+filepath.Ext(exec))
// Open exec, should fail if execing somewhere else.
file, err := os.Open(exec)
if err != nil {
rollbar.Report(errors.ErrUpdatePerm)
return 1
}
file.Close()
// Create the temp exec file to test io permissions.
file, err = os.Create(tempExec)
if err != nil {
rollbar.Report(errors.ErrUpdatePerm)
return 1
}
file.Close()
// Remove it which also removes any previous executables.
err = os.RemoveAll(tempExec)
if err != nil {
rollbar.Report(err)
return 1
}
// Move the exec to a temp file so we can write the new one.
err = os.Rename(exec, tempExec)
if err != nil {
rollbar.Report(err)
return 1
}
file, err = os.OpenFile(exec, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
rollbar.Report(err)
return 1
}
defer file.Close()
_, err = io.Copy(file, newVer)
if err != nil {
rollbar.Report(err)
return 1
}
log.Println("magenta", "Updated bowery to version", ver+".")
if notes, err := ioutil.ReadAll(releaseNotes); err != nil {
log.Println("", string(notes))
return 0
} else {
rollbar.Report(err)
return 1
}
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:83,代码来源:update.go
示例8: restartRun
func restartRun(keen *keen.Client, rollbar *rollbar.Client, args ...string) int {
if len(args) <= 0 {
fmt.Fprintln(os.Stderr,
"Usage: bowery "+Cmds["restart"].Usage, "\n\n"+Cmds["restart"].Short)
return 2
}
dev, err := getDeveloper()
if err != nil {
rollbar.Report(err)
return 1
}
state, err := db.GetState()
if err != nil {
rollbar.Report(err)
return 1
}
// Create slices of service names, and find the requested service.
var service *schemas.Service
services := make([]string, len(state.App.Services))
serviceIdx := -1
for i, v := range state.App.Services {
services[i] = v.Name
if args[0] == v.Name {
service = v
serviceIdx = i
break
}
}
// Handle no service found.
if service == nil {
log.Fprintln(os.Stderr, "red", errors.ErrInvalidService, args[0])
log.Println("yellow", "Valid services:", strings.Join(services, ", "))
return 1
}
log.Debug("Found service", service.Name)
newService, err := api.RestartService(service.DockerID, dev.Token)
if err != nil {
rollbar.Report(err)
return 1
}
if newService != nil {
state.App.Services[serviceIdx] = newService
service = newService
err = state.Save()
if err != nil {
rollbar.Report(err)
return 1
}
}
keen.AddEvent("bowery restart", map[string]string{
"name": service.Name,
"appId": state.App.ID,
})
return 0
}
开发者ID:Bowery,项目名称:bowery-cli,代码行数:63,代码来源:restart.go
注:本文中的github.com/Bowery/bowery/rollbar.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论