當前位置: 首頁>>代碼示例>>Golang>>正文


Golang aws.Int64Value函數代碼示例

本文整理匯總了Golang中github.com/aws/aws-sdk-go/aws.Int64Value函數的典型用法代碼示例。如果您正苦於以下問題:Golang Int64Value函數的具體用法?Golang Int64Value怎麽用?Golang Int64Value使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Int64Value函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestRunTask

func TestRunTask(t *testing.T) {
	mockEcs, _, client, ctrl := setupTestController(t, nil)
	defer ctrl.Finish()

	clusterName := "clusterName"
	td := "taskDef"
	startedBy := "startedBy"
	count := 5
	client.(*ecsClient).params = &config.CliParams{
		Cluster: clusterName,
	}

	mockEcs.EXPECT().RunTask(gomock.Any()).Do(func(input interface{}) {
		req := input.(*ecs.RunTaskInput)
		if clusterName != aws.StringValue(req.Cluster) {
			t.Errorf("clusterName should be [%s]. Got [%s]", clusterName, aws.StringValue(req.Cluster))
		}
		if td != aws.StringValue(req.TaskDefinition) {
			t.Errorf("taskDefinition should be [%s]. Got [%s]", td, aws.StringValue(req.TaskDefinition))
		}
		if startedBy != aws.StringValue(req.StartedBy) {
			t.Errorf("startedBy should be [%s]. Got [%s]", startedBy, aws.StringValue(req.StartedBy))
		}
		if int64(count) != aws.Int64Value(req.Count) {
			t.Errorf("count should be [%s]. Got [%s]", count, aws.Int64Value(req.Count))
		}
	}).Return(&ecs.RunTaskOutput{}, nil)

	_, err := client.RunTask(td, startedBy, count)
	if err != nil {
		t.Fatal(err)
	}
}
開發者ID:uttarasridhar,項目名稱:amazon-ecs-cli,代碼行數:33,代碼來源:client_test.go

示例2: waitForServiceTasks

// waitForServiceTasks continuously polls ECS (by calling describeService) and waits for service to get stable
// with desiredCount == runningCount
func waitForServiceTasks(service *Service, ecsServiceName string) error {
	timeoutMessage := fmt.Sprintf("Timeout waiting for service %s to get stable", ecsServiceName)

	return waitUntilComplete(func(retryCount int) (bool, error) {

		ecsService, err := service.describeService()
		if err != nil {
			return false, err
		}

		desiredCount := aws.Int64Value(ecsService.DesiredCount)
		runningCount := aws.Int64Value(ecsService.RunningCount)

		logFields := log.Fields{
			"serviceName":  ecsServiceName,
			"desiredCount": desiredCount,
			"runningCount": runningCount,
		}
		if len(ecsService.Deployments) == 1 && desiredCount == runningCount {
			log.WithFields(logFields).Info("ECS Service has reached a stable state")
			return true, nil
		}

		if retryCount%2 == 0 {
			log.WithFields(logFields).Info("Describe ECS Service status")
		} else {
			log.WithFields(logFields).Debug("Describe ECS Service status")
		}
		return false, nil
	}, service, timeoutMessage, true)
}
開發者ID:jloper3,項目名稱:amazon-ecs-cli,代碼行數:33,代碼來源:waiters.go

示例3: UpdateService

func (client *ecsClient) UpdateService(serviceName, taskDefinition string, count int64, deploymentConfig *ecs.DeploymentConfiguration) error {
	input := &ecs.UpdateServiceInput{
		DesiredCount:            aws.Int64(count),
		Service:                 aws.String(serviceName),
		Cluster:                 aws.String(client.params.Cluster),
		DeploymentConfiguration: deploymentConfig,
	}
	if taskDefinition != "" {
		input.TaskDefinition = aws.String(taskDefinition)
	}
	_, err := client.client.UpdateService(input)
	if err != nil {
		log.WithFields(log.Fields{
			"service": serviceName,
			"error":   err,
		}).Error("Error updating service")
		return err
	}
	fields := log.Fields{
		"service": serviceName,
		"count":   count,
	}
	if taskDefinition != "" {
		fields["taskDefinition"] = taskDefinition
	}
	if deploymentConfig != nil && deploymentConfig.MaximumPercent != nil {
		fields["deployment-max-percent"] = aws.Int64Value(deploymentConfig.MaximumPercent)
	}
	if deploymentConfig != nil && deploymentConfig.MinimumHealthyPercent != nil {
		fields["deployment-min-healthy-percent"] = aws.Int64Value(deploymentConfig.MinimumHealthyPercent)
	}
	log.WithFields(fields).Debug("Updated ECS service")
	return nil
}
開發者ID:yinshiua,項目名稱:amazon-ecs-cli,代碼行數:34,代碼來源:client.go

