本文整理汇总了Golang中github.com/aws/amazon-ecs-cli/ecs-cli/modules/config/ami.NewStaticAmiIds函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStaticAmiIds函数的具体用法?Golang NewStaticAmiIds怎么用?Golang NewStaticAmiIds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewStaticAmiIds函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestClusterUp
func TestClusterUp(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockEcs := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
mockEcs.EXPECT().Initialize(gomock.Any())
mockEcs.EXPECT().CreateCluster(gomock.Any()).Do(func(in interface{}) {
if in.(string) != clusterName {
t.Fatal("Expected to be called with " + clusterName + " not " + in.(string))
}
}).Return(clusterName, nil)
mockCloudformation.EXPECT().Initialize(gomock.Any())
mockCloudformation.EXPECT().ValidateStackExists(gomock.Any()).Return(errors.New("error"))
mockCloudformation.EXPECT().CreateStack(gomock.Any(), gomock.Any(), gomock.Any()).Return("", nil)
mockCloudformation.EXPECT().WaitUntilCreateComplete(gomock.Any()).Return(nil)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
flagSet.String(keypairNameFlag, "default", "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, &mockReadWriter{}, mockEcs, mockCloudformation, ami.NewStaticAmiIds())
if err != nil {
t.Fatal("Error bringing up cluster: ", err)
}
}
开发者ID:jloper3,项目名称:amazon-ecs-cli,代码行数:32,代码来源:cluster_app_test.go
示例2: TestClusterUpWithout2AvailabilityZones
func TestClusterUpWithout2AvailabilityZones(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockECS := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
vpcAZs := "us-west-2c"
os.Setenv("AWS_ACCESS_KEY", "AKIDEXAMPLE")
os.Setenv("AWS_SECRET_KEY", "secret")
defer func() {
os.Unsetenv("AWS_ACCESS_KEY")
os.Unsetenv("AWS_SECRET_KEY")
}()
gomock.InOrder(
mockCloudformation.EXPECT().Initialize(gomock.Any()),
mockCloudformation.EXPECT().ValidateStackExists(stackName).Return(errors.New("error")),
)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
flagSet.String(keypairNameFlag, "default", "")
flagSet.Bool(forceFlag, true, "")
flagSet.String(vpcAzFlag, vpcAZs, "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, newMockReadWriter(), mockECS, mockCloudformation, ami.NewStaticAmiIds())
if err == nil {
t.Fatal("Expected error for 2 AZs")
}
}
开发者ID:yinshiua,项目名称:amazon-ecs-cli,代码行数:34,代码来源:cluster_app_test.go
示例3: TestClusterUpForImageIdInput
func TestClusterUpForImageIdInput(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockEcs := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
imageId := "ami-12345"
os.Setenv("AWS_ACCESS_KEY", "AKIDEXAMPLE")
os.Setenv("AWS_SECRET_KEY", "secret")
defer func() {
os.Unsetenv("AWS_ACCESS_KEY")
os.Unsetenv("AWS_SECRET_KEY")
}()
gomock.InOrder(
mockEcs.EXPECT().Initialize(gomock.Any()),
mockEcs.EXPECT().CreateCluster(gomock.Any()).Do(func(in interface{}) {
if in.(string) != clusterName {
t.Fatal("Expected to be called with " + clusterName + " not " + in.(string))
}
}).Return(clusterName, nil),
)
gomock.InOrder(
mockCloudformation.EXPECT().Initialize(gomock.Any()),
mockCloudformation.EXPECT().ValidateStackExists(gomock.Any()).Return(errors.New("error")),
mockCloudformation.EXPECT().CreateStack(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(x, y, z interface{}) {
cfnStackParams := z.(*cloudformation.CfnStackParams)
param, err := cfnStackParams.GetParameter(cloudformation.ParameterKeyAmiId)
if err != nil {
t.Fatal("Expected image id params to be present")
}
if imageId != aws.StringValue(param.ParameterValue) {
t.Fatalf("Expected image id to equal %s but got %s", imageId, aws.StringValue(param.ParameterValue))
}
}).Return("", nil),
mockCloudformation.EXPECT().WaitUntilCreateComplete(gomock.Any()).Return(nil),
)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
flagSet.String(keypairNameFlag, "default", "")
flagSet.String(imageIdFlag, imageId, "")
flagSet.String(certificateFlag, "default", "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, &mockReadWriter{}, mockEcs, mockCloudformation, ami.NewStaticAmiIds())
if err != nil {
t.Fatal("Error bringing up cluster: ", err)
}
}
开发者ID:abdollar,项目名称:amazon-ecs-cli,代码行数:55,代码来源:cluster_app_test.go
示例4: ClusterUp
func ClusterUp(c *cli.Context) {
rdwr, err := config.NewReadWriter()
if err != nil {
logrus.Error("Error executing 'up': ", err)
return
}
ecsClient := ecsclient.NewECSClient()
cfnClient := cloudformation.NewCloudformationClient()
amiIds := ami.NewStaticAmiIds()
if err := createCluster(c, rdwr, ecsClient, cfnClient, amiIds); err != nil {
logrus.Error("Error executing 'up': ", err)
return
}
}
开发者ID:uttarasridhar,项目名称:amazon-ecs-cli,代码行数:15,代码来源:cluster_app.go
示例5: TestClusterUpWithoutRegion
func TestClusterUpWithoutRegion(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockECS := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, newMockReadWriter(), mockECS, mockCloudformation, ami.NewStaticAmiIds())
if err == nil {
t.Fatal("Expected error bringing up cluster")
}
}
开发者ID:yinshiua,项目名称:amazon-ecs-cli,代码行数:17,代码来源:cluster_app_test.go
示例6: TestClusterUpWithVPC
func TestClusterUpWithVPC(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockECS := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
vpcId := "vpc-02dd3038"
subnetIds := "subnet-04726b21,subnet-04346b21"
os.Setenv("AWS_ACCESS_KEY", "AKIDEXAMPLE")
os.Setenv("AWS_SECRET_KEY", "secret")
defer func() {
os.Unsetenv("AWS_ACCESS_KEY")
os.Unsetenv("AWS_SECRET_KEY")
}()
gomock.InOrder(
mockECS.EXPECT().Initialize(gomock.Any()),
mockECS.EXPECT().CreateCluster(clusterName).Return(clusterName, nil),
)
gomock.InOrder(
mockCloudformation.EXPECT().Initialize(gomock.Any()),
mockCloudformation.EXPECT().ValidateStackExists(stackName).Return(errors.New("error")),
mockCloudformation.EXPECT().CreateStack(gomock.Any(), stackName, gomock.Any()).Return("", nil),
mockCloudformation.EXPECT().WaitUntilCreateComplete(stackName).Return(nil),
)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
flagSet.String(keypairNameFlag, "default", "")
flagSet.String(vpcIdFlag, vpcId, "")
flagSet.String(subnetIdsFlag, subnetIds, "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, newMockReadWriter(), mockECS, mockCloudformation, ami.NewStaticAmiIds())
if err != nil {
t.Fatal("Error bringing up cluster: ", err)
}
}
开发者ID:yinshiua,项目名称:amazon-ecs-cli,代码行数:43,代码来源:cluster_app_test.go
示例7: TestClusterUpWithoutKeyPair
func TestClusterUpWithoutKeyPair(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockEcs := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
gomock.InOrder(
mockCloudformation.EXPECT().Initialize(gomock.Any()),
mockCloudformation.EXPECT().ValidateStackExists(gomock.Any()).Return(errors.New("error")),
)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, &mockReadWriter{}, mockEcs, mockCloudformation, ami.NewStaticAmiIds())
if err == nil {
t.Fatal("Expected error for key pair name")
}
}
开发者ID:nrdlngr,项目名称:amazon-ecs-cli,代码行数:22,代码来源:cluster_app_test.go
示例8: TestClusterUpWith2SecurityGroups
func TestClusterUpWith2SecurityGroups(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockECS := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
securityGroupIds := "sg-eeaabc8d,sg-eaaebc8d"
vpcId := "vpc-02dd3038"
subnetIds := "subnet-04726b21,subnet-04346b21"
os.Setenv("AWS_ACCESS_KEY", "AKIDEXAMPLE")
os.Setenv("AWS_SECRET_KEY", "secret")
defer func() {
os.Unsetenv("AWS_ACCESS_KEY")
os.Unsetenv("AWS_SECRET_KEY")
}()
gomock.InOrder(
mockCloudformation.EXPECT().Initialize(gomock.Any()),
mockCloudformation.EXPECT().ValidateStackExists(stackName).Return(errors.New("error")),
)
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
flagSet.String(keypairNameFlag, "default", "")
flagSet.Bool(forceFlag, true, "")
flagSet.String(securityGroupFlag, securityGroupIds, "")
flagSet.String(vpcIdFlag, vpcId, "")
flagSet.String(subnetIdsFlag, subnetIds, "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, newMockReadWriter(), mockECS, mockCloudformation, ami.NewStaticAmiIds())
if err == nil {
t.Fatal("Expected error for security group without VPC")
}
}
开发者ID:yinshiua,项目名称:amazon-ecs-cli,代码行数:38,代码来源:cluster_app_test.go
示例9: TestClusterUpWithClusterNameEmpty
func TestClusterUpWithClusterNameEmpty(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockECS := mock_ecs.NewMockECSClient(ctrl)
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
os.Setenv("AWS_ACCESS_KEY", "AKIDEXAMPLE")
os.Setenv("AWS_SECRET_KEY", "secret")
defer func() {
os.Unsetenv("AWS_ACCESS_KEY")
os.Unsetenv("AWS_SECRET_KEY")
}()
globalSet := flag.NewFlagSet("ecs-cli", 0)
globalSet.String("region", "us-west-1", "")
globalContext := cli.NewContext(nil, globalSet, nil)
flagSet := flag.NewFlagSet("ecs-cli-up", 0)
flagSet.Bool(capabilityIAMFlag, true, "")
flagSet.String(keypairNameFlag, "default", "")
context := cli.NewContext(nil, flagSet, globalContext)
err := createCluster(context, &mockReadWriter{clusterName: ""}, mockECS, mockCloudformation, ami.NewStaticAmiIds())
if err == nil {
t.Fatal("Expected error bringing up cluster")
}
}
开发者ID:yinshiua,项目名称:amazon-ecs-cli,代码行数:27,代码来源:cluster_app_test.go
注:本文中的github.com/aws/amazon-ecs-cli/ecs-cli/modules/config/ami.NewStaticAmiIds函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论