本文整理汇总了Golang中github.com/Scalingo/cli/config.ScalingoClient函数的典型用法代码示例。如果您正苦于以下问题:Golang ScalingoClient函数的具体用法?Golang ScalingoClient怎么用?Golang ScalingoClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ScalingoClient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: List
func List() error {
c := config.ScalingoClient()
apps, err := c.AppsList()
if err != nil {
return errgo.Mask(err, errgo.Any)
}
if len(apps) == 0 {
fmt.Println(io.Indent("\nYou haven't created any app yet, create your first application using:\n→ scalingo create <app_name>\n", 2))
return nil
}
t := tablewriter.NewWriter(os.Stdout)
t.SetHeader([]string{"Name", "Role", "Owner"})
for _, app := range apps {
if app.Owner.Email == config.AuthenticatedUser.Email {
t.Append([]string{app.Name, "owner", "-"})
} else {
t.Append([]string{app.Name, "collaborator", fmt.Sprintf("%s <%s>", app.Owner.Username, app.Owner.Email)})
}
}
t.Render()
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:26,代码来源:list.go
示例2: Add
func Add(name string, path string) error {
stat, err := os.Stat(path)
if err != nil {
return errgo.Mask(err)
}
if stat.Mode().IsDir() {
return errgo.Newf("%s: is a directory", path)
}
if stat.Size() > 10*1024*1024 {
return errgo.Newf("%s: is too large (%v bytes)", stat.Size())
}
keyContent, err := ioutil.ReadFile(path)
if err != nil {
return errgo.Mask(err)
}
c := config.ScalingoClient()
_, err = c.KeysAdd(name, string(keyContent))
if err != nil {
return errgo.Mask(err)
}
fmt.Printf("Key '%s' has been added.\n", name)
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:26,代码来源:add.go
示例3: DbTunnelAutoComplete
func DbTunnelAutoComplete(c *cli.Context) error {
appName := CurrentAppCompletion(c)
if appName == "" {
return nil
}
lastArg := ""
if len(os.Args) > 2 {
lastArg = os.Args[len(os.Args)-2]
}
if !strings.HasPrefix(lastArg, "-") {
client := config.ScalingoClient()
variables, err := client.VariablesList(appName)
if err == nil {
for _, v := range variables {
if matched, err := regexp.Match("SCALINGO_.*_URL", []byte(v.Name)); matched && err == nil {
fmt.Println(v.Name)
}
}
}
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:26,代码来源:db_tunnel.go
示例4: Add
func Add(app string, params []string) error {
var variables scalingo.Variables
for _, param := range params {
if err := isEnvEditValid(param); err != nil {
return errgo.Newf("'%s' is invalid: %s", param, err)
}
name, value := parseVariable(param)
variables = append(variables, &scalingo.Variable{
Name: name,
Value: value,
})
}
c := config.ScalingoClient()
_, _, err := c.VariableMultipleSet(app, variables)
if err != nil {
return errgo.Mask(err, errgo.Any)
}
for _, variable := range variables {
fmt.Printf("%s has been set to '%s'.\n", variable.Name, variable.Value)
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:26,代码来源:edit.go
示例5: Delete
func Delete(app string, varNames []string) error {
c := config.ScalingoClient()
vars, err := c.VariablesList(app)
if err != nil {
return errgo.Mask(err, errgo.Any)
}
var varsToUnset scalingo.Variables
for _, varName := range varNames {
v, ok := vars.Contains(varName)
if !ok {
return errgo.Newf("%s variable does not exist", varName)
}
varsToUnset = append(varsToUnset, v)
}
for _, v := range varsToUnset {
err := c.VariableUnset(app, v.ID)
if err != nil {
return errgo.Mask(err, errgo.Any)
}
fmt.Printf("%s has been unset.\n", v.Name)
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:27,代码来源:edit.go
示例6: AddonsAddAutoComplete
func AddonsAddAutoComplete(c *cli.Context) error {
client := config.ScalingoClient()
resources, err := client.AddonProvidersList()
if len(os.Args) > 1 && err == nil {
lastArg := os.Args[len(os.Args)-2]
isAddonNameSet := false
for _, resource := range resources {
if lastArg == resource.ID {
isAddonNameSet = true
break
}
}
if isAddonNameSet {
plans, err := client.AddonProviderPlansList(lastArg)
if err == nil {
for _, plan := range plans {
fmt.Println(plan.Name)
}
}
} else {
for _, resource := range resources {
fmt.Println(resource.ID)
}
}
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:32,代码来源:addons_add.go
示例7: KeysRemoveAutoComplete
func KeysRemoveAutoComplete(c *cli.Context) error {
client := config.ScalingoClient()
keys, err := client.KeysList()
if err == nil {
for _, key := range keys {
fmt.Println(key.Name)
}
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:11,代码来源:keys_remove.go
示例8: Display
func Display(app string) error {
c := config.ScalingoClient()
vars, err := c.VariablesList(app)
if err != nil {
return errgo.Mask(err, errgo.Any)
}
for _, v := range vars {
fmt.Printf("%s=%s\n", v.Name, v.Value)
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:12,代码来源:display.go
示例9: keyByName
func keyByName(name string) (*scalingo.Key, error) {
c := config.ScalingoClient()
keys, err := c.KeysList()
if err != nil {
return nil, errgo.Mask(err)
}
for _, k := range keys {
if k.Name == name {
return &k, nil
}
}
return nil, errgo.New("no such key")
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:13,代码来源:remove.go
示例10: getFromEmail
func getFromEmail(app, email string) (scalingo.Collaborator, error) {
c := config.ScalingoClient()
collaborators, err := c.CollaboratorsList(app)
if err != nil {
return scalingo.Collaborator{}, errgo.Mask(err, errgo.Any)
}
for _, collaborator := range collaborators {
if collaborator.Email == email {
return collaborator, nil
}
}
return scalingo.Collaborator{}, notFound
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:13,代码来源:remove.go
示例11: handleOperation
func handleOperation(app string, res *http.Response) error {
opURL, err := url.Parse(res.Header.Get("Location"))
if err != nil {
return errgo.Mask(err)
}
var op *scalingo.Operation
opID := filepath.Base(opURL.Path)
done := make(chan struct{})
errs := make(chan error)
defer close(done)
defer close(errs)
go func() {
c := config.ScalingoClient()
for {
op, err = c.OperationsShow(app, opID)
if err != nil {
errs <- err
break
}
if op.Status == "done" || op.Status == "error" {
done <- struct{}{}
break
}
time.Sleep(1 * time.Second)
}
}()
fmt.Print("Status: ")
spinner := io.NewSpinner(os.Stderr)
go spinner.Start()
defer spinner.Stop()
for {
select {
case err := <-errs:
return errgo.Mask(err)
case <-done:
if op.Status == "done" {
fmt.Printf("\bDone in %.3f seconds\n", op.ElapsedDuration())
return nil
} else if op.Status == "error" {
fmt.Printf("\bOperation '%s' failed, an error occured: %v\n", op.Type, op.Error)
return nil
}
}
}
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:51,代码来源:operations.go
示例12: findDomain
func findDomain(app string, domain string) (scalingo.Domain, error) {
c := config.ScalingoClient()
domains, err := c.DomainsList(app)
if err != nil {
return scalingo.Domain{}, errgo.Mask(err)
}
for _, d := range domains {
if d.Name == domain {
return d, nil
}
}
return scalingo.Domain{}, errgo.New("There is no such domain, please ensure you've added it correctly.\nhttps://my.scalingo.com/apps/" + app + "/domains")
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:14,代码来源:remove.go
示例13: DisableSSL
func DisableSSL(app string, domain string) error {
d, err := findDomain(app, domain)
if err != nil {
return errgo.Mask(err)
}
c := config.ScalingoClient()
_, err = c.DomainsUpdate(app, d.ID, "", "")
if err != nil {
return errgo.Mask(err)
}
io.Status("SSL of " + domain + " has been disabled.")
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:14,代码来源:ssl.go
示例14: Remove
func Remove(name string) error {
k, err := keyByName(name)
if err != nil {
return errgo.Mask(err)
}
c := config.ScalingoClient()
err = c.KeysDelete(k.ID)
if err != nil {
return errgo.Mask(err)
}
fmt.Printf("Key '%s' has been deleted.\n", name)
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:15,代码来源:remove.go
示例15: DeploymentsAutoComplete
func DeploymentsAutoComplete(c *cli.Context) error {
client := config.ScalingoClient()
currentApp := appdetect.CurrentApp(c)
deployments, err := client.DeploymentList(currentApp)
if err != nil {
return errgo.Mask(err, errgo.Any)
}
for _, deployment := range deployments {
fmt.Println(deployment.ID)
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:15,代码来源:deployments.go
示例16: ScaleAutoComplete
func ScaleAutoComplete(c *cli.Context) error {
appName := CurrentAppCompletion(c)
if appName == "" {
return nil
}
client := config.ScalingoClient()
processes, err := client.AppsPs(appName)
if err != nil {
return errgo.Mask(err)
}
for _, ct := range processes {
fmt.Println(fmt.Sprintf("%s:%d:%s", ct.Name, ct.Amount, ct.Size))
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:17,代码来源:scale.go
示例17: RestartAutoComplete
func RestartAutoComplete(c *cli.Context) error {
appName := CurrentAppCompletion(c)
if appName == "" {
return nil
}
client := config.ScalingoClient()
processes, err := client.AppsPs(appName)
if err != nil {
return errgo.Mask(err)
}
for _, ct := range processes {
fmt.Println(ct.Name)
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:17,代码来源:restart.go
示例18: EnvUnsetAutoComplete
func EnvUnsetAutoComplete(c *cli.Context) error {
appName := CurrentAppCompletion(c)
if appName == "" {
return nil
}
client := config.ScalingoClient()
variables, err := client.VariablesList(appName)
if err == nil {
for _, v := range variables {
fmt.Println(v.Name)
}
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:17,代码来源:env_unset.go
示例19: AddonsRemoveAutoComplete
func AddonsRemoveAutoComplete(c *cli.Context) error {
appName := CurrentAppCompletion(c)
if appName == "" {
return nil
}
client := config.ScalingoClient()
resources, err := client.AddonsList(appName)
if err == nil {
for _, resource := range resources {
fmt.Println(resource.ResourceID)
}
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:17,代码来源:addons_remove.go
示例20: DomainsRemoveAutoComplete
func DomainsRemoveAutoComplete(c *cli.Context) error {
appName := CurrentAppCompletion(c)
if appName == "" {
return nil
}
client := config.ScalingoClient()
domains, err := client.DomainsList(appName)
if err == nil {
for _, domain := range domains {
fmt.Println(domain.Name)
}
}
return nil
}
开发者ID:carriercomm,项目名称:cli-8,代码行数:17,代码来源:domains_remove.go
注:本文中的github.com/Scalingo/cli/config.ScalingoClient函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论