本文整理汇总了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)
}
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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))
}
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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))
}
示例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)
}
示例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
}