• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang client.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/deis/deis/client-go/controller/client.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Cancel

// Cancel deletes a user's account.
func Cancel(username string, password string, yes bool) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	if username == "" || password != "" {
		fmt.Println("Please log in again in order to cancel this account")

		if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil {
			return err
		}
	}

	if yes == false {
		confirm := ""

		c, err = client.New()

		if err != nil {
			return err
		}

		deletedUser := username

		if deletedUser == "" {
			deletedUser = c.Username
		}

		fmt.Printf("cancel account %s at %s? (y/N): ", deletedUser, c.ControllerURL.String())
		fmt.Scanln(&confirm)

		if strings.ToLower(confirm) == "y" {
			yes = true
		}
	}

	if yes == false {
		fmt.Println("Account not changed")
		return nil
	}

	err = auth.Delete(c, username)

	if err != nil {
		return err
	}

	// If user targets themselves, logout.
	if username != "" || c.Username == username {
		if err := client.Delete(); err != nil {
			return err
		}
	}

	fmt.Println("Account cancelled")
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:60,代码来源:auth.go


示例2: Cancel

// Cancel deletes a user's account.
func Cancel(username string, password string, yes bool) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	fmt.Println("Please log in again in order to cancel this account")

	if err = Login(c.ControllerURL.String(), username, password, c.SSLVerify); err != nil {
		return err
	}

	if yes == false {
		confirm := ""

		c, err = client.New()

		if err != nil {
			return err
		}

		fmt.Printf("cancel account %s at %s? (y/N): ", c.Username, c.ControllerURL.String())
		fmt.Scanln(&confirm)

		if strings.ToLower(confirm) == "y" {
			yes = true
		}
	}

	if yes == false {
		fmt.Println("Account not changed")
		return nil
	}

	err = auth.Delete(c)

	if err != nil {
		return err
	}

	if err := client.Delete(); err != nil {
		return err
	}

	fmt.Println("Account cancelled")
	return nil
}
开发者ID:kuvi-innovations,项目名称:deis,代码行数:49,代码来源:auth.go


示例3: AppCreate

// AppCreate creates an app.
func AppCreate(id string, buildpack string, remote string, noRemote bool) error {
	c, err := client.New()

	fmt.Print("Creating Application... ")
	quit := progress()
	app, err := apps.New(c, id)

	quit <- true
	<-quit

	if err != nil {
		return err
	}

	fmt.Printf("done, created %s\n", app.ID)

	if buildpack != "" {
		configValues := api.Config{
			Values: map[string]interface{}{
				"BUILDPACK_URL": buildpack,
			},
		}
		if _, err = config.Set(c, app.ID, configValues); err != nil {
			return err
		}
	}

	if !noRemote {
		return git.CreateRemote(c.ControllerURL.Host, remote, app.ID)
	}

	fmt.Println("remote available at", git.RemoteURL(c.ControllerURL.Host, app.ID))

	return nil
}
开发者ID:rsackler,项目名称:deis,代码行数:36,代码来源:apps.go


示例4: KeyAdd

// KeyAdd adds keys.
func KeyAdd(keyLocation string) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	var key api.KeyCreateRequest

	if keyLocation == "" {
		key, err = chooseKey()
	} else {
		key, err = getKey(keyLocation)
	}

	if err != nil {
		return err
	}

	fmt.Printf("Uploading %s to deis...", path.Base(key.Name))

	if _, err = keys.New(c, key.ID, key.Public); err != nil {
		fmt.Println()
		return err
	}

	fmt.Println(" done")
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:30,代码来源:keys.go


示例5: Regenerate

// Regenerate regenenerates a user's token.
func Regenerate(username string, all bool) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	token, err := auth.Regenerate(c, username, all)

	if err != nil {
		return err
	}

	if username == "" && all == false {
		c.Token = token

		err = c.Save()

		if err != nil {
			return err
		}
	}

	fmt.Println("Token Regenerated")
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:27,代码来源:auth.go


示例6: Whoami

