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

Golang ec2.NewBlackholeEC2MetadataClient函数代码示例

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

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



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

示例1: TestSubmitContainerStateChangeLongReason

func TestSubmitContainerStateChangeLongReason(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()
	client, _, mockSubmitStateClient := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient())
	exitCode := 20
	trimmedReason := strings.Repeat("a", api.EcsMaxReasonLength)
	reason := strings.Repeat("a", api.EcsMaxReasonLength+1)

	mockSubmitStateClient.EXPECT().SubmitContainerStateChange(&containerSubmitInputMatcher{
		ecs.SubmitContainerStateChangeInput{
			Cluster:         strptr(configuredCluster),
			Task:            strptr("arn"),
			ContainerName:   strptr("cont"),
			Status:          strptr("STOPPED"),
			ExitCode:        int64ptr(&exitCode),
			Reason:          strptr(trimmedReason),
			NetworkBindings: []*ecs.NetworkBinding{},
		},
	})
	err := client.SubmitContainerStateChange(api.ContainerStateChange{
		TaskArn:       "arn",
		ContainerName: "cont",
		Status:        api.ContainerStopped,
		ExitCode:      &exitCode,
		Reason:        reason,
	})
	if err != nil {
		t.Errorf("Unable to submit container state change: %v", err)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:30,代码来源:api_client_test.go


示例2: TestTrimWhitespace

func TestTrimWhitespace(t *testing.T) {
	os.Setenv("ECS_CLUSTER", "default \r")
	os.Setenv("ECS_ENGINE_AUTH_TYPE", "dockercfg\r")

	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}
	if cfg.Cluster != "default" {
		t.Error("Wrong cluster: " + cfg.Cluster)
	}
	if cfg.EngineAuthType != "dockercfg" {
		t.Error("Wrong auth type: " + cfg.EngineAuthType)
	}

	cfg = &Config{
		Cluster:   " asdf ",
		AWSRegion: " us-east-1\r\t",
		DataDir:   "/trailing/space/directory ",
	}
	cfg.trimWhitespace()
	if !reflect.DeepEqual(cfg, &Config{Cluster: "asdf", AWSRegion: "us-east-1", DataDir: "/trailing/space/directory "}) {
		t.Error("Did not match expected", *cfg)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:25,代码来源:config_test.go


示例3: TestConfigDefault

func TestConfigDefault(t *testing.T) {
	os.Unsetenv("ECS_DISABLE_METRICS")
	os.Unsetenv("ECS_RESERVED_PORTS")
	os.Unsetenv("ECS_RESERVED_MEMORY")
	os.Unsetenv("ECS_DISABLE_PRIVILEGED")
	os.Unsetenv("ECS_AVAILABLE_LOGGING_DRIVERS")
	os.Unsetenv("ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION")
	os.Unsetenv("ECS_ENABLE_TASK_IAM_ROLE")
	os.Unsetenv("ECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST")
	os.Unsetenv("ECS_CONTAINER_STOP_TIMEOUT")
	os.Unsetenv("ECS_AUDIT_LOGFILE")
	os.Unsetenv("ECS_AUDIT_LOGFILE_DISABLED")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}
	if cfg.DockerEndpoint != "unix:///var/run/docker.sock" {
		t.Error("Default docker endpoint set incorrectly")
	}
	if cfg.DataDir != "/data/" {
		t.Error("Default datadir set incorrectly")
	}
	if cfg.DisableMetrics {
		t.Errorf("Default disablemetrics set incorrectly: %v", cfg.DisableMetrics)
	}
	if len(cfg.ReservedPorts) != 5 {
		t.Error("Default resered ports set incorrectly")
	}
	if cfg.ReservedMemory != 0 {
		t.Errorf("Default reserved memory set incorrectly: %v", cfg.ReservedMemory)
	}
	expectedTimeout, _ := time.ParseDuration("30s")
	if cfg.DockerStopTimeout != expectedTimeout {
		t.Error("Default docker stop container timeout set incorrectly", cfg.DockerStopTimeout)
	}
	if cfg.PrivilegedDisabled {
		t.Errorf("Default PrivilegedDisabled set incorrectly: %v", cfg.PrivilegedDisabled)
	}
	if !reflect.DeepEqual(cfg.AvailableLoggingDrivers, []dockerclient.LoggingDriver{dockerclient.JsonFileDriver}) {
		t.Errorf("Default logging drivers set incorrectly: %v", cfg.AvailableLoggingDrivers)
	}
	if cfg.TaskCleanupWaitDuration != 3*time.Hour {
		t.Errorf("Defualt task cleanup wait duration set incorrectly: %v", cfg.TaskCleanupWaitDuration)
	}
	if cfg.TaskIAMRoleEnabled {
		t.Error("TaskIAMRoleEnabled set incorrectly")
	}
	if cfg.TaskIAMRoleEnabledForNetworkHost {
		t.Error("TaskIAMRoleEnabledForNetworkHost set incorrectly")
	}
	if cfg.CredentialsAuditLogDisabled {
		t.Error("CredentialsAuditLogDisabled set incorrectly")
	}
	if cfg.CredentialsAuditLogFile != defaultCredentialsAuditLogFile {
		t.Error("CredentialsAuditLogFile default is set incorrectly")
	}
}
开发者ID:instacart,项目名称:amazon-ecs-agent,代码行数:57,代码来源:config_test.go


示例4: TestConfigBoolean

func TestConfigBoolean(t *testing.T) {
	os.Setenv("ECS_DISABLE_METRICS", "true")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}
	if !cfg.DisableMetrics {
		t.Error("DisableMetrics not set to true")
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:10,代码来源:config_test.go


示例5: TestDiscoverNilTelemetryEndpoint

func TestDiscoverNilTelemetryEndpoint(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()
	client, mc, _ := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient())
	pollEndpoint := "http://127.0.0.1"
	mc.EXPECT().DiscoverPollEndpoint(gomock.Any()).Return(&ecs.DiscoverPollEndpointOutput{Endpoint: &pollEndpoint}, nil)
	_, err := client.DiscoverTelemetryEndpoint("containerInstance")
	if err == nil {
		t.Error("Expected error getting telemetry endpoint with old response")
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:11,代码来源:api_client_test.go


示例6: TestTaskIAMRoleEnabled

func TestTaskIAMRoleEnabled(t *testing.T) {
	os.Setenv("ECS_ENABLE_TASK_IAM_ROLE", "true")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	if !cfg.TaskIAMRoleEnabled {
		t.Errorf("Wrong value for TaskIAMRoleEnabled: %v", cfg.TaskIAMRoleEnabled)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:11,代码来源:config_test.go


示例7: TestCredentialsAuditLogDisabled

func TestCredentialsAuditLogDisabled(t *testing.T) {
	os.Setenv("ECS_AUDIT_LOGFILE_DISABLED", "true")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	if !cfg.CredentialsAuditLogDisabled {
		t.Errorf("Wrong value for CredentialsAuditLogDisabled: %v", cfg.CredentialsAuditLogDisabled)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:11,代码来源:config_test.go


示例8: TestImageCleanupMinimumInterval

func TestImageCleanupMinimumInterval(t *testing.T) {
	os.Setenv("ECS_IMAGE_CLEANUP_INTERVAL", "1m")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	if cfg.ImageCleanupInterval != DefaultImageCleanupTimeInterval {
		t.Errorf("Wrong value for ImageCleanupInterval: %v", cfg.ImageCleanupInterval)
	}
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:11,代码来源:config_test.go


示例9: TestImageCleanupMinimumNumImagesToDeletePerCycle

func TestImageCleanupMinimumNumImagesToDeletePerCycle(t *testing.T) {
	os.Setenv("ECS_NUM_IMAGES_DELETE_PER_CYCLE", "-1")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	if cfg.NumImagesToDeletePerCycle != DefaultNumImagesToDeletePerCycle {
		t.Errorf("Wrong value for NumImagesToDeletePerCycle: %v", cfg.NumImagesToDeletePerCycle)
	}
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:11,代码来源:config_test.go


示例10: TestTaskIAMRoleForHostNetworkEnabled

func TestTaskIAMRoleForHostNetworkEnabled(t *testing.T) {
	os.Setenv("ECS_ENABLE_TASK_IAM_ROLE_NETWORK_HOST", "true")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	if !cfg.TaskIAMRoleEnabledForNetworkHost {
		t.Errorf("Wrong value for TaskIAMRoleEnabledForNetworkHost: %v", cfg.TaskIAMRoleEnabledForNetworkHost)
	}
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:11,代码来源:config_test.go


示例11: TestCredentialsAuditLogFile

func TestCredentialsAuditLogFile(t *testing.T) {
	dummyLocation := "/foo/bar.log"
	os.Setenv("ECS_AUDIT_LOGFILE", dummyLocation)
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	if cfg.CredentialsAuditLogFile != dummyLocation {
		t.Errorf("Wrong value for CredentialsAuditLogFile: %v", cfg.CredentialsAuditLogFile)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:12,代码来源:config_test.go


示例12: TestReservedMemory

func TestReservedMemory(t *testing.T) {
	os.Setenv("ECS_RESERVED_MEMORY", "1")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	// If an invalid value is set, the config should pick up the default value for
	// reserved memory, which is 0.
	if cfg.ReservedMemory != 1 {
		t.Errorf("Wrong value for ReservedMemory. Expected %d, got %d", 1, cfg.ReservedMemory)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:13,代码来源:config_test.go


示例13: TestTaskCleanupTimeout

func TestTaskCleanupTimeout(t *testing.T) {
	os.Setenv("ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION", "10m")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	// If an invalid value is set, the config should pick up the default value for
	// cleaning up the task.
	if cfg.TaskCleanupWaitDuration != 10*time.Minute {
		t.Errorf("Task cleanup wait duration set incorrectly. Expected %v, got %v", 10*time.Minute, cfg.TaskCleanupWaitDuration)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:13,代码来源:config_test.go


示例14: TestInvalidTaskCleanupTimeout

func TestInvalidTaskCleanupTimeout(t *testing.T) {
	os.Setenv("ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION", "1s")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}

	// If an invalid value is set, the config should pick up the default value for
	// cleaning up the task.
	if cfg.TaskCleanupWaitDuration != 3*time.Hour {
		t.Error("Defualt task cleanup wait duration set incorrectly")
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:13,代码来源:config_test.go


示例15: TestSubmitContainerStateChange

func TestSubmitContainerStateChange(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()
	client, _, mockSubmitStateClient := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient())
	mockSubmitStateClient.EXPECT().SubmitContainerStateChange(&containerSubmitInputMatcher{
		ecs.SubmitContainerStateChangeInput{
			Cluster:       strptr(configuredCluster),
			Task:          strptr("arn"),
			ContainerName: strptr("cont"),
			Status:        strptr("RUNNING"),
			NetworkBindings: []*ecs.NetworkBinding{
				&ecs.NetworkBinding{
					BindIP:        strptr("1.2.3.4"),
					ContainerPort: int64ptr(intptr(1)),
					HostPort:      int64ptr(intptr(2)),
					Protocol:      strptr("tcp"),
				},
				&ecs.NetworkBinding{
					BindIP:        strptr("2.2.3.4"),
					ContainerPort: int64ptr(intptr(3)),
					HostPort:      int64ptr(intptr(4)),
					Protocol:      strptr("udp"),
				},
			},
		},
	})
	err := client.SubmitContainerStateChange(api.ContainerStateChange{
		TaskArn:       "arn",
		ContainerName: "cont",
		Status:        api.ContainerRunning,
		PortBindings: []api.PortBinding{
			api.PortBinding{
				BindIp:        "1.2.3.4",
				ContainerPort: 1,
				HostPort:      2,
			},
			api.PortBinding{
				BindIp:        "2.2.3.4",
				ContainerPort: 3,
				HostPort:      4,
				Protocol:      api.TransportProtocolUDP,
			},
		},
	})
	if err != nil {
		t.Errorf("Unable to submit container state change: %v", err)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:48,代码来源:api_client_test.go


示例16: TestDiscoverTelemetryEndpoint

func TestDiscoverTelemetryEndpoint(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()
	client, mc, _ := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient())
	expectedEndpoint := "http://127.0.0.1"
	mc.EXPECT().DiscoverPollEndpoint(gomock.Any()).Return(&ecs.DiscoverPollEndpointOutput{TelemetryEndpoint: &expectedEndpoint}, nil)
	endpoint, err := client.DiscoverTelemetryEndpoint("containerInstance")
	if err != nil {
		t.Error("Error getting telemetry endpoint: ", err)
	}
	if expectedEndpoint != endpoint {
		t.Errorf("Expected telemetry endpoint(%s) != endpoint(%s)", expectedEndpoint, endpoint)
	}
	mc.EXPECT().DiscoverPollEndpoint(gomock.Any()).Return(nil, fmt.Errorf("Error getting endpoint"))
	endpoint, err = client.DiscoverTelemetryEndpoint("containerInstance")
	if err == nil {
		t.Error("Expected error getting telemetry endpoint, didn't get any")
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:19,代码来源:api_client_test.go


示例17: TestSubmitContainerStateChangeFull

func TestSubmitContainerStateChangeFull(t *testing.T) {
	mockCtrl := gomock.NewController(t)
	defer mockCtrl.Finish()
	client, _, mockSubmitStateClient := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient())
	exitCode := 20
	reason := "I exited"

	mockSubmitStateClient.EXPECT().SubmitContainerStateChange(&containerSubmitInputMatcher{
		ecs.SubmitContainerStateChangeInput{
			Cluster:       strptr(configuredCluster),
			Task:          strptr("arn"),
			ContainerName: strptr("cont"),
			Status:        strptr("STOPPED"),
			ExitCode:      int64ptr(&exitCode),
			Reason:        strptr(reason),
			NetworkBindings: []*ecs.NetworkBinding{
				&ecs.NetworkBinding{
					BindIP:        strptr(""),
					ContainerPort: int64ptr(intptr(0)),
					HostPort:      int64ptr(intptr(0)),
					Protocol:      strptr("tcp"),
				},
			},
		},
	})
	err := client.SubmitContainerStateChange(api.ContainerStateChange{
		TaskArn:       "arn",
		ContainerName: "cont",
		Status:        api.ContainerStopped,
		ExitCode:      &exitCode,
		Reason:        reason,
		PortBindings: []api.PortBinding{
			api.PortBinding{},
		},
	})
	if err != nil {
		t.Errorf("Unable to submit container state change: %v", err)
	}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:39,代码来源:api_client_test.go


示例18: TestConfigDefault

func TestConfigDefault(t *testing.T) {
	os.Unsetenv("ECS_DISABLE_METRICS")
	os.Unsetenv("ECS_RESERVED_PORTS")
	os.Unsetenv("ECS_RESERVED_MEMORY")
	os.Unsetenv("ECS_DISABLE_PRIVILEGED")
	os.Unsetenv("ECS_AVAILABLE_LOGGING_DRIVERS")
	os.Unsetenv("ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION")
	cfg, err := NewConfig(ec2.NewBlackholeEC2MetadataClient())
	if err != nil {
		t.Fatal(err)
	}
	if cfg.DockerEndpoint != "unix:///var/run/docker.sock" {
		t.Error("Default docker endpoint set incorrectly")
	}
	if cfg.DataDir != "/data/" {
		t.Error("Default datadir set incorrectly")
	}
	if cfg.DisableMetrics {
		t.Errorf("Default disablemetrics set incorrectly: %v", cfg.DisableMetrics)
	}
	if len(cfg.ReservedPorts) != 4 {
		t.Error("Default resered ports set incorrectly")
	}
	if cfg.DockerGraphPath != "/var/lib/docker" {
		t.Error("Default docker graph path set incorrectly")
	}
	if cfg.ReservedMemory != 0 {
		t.Errorf("Default reserved memory set incorrectly: %v", cfg.ReservedMemory)
	}
	if cfg.PrivilegedDisabled {
		t.Errorf("Default PrivilegedDisabled set incorrectly: %v", cfg.PrivilegedDisabled)
	}
	if !reflect.DeepEqual(cfg.AvailableLoggingDrivers, []dockerclient.LoggingDriver{dockerclient.JsonFileDriver}) {
		t.Errorf("Default logging drivers set incorrectly: %v", cfg.AvailableLoggingDrivers)
	}
	if cfg.TaskCleanupWaitDuration != 3*time.Hour {
		t.Errorf("Defualt task cleanup wait duration set incorrectly: %v", cfg.TaskCleanupWaitDuration)
	}
}
开发者ID:xplenty,项目名称:amazon-ecs-agent,代码行数:39,代码来源:config_test.go


示例19: defaultTestConfig

func defaultTestConfig() *config.Config {
	cfg, _ := config.NewConfig(ec2.NewBlackholeEC2MetadataClient())
	return cfg
}
开发者ID:umaptechnologies,项目名称:amazon-ecs-agent,代码行数:4,代码来源:docker_container_engine_test.go


示例20: init

func init() {
	cfg, _ = config.NewConfig(ec2.NewBlackholeEC2MetadataClient())
}
开发者ID:pixeleet,项目名称:amazon-ecs-agent,代码行数:3,代码来源:engine_integ_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang engine.NewTaskEngine函数代码示例发布时间:2022-05-24
下一篇:
Golang config.NewSensitiveRawMessage函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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