本文整理匯總了Golang中github.com/convox/cli/Godeps/_workspace/src/github.com/codegangsta/cli.Context.Int方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Int方法的具體用法?Golang Context.Int怎麽用?Golang Context.Int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/convox/cli/Godeps/_workspace/src/github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.Int方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: cmdInstall
func cmdInstall(c *cli.Context) {
region := c.String("region")
if !lambdaRegions[region] {
stdcli.Error(fmt.Errorf("Convox is not currently supported in %s", region))
}
tenancy := "default"
instanceType := c.String("instance-type")
if c.Bool("dedicated") {
tenancy = "dedicated"
if strings.HasPrefix(instanceType, "t2") {
stdcli.Error(fmt.Errorf("t2 instance types aren't supported in dedicated tenancy, please set --instance-type."))
}
}
fmt.Println(`
___ ___ ___ __ __ ___ __ _
/ ___\ / __ \ / _ \/\ \/\ \ / __ \/\ \/ \
/\ \__//\ \_\ \/\ \/\ \ \ \_/ |/\ \_\ \/> </
\ \____\ \____/\ \_\ \_\ \___/ \ \____//\_/\_\
\/____/\/___/ \/_/\/_/\/__/ \/___/ \//\/_/
`)
fmt.Println("This installer needs AWS credentials to install the Convox platform into")
fmt.Println("your AWS account. These credentials will only be used to communicate")
fmt.Println("between this installer running on your computer and the AWS API.")
fmt.Println("")
fmt.Println("We recommend that you create a new set of credentials exclusively for this")
fmt.Println("install process and then delete them once the installer has completed.")
fmt.Println("")
fmt.Println("To generate a new set of AWS credentials go to:")
fmt.Println("https://docs.convox.com/docs/creating-an-iam-user-and-credentials")
fmt.Println("")
distinctId, err := currentId()
if err != nil {
handleError("install", distinctId, err)
return
}
reader := bufio.NewReader(os.Stdin)
access := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
if access == "" || secret == "" {
var err error
fmt.Print("AWS Access Key ID: ")
access, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Print("AWS Secret Access Key: ")
secret, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Println("")
}
development := "No"
if c.Bool("development") {
development = "Yes"
}
key := c.String("key")
stackName := c.String("stack-name")
version := c.String("version")
instanceCount := fmt.Sprintf("%d", c.Int("instance-count"))
fmt.Println("Installing Convox...")
access = strings.TrimSpace(access)
secret = strings.TrimSpace(secret)
password := randomString(30)
CloudFormation := cloudformation.New(&aws.Config{
Region: region,
Credentials: credentials.NewStaticCredentials(access, secret, ""),
})
res, err := CloudFormation.CreateStack(&cloudformation.CreateStackInput{
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
Parameters: []*cloudformation.Parameter{
//.........這裏部分代碼省略.........
示例2: cmdInstall
func cmdInstall(c *cli.Context) {
tenancy := "default"
instanceType := c.String("instance-type")
if c.Bool("dedicated") {
tenancy = "dedicated"
if strings.HasPrefix(instanceType, "t2") {
stdcli.Error(fmt.Errorf("t2 instance types aren't supported in dedicated tenancy, please set --instance-type."))
}
}
fmt.Println(`
___ ___ ___ __ __ ___ __ _
/ ___\ / __ \ / _ \/\ \/\ \ / __ \/\ \/ \
/\ \__//\ \_\ \/\ \/\ \ \ \_/ |/\ \_\ \/> </
\ \____\ \____/\ \_\ \_\ \___/ \ \____//\_/\_\
\/____/\/___/ \/_/\/_/\/__/ \/___/ \//\/_/
`)
fmt.Println("This installer needs AWS credentials to install the Convox platform into")
fmt.Println("your AWS account. These credentials will only be used to communicate")
fmt.Println("between this installer running on your computer and the AWS API.")
fmt.Println("")
fmt.Println("We recommend that you create a new set of credentials exclusively for this")
fmt.Println("install process and then delete them once the installer has completed.")
fmt.Println("")
fmt.Println("To generate a new set of AWS credentials go to:")
fmt.Println("https://console.aws.amazon.com/iam/home?region=us-east-1#security_credential")
fmt.Println("")
distinctId, err := currentId()
if err != nil {
handleError("install", distinctId, err)
return
}
reader := bufio.NewReader(os.Stdin)
access := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
if access == "" || secret == "" {
var err error
fmt.Print("AWS Access Key ID: ")
access, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Print("AWS Secret Access Key: ")
secret, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Println("")
}
development := os.Getenv("DEVELOPMENT")
if development != "Yes" {
development = "No"
}
key := os.Getenv("KEY")
stackName := os.Getenv("STACK_NAME")
if stackName == "" {
stackName = "convox"
}
version := os.Getenv("VERSION")
if version == "" {
version = "latest"
}
instanceCount := fmt.Sprintf("%d", c.Int("instance-count"))
fmt.Println("Installing Convox...")
access = strings.TrimSpace(access)
secret = strings.TrimSpace(secret)
password := randomString(30)
CloudFormation := cloudformation.New(&aws.Config{
Region: "us-east-1",
Credentials: credentials.NewStaticCredentials(access, secret, ""),
})
//.........這裏部分代碼省略.........