示例4: buildDBInstance

func (r *RDSDBInstance) buildDBInstance(dbInstance *rds.DBInstance) DBInstanceDetails {
	dbInstanceDetails := DBInstanceDetails{
		Identifier:       aws.StringValue(dbInstance.DBInstanceIdentifier),
		Status:           aws.StringValue(dbInstance.DBInstanceStatus),
		Engine:           aws.StringValue(dbInstance.Engine),
		EngineVersion:    aws.StringValue(dbInstance.EngineVersion),
		DBName:           aws.StringValue(dbInstance.DBName),
		MasterUsername:   aws.StringValue(dbInstance.MasterUsername),
		AllocatedStorage: aws.Int64Value(dbInstance.AllocatedStorage),
	}

	if dbInstance.Endpoint != nil {
		dbInstanceDetails.Address = aws.StringValue(dbInstance.Endpoint.Address)
		dbInstanceDetails.Port = aws.Int64Value(dbInstance.Endpoint.Port)
	}

	if dbInstance.PendingModifiedValues != nil {
		emptyPendingModifiedValues := &rds.PendingModifiedValues{}
		if *dbInstance.PendingModifiedValues != *emptyPendingModifiedValues {
			dbInstanceDetails.PendingModifications = true
		}
	}

	return dbInstanceDetails
}
開發者ID:x6j8x,項目名稱:rds-broker,代碼行數:25,代碼來源:rds_db_instance.go

示例5: rootBlockDeviceToSet

func rootBlockDeviceToSet(
	bdm []*ec2.BlockDeviceMapping,
	rootDevName *string,
) *schema.Set {
	set := &schema.Set{F: hashRootBlockDevice}

	if rootDevName != nil {
		for _, val := range bdm {
			if aws.StringValue(val.DeviceName) == aws.StringValue(rootDevName) {
				m := make(map[string]interface{})
				if val.Ebs.DeleteOnTermination != nil {
					m["delete_on_termination"] = aws.BoolValue(val.Ebs.DeleteOnTermination)
				}

				if val.Ebs.VolumeSize != nil {
					m["volume_size"] = aws.Int64Value(val.Ebs.VolumeSize)
				}

				if val.Ebs.VolumeType != nil {
					m["volume_type"] = aws.StringValue(val.Ebs.VolumeType)
				}

				if val.Ebs.Iops != nil {
					m["iops"] = aws.Int64Value(val.Ebs.Iops)
				}

				set.Add(m)
			}
		}
	}

	return set
}
開發者ID:mhlias,項目名稱:terraform,代碼行數:33,代碼來源:resource_aws_spot_fleet_request.go

示例6: CreateService

func (client *ecsClient) CreateService(serviceName, taskDefName string, deploymentConfig *ecs.DeploymentConfiguration) error {
	_, err := client.client.CreateService(&ecs.CreateServiceInput{
		DesiredCount:            aws.Int64(0),            // Required
		ServiceName:             aws.String(serviceName), // Required
		TaskDefinition:          aws.String(taskDefName), // Required
		Cluster:                 aws.String(client.params.Cluster),
		DeploymentConfiguration: deploymentConfig,
	})
	if err != nil {
		log.WithFields(log.Fields{
			"service": serviceName,
			"error":   err,
		}).Error("Error creating service")
		return err
	}

	fields := log.Fields{
		"service":        serviceName,
		"taskDefinition": taskDefName,
	}
	if deploymentConfig != nil && deploymentConfig.MaximumPercent != nil {
		fields["deployment-max-percent"] = aws.Int64Value(deploymentConfig.MaximumPercent)
	}
	if deploymentConfig != nil && deploymentConfig.MinimumHealthyPercent != nil {
		fields["deployment-min-healthy-percent"] = aws.Int64Value(deploymentConfig.MinimumHealthyPercent)
	}

	log.WithFields(fields).Info("Created an ECS service")
	return nil
}
開發者ID:yinshiua,項目名稱:amazon-ecs-cli,代碼行數:30,代碼來源:client.go

示例7: TestLoadContext

func TestLoadContext(t *testing.T) {
	deploymentMaxPercent := 150

	flagSet := flag.NewFlagSet("ecs-cli-up", 0)
	flagSet.String(DeploymentMaxPercentFlag, strconv.Itoa(deploymentMaxPercent), "")
	cliContext := cli.NewContext(nil, flagSet, nil)
	service := &Service{
		projectContext: &Context{CLIContext: cliContext},
	}

	if err := service.LoadContext(); err != nil {
		t.Fatal("Unexpected error while loading context in load context test")
	}

	observedDeploymentConfig := service.DeploymentConfig()
	if aws.Int64Value(observedDeploymentConfig.MaximumPercent) != int64(deploymentMaxPercent) {
		t.Errorf("Expected DeploymentConfig.MaxPercent to be [%s] but got [%s]",
			deploymentMaxPercent, aws.Int64Value(observedDeploymentConfig.MaximumPercent))
	}
	if observedDeploymentConfig.MinimumHealthyPercent != nil {
		t.Errorf("Expected DeploymentConfig.MinimumHealthyPercent to be nil but got [%s]",
			aws.Int64Value(observedDeploymentConfig.MinimumHealthyPercent))
	}

}
開發者ID:uttarasridhar,項目名稱:amazon-ecs-cli,代碼行數:25,代碼來源:service_test.go

示例8: Marshal

// Marshal parses the response from the aws sdk into an awsm ScalingPolicy
func (s *ScalingPolicy) Marshal(policy *autoscaling.ScalingPolicy, region string) {
	adjustment := int(aws.Int64Value(policy.ScalingAdjustment))
	adjustmentStr := fmt.Sprint(adjustment)
	if adjustment >= 1 {
		adjustmentStr = fmt.Sprintf("+%d", adjustment)
	}

	var alarmArns []string
	var alarmNames []string

	for _, alarm := range policy.Alarms {
		arnStr := aws.StringValue(alarm.AlarmARN)
		alarmArns = append(alarmArns, arnStr)

		arn, err := ParseArn(arnStr)
		if err == nil {
			alarmNames = append(alarmNames, arn.Resource)
		} else {
			alarmNames = append(alarmNames, "?????")
		}
	}

	s.Name = aws.StringValue(policy.PolicyName)
	s.Arn = aws.StringValue(policy.PolicyARN)
	s.AdjustmentType = aws.StringValue(policy.AdjustmentType)
	s.Adjustment = adjustment
	s.AdjustmentStr = adjustmentStr
	s.Cooldown = fmt.Sprint(aws.Int64Value(policy.Cooldown))
	s.AutoScaleGroupName = aws.StringValue(policy.AutoScalingGroupName)
	s.AlarmArns = alarmArns
	s.AlarmNames = strings.Join(alarmNames, ", ")

	s.Region = region
}
開發者ID:murdinc,項目名稱:awsm,代碼行數:35,代碼來源:scalingpolicies.go

示例9: Find

func (e *LoadBalancer) Find(c *fi.Context) (*LoadBalancer, error) {
	cloud := c.Cloud.(*awsup.AWSCloud)

	elbName := fi.StringValue(e.ID)
	if elbName == "" {
		elbName = fi.StringValue(e.Name)
	}

	lb, err := findELB(cloud, elbName)
	if err != nil {
		return nil, err
	}
	if lb == nil {
		return nil, nil
	}

	actual := &LoadBalancer{}
	actual.Name = e.Name
	actual.ID = lb.LoadBalancerName
	actual.DNSName = lb.DNSName
	actual.HostedZoneId = lb.CanonicalHostedZoneNameID
	for _, subnet := range lb.Subnets {
		actual.Subnets = append(actual.Subnets, &Subnet{ID: subnet})
	}

	for _, sg := range lb.SecurityGroups {
		actual.SecurityGroups = append(actual.SecurityGroups, &SecurityGroup{ID: sg})
	}

	actual.Listeners = make(map[string]*LoadBalancerListener)

	for _, ld := range lb.ListenerDescriptions {
		l := ld.Listener
		loadBalancerPort := strconv.FormatInt(aws.Int64Value(l.LoadBalancerPort), 10)

		actualListener := &LoadBalancerListener{}
		actualListener.InstancePort = int(aws.Int64Value(l.InstancePort))
		actual.Listeners[loadBalancerPort] = actualListener
	}

	// Avoid spurious mismatches
	if subnetSlicesEqualIgnoreOrder(actual.Subnets, e.Subnets) {
		actual.Subnets = e.Subnets
	}
	if e.DNSName == nil {
		e.DNSName = actual.DNSName
	}
	if e.HostedZoneId == nil {
		e.HostedZoneId = actual.HostedZoneId
	}
	if e.ID == nil {
		e.ID = actual.ID
	}

	return actual, nil
}
開發者ID:crohling,項目名稱:kops,代碼行數:56,代碼來源:load_balancer.go

示例10: Marshal

// Marshal parses the response from the aws sdk into an awsm Alarm
func (a *Alarm) Marshal(alarm *cloudwatch.MetricAlarm, region string) {
	var dimensions []string
	var operator string

	for _, dim := range alarm.Dimensions {
		dimensions = append(dimensions, aws.StringValue(dim.Name)+" = "+aws.StringValue(dim.Value))
	}

	switch aws.StringValue(alarm.ComparisonOperator) {
	case "GreaterThanThreshold":
		operator = ">"

	case "GreaterThanOrEqualToThreshold":
		operator = ">="

	case "LessThanThreshold":
		operator = "<"

	case "LessThanOrEqualToThreshold":
		operator = "<="
	}

	var actionArns []string
	var actionNames []string

	for _, action := range alarm.AlarmActions {
		arnStr := aws.StringValue(action)
		actionArns = append(actionArns, arnStr)

		arn, err := ParseArn(arnStr)
		if err == nil {
			actionNames = append(actionNames, arn.PolicyName)
		} else {
			actionNames = append(actionNames, "??????")
		}
	}

	a.Name = aws.StringValue(alarm.AlarmName)
	a.Arn = aws.StringValue(alarm.AlarmArn)
	a.Description = aws.StringValue(alarm.AlarmDescription)
	a.State = aws.StringValue(alarm.StateValue)
	a.Trigger = fmt.Sprintf("%s %s %d (%s)", aws.StringValue(alarm.MetricName), operator, int(aws.Float64Value(alarm.Threshold)), aws.StringValue(alarm.Statistic))
	a.Period = fmt.Sprint(aws.Int64Value(alarm.Period))
	a.EvalPeriods = fmt.Sprint(aws.Int64Value(alarm.EvaluationPeriods))
	a.ActionArns = actionArns
	a.ActionNames = strings.Join(actionNames, ", ")
	a.Dimensions = strings.Join(dimensions, ", ")
	a.Namespace = aws.StringValue(alarm.Namespace)
	a.Region = region
}
開發者ID:murdinc,項目名稱:awsm,代碼行數:51,代碼來源:alarms.go

示例11: buildDBCluster

func (r *RDSDBCluster) buildDBCluster(dbCluster *rds.DBCluster) DBClusterDetails {
	dbClusterDetails := DBClusterDetails{
		Identifier:       aws.StringValue(dbCluster.DBClusterIdentifier),
		Status:           aws.StringValue(dbCluster.Status),
		Engine:           aws.StringValue(dbCluster.Engine),
		EngineVersion:    aws.StringValue(dbCluster.EngineVersion),
		DatabaseName:     aws.StringValue(dbCluster.DatabaseName),
		MasterUsername:   aws.StringValue(dbCluster.MasterUsername),
		AllocatedStorage: aws.Int64Value(dbCluster.AllocatedStorage),
		Endpoint:         aws.StringValue(dbCluster.Endpoint),
		Port:             aws.Int64Value(dbCluster.Port),
	}

	return dbClusterDetails
}
開發者ID:x6j8x,項目名稱:rds-broker,代碼行數:15,代碼來源:rds_db_cluster.go

示例12: buildStackDetails

func (s *CloudFormationStack) buildStackDetails(stack *cloudformation.Stack) StackDetails {
	stackDetails := StackDetails{
		StackName:        aws.StringValue(stack.StackName),
		Capabilities:     aws.StringValueSlice(stack.Capabilities),
		DisableRollback:  aws.BoolValue(stack.DisableRollback),
		Description:      aws.StringValue(stack.Description),
		NotificationARNs: aws.StringValueSlice(stack.NotificationARNs),
		StackID:          aws.StringValue(stack.StackId),
		StackStatus:      s.stackStatus(aws.StringValue(stack.StackStatus)),
		TimeoutInMinutes: aws.Int64Value(stack.TimeoutInMinutes),
	}

	if stack.Parameters != nil && len(stack.Parameters) > 0 {
		stackDetails.Parameters = make(map[string]string)
		for _, parameter := range stack.Parameters {
			stackDetails.Parameters[aws.StringValue(parameter.ParameterKey)] = aws.StringValue(parameter.ParameterValue)
		}
	}

	if stack.Outputs != nil && len(stack.Outputs) > 0 {
		stackDetails.Outputs = make(map[string]string)
		for _, output := range stack.Outputs {
			stackDetails.Outputs[aws.StringValue(output.OutputKey)] = aws.StringValue(output.OutputValue)
		}
	}

	return stackDetails
}
開發者ID:cf-platform-eng,項目名稱:cloudformation-broker,代碼行數:28,代碼來源:cf_stack.go

示例13: SizeFromVolumeId

// Size returns the given volume ids size. Returns 0 if the size is not
// available
func (v Volumes) SizeFromVolumeId(id string) int {
	vol, ok := v[id]
	if !ok {
		return 0
	}
	return int(aws.Int64Value(vol.Size))
}
開發者ID:koding,項目名稱:koding,代碼行數:9,代碼來源:volumes.go

示例14: Down

// Down stops any running containers(tasks) by calling Stop() and deletes an active ECS Service
// NoOp if the service is inactive
func (s *Service) Down() error {
	// describe the service
	ecsService, err := s.describeService()
	if err != nil {
		return err
	}

	ecsServiceName := aws.StringValue(ecsService.ServiceName)
	// if already deleted, NoOp
	if aws.StringValue(ecsService.Status) != ecsActiveResourceCode {
		log.WithFields(log.Fields{
			"serviceName": ecsServiceName,
		}).Info("ECS Service is already deleted")
		return nil
	}

	// stop any running tasks
	if aws.Int64Value(ecsService.DesiredCount) != 0 {
		if err = s.Stop(); err != nil {
			return err
		}
	}

	// deleteService
	if err = s.Context().ECSClient.DeleteService(ecsServiceName); err != nil {
		return err
	}
	return waitForServiceTasks(s, ecsServiceName)
}
開發者ID:jloper3,項目名稱:amazon-ecs-cli,代碼行數:31,代碼來源:service.go

示例15: CheckDataAndGetSize

func (s3 *s3driver) CheckDataAndGetSize(dpconn, itemlocation, fileName string) (exist bool, size int64, err error) {
	bucket := getAwsInfoFromDpconn(dpconn)

	destFullPathFileName := bucket + "/" + itemlocation + "/" + fileName
	log.Info(destFullPathFileName)

	AWS_REGION = Env("AWS_REGION", false)

	svc := s3aws.New(session.New(&aws.Config{Region: aws.String(AWS_REGION)}))
	result, err := svc.ListObjects(&s3aws.ListObjectsInput{Bucket: aws.String(bucket),
		Prefix: aws.String(itemlocation + "/" + fileName)})
	if err != nil {
		log.Error("Failed to list objects", err)
		return exist, size, err
	}

	exist = false
	for _, v := range result.Contents {
		log.Infof("Tag:%s, key:%s, size:%v\n", aws.StringValue(v.ETag), aws.StringValue(v.Key), aws.Int64Value(v.Size))
		if aws.StringValue(v.Key) == fileName {
			size = aws.Int64Value(v.Size)
			exist = true
		}
	}

	return
}
開發者ID:asiainfoLDP,項目名稱:datahub,代碼行數:27,代碼來源:s3driver.go


注:本文中的github.com/aws/aws-sdk-go/aws.Int64Value函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。