// Whoami prints the logged in user.
func Whoami() error {
	c, err := client.New()

	if err != nil {
		return err
	}

	fmt.Printf("You are %s at %s\n", c.Username, c.ControllerURL.String())
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:11,代码来源:auth.go


示例7: CertsList

// CertsList lists certs registered with the controller.
func CertsList() error {
	c, err := client.New()

	if err != nil {
		return err
	}

	certList, err := certs.List(c)

	if err != nil {
		return err
	}

	if len(certList) == 0 {
		fmt.Println("No certs")
		return nil
	}

	certMap := make(map[string]string)
	nameMax := 0
	expiresMax := 0
	for _, cert := range certList {
		certMap[cert.Name] = cert.Expires

		if len(cert.Name) > nameMax {
			nameMax = len(cert.Name)
		}
		if len(cert.Expires) > nameMax {
			expiresMax = len(cert.Expires)
		}
	}

	nameHeader := "Common Name"
	expiresHeader := "Expires"
	tabSpaces := 5
	bufferSpaces := tabSpaces

	if nameMax < len(nameHeader) {
		tabSpaces += len(nameHeader) - nameMax
		nameMax = len(nameHeader)
	} else {
		bufferSpaces += nameMax - len(nameHeader)
	}

	if expiresMax < len(expiresHeader) {
		expiresMax = len(expiresHeader)
	}

	fmt.Printf("%s%s%s\n", nameHeader, strings.Repeat(" ", bufferSpaces), expiresHeader)
	fmt.Printf("%s%s%s\n", strings.Repeat("-", nameMax), strings.Repeat(" ", 5),
		strings.Repeat("-", expiresMax))
	fmt.Print(prettyprint.PrettyTabs(certMap, tabSpaces))
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:55,代码来源:certs.go


示例8: AppDestroy

// AppDestroy destroys an app.
func AppDestroy(appID, confirm string) error {
	gitSession := false

	c, err := client.New()

	if err != nil {
		return err
	}

	if appID == "" {
		appID, err = git.DetectAppName(c.ControllerURL.Host)

		if err != nil {
			return err
		}

		gitSession = true
	}

	if confirm == "" {
		fmt.Printf(` !    WARNING: Potentially Destructive Action
 !    This command will destroy the application: %s
 !    To proceed, type "%s" or re-run this command with --confirm=%s

> `, appID, appID, appID)

		fmt.Scanln(&confirm)
	}

	if confirm != appID {
		return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm)
	}

	startTime := time.Now()
	fmt.Printf("Destroying %s...\n", appID)

	if err = apps.Delete(c, appID); err != nil {
		return err
	}

	fmt.Printf("done in %ds\n", int(time.Since(startTime).Seconds()))

	if gitSession {
		return git.DeleteRemote(appID)
	}

	return nil
}
开发者ID:rsackler,项目名称:deis,代码行数:49,代码来源:apps.go


示例9: KeyRemove

// KeyRemove removes keys.
func KeyRemove(keyID string) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	fmt.Printf("Removing %s SSH Key...", keyID)

	if err = keys.Delete(c, keyID); err != nil {
		fmt.Println()
		return err
	}

	fmt.Println(" done")
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:18,代码来源:keys.go


示例10: permsLoad

func permsLoad(appID string, admin bool) (*client.Client, string, error) {
	c, err := client.New()

	if err != nil {
		return nil, "", err
	}

	if !admin && appID == "" {
		appID, err = git.DetectAppName(c.ControllerURL.Host)

		if err != nil {
			return nil, "", err
		}
	}

	return c, appID, err
}
开发者ID:rsackler,项目名称:deis,代码行数:17,代码来源:perms.go


示例11: load

func load(appID string) (*client.Client, string, error) {
	c, err := client.New()

	if err != nil {
		return nil, "", err
	}

	if appID == "" {
		appID, err = git.DetectAppName(c.ControllerURL.Host)

		if err != nil {
			return nil, "", err
		}
	}

	return c, appID, nil
}
开发者ID:rsackler,项目名称:deis,代码行数:17,代码来源:utils.go


示例12: permsLoad

func permsLoad(appID string, admin bool) (*client.Client, string, error) {
	c, err := client.New()

	if err != nil {
		return nil, "", err
	}

	if !admin && appID == "" {
		appID, err = c.DetectApp()

		if err != nil {
			return nil, "", err
		}
	}

	return c, appID, err
}
开发者ID:uniite,项目名称:deis,代码行数:17,代码来源:perms.go


示例13: load

func load(appID string) (*client.Client, string, error) {
	c, err := client.New()

	if err != nil {
		return nil, "", err
	}

	if appID == "" {
		appID, err = c.DetectApp()

		if err != nil {
			return nil, "", err
		}
	}

	return c, appID, nil
}
开发者ID:Kazanz,项目名称:deis,代码行数:17,代码来源:utils.go


示例14: AppDestroy

// AppDestroy destroys an app.
func AppDestroy(appID, confirm string) error {
	gitSession := false

	c, err := client.New()

	if err != nil {
		return err
	}

	if appID == "" {
		appID, err = c.DetectApp()

		if err != nil {
			return err
		}

		gitSession = true
	}

	if confirm == "" {
		fmt.Printf(` !    WARNING: Potentially Destructive Action
 !    This command will destroy the application: %s
 !    To proceed, type "%s" or re-run this command with --confirm=%s

>`, appID, appID, appID)

		fmt.Scanln(&confirm)
	}

	if confirm != appID {
		return fmt.Errorf("App %s does not match confirm %s, aborting.", appID, confirm)
	}

	fmt.Printf("Destroying %s...", appID)

	if err = apps.Delete(c, appID); err != nil {
		return err
	}

	if gitSession {
		return c.DeleteRemote(appID)
	}

	return nil
}
开发者ID:Kazanz,项目名称:deis,代码行数:46,代码来源:apps.go


示例15: Passwd

// Passwd changes a user's password.
func Passwd(username string, password string, newPassword string) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	if password == "" && username == "" {
		fmt.Print("current password: ")
		password, err = readPassword()
		fmt.Println()

		if err != nil {
			return err
		}
	}

	if newPassword == "" {
		fmt.Print("new password: ")
		newPassword, err = readPassword()
		fmt.Printf("\nnew password (confirm): ")
		passwordConfirm, err := readPassword()

		fmt.Println()

		if err != nil {
			return err
		}

		if newPassword != passwordConfirm {
			return errors.New("Password mismatch, not changing.")
		}
	}

	err = auth.Passwd(c, username, password, newPassword)

	if err != nil {
		return err
	}

	fmt.Println("Password change succeeded.")
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:44,代码来源:auth.go


示例16: KeysList

// KeysList lists a user's keys.
func KeysList() error {
	c, err := client.New()

	if err != nil {
		return err
	}

	keys, err := keys.List(c)

	if err != nil {
		return err
	}

	fmt.Printf("=== %s Keys\n", c.Username)

	for _, key := range keys {
		fmt.Printf("%s %s...%s\n", key.ID, key.Public[:16], key.Public[len(key.Public)-10:])
	}
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:21,代码来源:keys.go


示例17: CertAdd

// CertAdd adds a cert to the controller.
func CertAdd(cert, key, commonName, sans string) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	fmt.Print("Adding SSL endpoint... ")
	quit := progress()
	err = processCertsAdd(c, cert, key, commonName, sans)
	quit <- true
	<-quit

	if err != nil {
		return err
	}

	fmt.Println("done")
	return nil
}
开发者ID:laurrentt,项目名称:deis,代码行数:21,代码来源:certs.go


示例18: AppsList

// AppsList lists apps on the Deis controller.
func AppsList() error {
	c, err := client.New()

	if err != nil {
		return err
	}

	apps, err := apps.List(c)

	if err != nil {
		return err
	}

	fmt.Println("=== Apps")

	for _, app := range apps {
		fmt.Println(app.ID)
	}
	return nil
}
开发者ID:Kazanz,项目名称:deis,代码行数:21,代码来源:apps.go


示例19: CertRemove

// CertRemove deletes a cert from the controller.
func CertRemove(commonName string) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	fmt.Printf("Removing %s... ", commonName)
	quit := progress()

	certs.Delete(c, commonName)

	quit <- true
	<-quit

	if err == nil {
		fmt.Println("done")
	}

	return err
}
开发者ID:laurrentt,项目名称:deis,代码行数:22,代码来源:certs.go


示例20: KeysList

// KeysList lists a user's keys.
func KeysList(results int) error {
	c, err := client.New()

	if err != nil {
		return err
	}

	if results == defaultLimit {
		results = c.ResponseLimit
	}

	keys, count, err := keys.List(c, results)

	if err != nil {
		return err
	}

	fmt.Printf("=== %s Keys%s", c.Username, limitCount(len(keys), count))

	for _, key := range keys {
		fmt.Printf("%s %s...%s\n", key.ID, key.Public[:16], key.Public[len(key.Public)-10:])
	}
	return nil
}
开发者ID:rsackler,项目名称:deis,代码行数:25,代码来源:keys.go



注:本文中的github.com/deis/deis/client-go/controller/client.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang client.Client类代码示例发布时间:2022-05-23
下一篇:
Golang client.CreateHTTPClient函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap