当前位置: 首页>>代码示例>>Golang>>正文


Golang aws.BoolValue函数代码示例

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


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

示例1: presignURL

// presignURL will presign the request by using SoureRegion to sign with. SourceRegion is not
// sent to the service, and is only used to not have the SDKs parsing ARNs.
func presignURL(r *request.Request, sourceRegion *string, newParams interface{}) *string {
	cfg := r.Config.Copy(aws.NewConfig().
		WithEndpoint("").
		WithRegion(aws.StringValue(sourceRegion)))

	clientInfo := r.ClientInfo
	resolved, err := r.Config.EndpointResolver.EndpointFor(
		clientInfo.ServiceName, aws.StringValue(cfg.Region),
		func(opt *endpoints.Options) {
			opt.DisableSSL = aws.BoolValue(cfg.DisableSSL)
			opt.UseDualStack = aws.BoolValue(cfg.UseDualStack)
		},
	)
	if err != nil {
		r.Error = err
		return nil
	}

	clientInfo.Endpoint = resolved.URL
	clientInfo.SigningRegion = resolved.SigningRegion

	// Presign a request with modified params
	req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data)
	req.Operation.HTTPMethod = "GET"
	uri, err := req.Presign(5 * time.Minute) // 5 minutes should be enough.
	if err != nil {                          // bubble error back up to original request
		r.Error = err
		return nil
	}

	// We have our URL, set it on params
	return &uri
}
开发者ID:hashicorp,项目名称:terraform,代码行数:35,代码来源:customizations.go

示例2: clientConfigWithErr

func (s *Session) clientConfigWithErr(serviceName string, cfgs ...*aws.Config) (client.Config, error) {
	s = s.Copy(cfgs...)

	var resolved endpoints.ResolvedEndpoint
	var err error

	region := aws.StringValue(s.Config.Region)

	if endpoint := aws.StringValue(s.Config.Endpoint); len(endpoint) != 0 {
		resolved.URL = endpoints.AddScheme(endpoint, aws.BoolValue(s.Config.DisableSSL))
		resolved.SigningRegion = region
	} else {
		resolved, err = s.Config.EndpointResolver.EndpointFor(
			serviceName, region,
			func(opt *endpoints.Options) {
				opt.DisableSSL = aws.BoolValue(s.Config.DisableSSL)
				opt.UseDualStack = aws.BoolValue(s.Config.UseDualStack)
			},
		)
	}

	return client.Config{
		Config:        s.Config,
		Handlers:      s.Handlers,
		Endpoint:      resolved.URL,
		SigningRegion: resolved.SigningRegion,
		SigningName:   resolved.SigningName,
	}, err
}
开发者ID:hooklift,项目名称:terraform,代码行数:29,代码来源:session.go

示例3: launchSpecToMap

func launchSpecToMap(
	l *ec2.SpotFleetLaunchSpecification,
	rootDevName *string,
) map[string]interface{} {
	m := make(map[string]interface{})

	m["root_block_device"] = rootBlockDeviceToSet(l.BlockDeviceMappings, rootDevName)
	m["ebs_block_device"] = ebsBlockDevicesToSet(l.BlockDeviceMappings, rootDevName)
	m["ephemeral_block_device"] = ephemeralBlockDevicesToSet(l.BlockDeviceMappings)

	if l.ImageId != nil {
		m["ami"] = aws.StringValue(l.ImageId)
	}

	if l.InstanceType != nil {
		m["instance_type"] = aws.StringValue(l.InstanceType)
	}

	if l.SpotPrice != nil {
		m["spot_price"] = aws.StringValue(l.SpotPrice)
	}

	if l.EbsOptimized != nil {
		m["ebs_optimized"] = aws.BoolValue(l.EbsOptimized)
	}

	if l.Monitoring != nil && l.Monitoring.Enabled != nil {
		m["monitoring"] = aws.BoolValue(l.Monitoring.Enabled)
	}

	if l.IamInstanceProfile != nil && l.IamInstanceProfile.Name != nil {
		m["iam_instance_profile"] = aws.StringValue(l.IamInstanceProfile.Name)
	}

	if l.UserData != nil {
		ud_dec, err := base64.StdEncoding.DecodeString(aws.StringValue(l.UserData))
		if err == nil {
			m["user_data"] = string(ud_dec)
		}
	}

	if l.KeyName != nil {
		m["key_name"] = aws.StringValue(l.KeyName)
	}

	if l.Placement != nil {
		m["availability_zone"] = aws.StringValue(l.Placement.AvailabilityZone)
	}

	if l.SubnetId != nil {
		m["subnet_id"] = aws.StringValue(l.SubnetId)
	}

	if l.WeightedCapacity != nil {
		m["weighted_capacity"] = strconv.FormatFloat(*l.WeightedCapacity, 'f', 0, 64)
	}

	// m["security_groups"] = securityGroupsToSet(l.SecutiryGroups)
	return m
}
开发者ID:mhlias,项目名称:terraform,代码行数:60,代码来源:resource_aws_spot_fleet_request.go

示例4: verifyVolumeFrom

func verifyVolumeFrom(t *testing.T, output *ecs.VolumeFrom, containerName string, readOnly bool) {
	if containerName != aws.StringValue(output.SourceContainer) {
		t.Errorf("Expected SourceContainer [%s] But was [%s]", containerName, aws.StringValue(output.SourceContainer))
	}
	if readOnly != aws.BoolValue(output.ReadOnly) {
		t.Errorf("Expected ReadOnly [%t] But was [%t]", readOnly, aws.BoolValue(output.ReadOnly))
	}
}
开发者ID:uttarasridhar,项目名称:amazon-ecs-cli,代码行数:8,代码来源:convert_task_definition_test.go

示例5: TestAddWithUsePreviousValueAndValidate

func TestAddWithUsePreviousValueAndValidate(t *testing.T) {
	cfnParams := NewCfnStackParamsForUpdate()
	err := cfnParams.Validate()
	if err != nil {
		t.Error("Error validating params for update: ", err)
	}

	params := cfnParams.Get()
	if 0 == len(params) {
		t.Error("Got empty params list")
	}

	for _, param := range params {
		usePrevious := param.UsePreviousValue
		paramName := aws.StringValue(param.ParameterKey)
		if usePrevious == nil {
			t.Fatalf("usePrevious is not set for '%s' in params map", paramName)
		}

		if !aws.BoolValue(usePrevious) {
			t.Errorf("usePrevious value for '%s' is false, expected to be true", paramName)
		}
	}

	err = cfnParams.AddWithUsePreviousValue(ParameterKeyAsgMaxSize, false)
	if err != nil {
		t.Errorf("Error adding parameter with use previous value '%s': '%v'", ParameterKeyAsgMaxSize, err)
	}
	err = cfnParams.Validate()
	if err == nil {
		t.Errorf("Expected error for param '%s' when usePrevious is false and value is not set", ParameterKeyAsgMaxSize)
	}

	size := "3"
	err = cfnParams.Add(ParameterKeyAsgMaxSize, size)
	if err != nil {
		t.Errorf("Error adding parameter '%s': %v", ParameterKeyAsgMaxSize, err)
	}

	param, err := cfnParams.GetParameter(ParameterKeyAsgMaxSize)
	if err != nil {
		t.Errorf("Error getting parameter '%s': %v", ParameterKeyAsgMaxSize, err)
	}
	usePrevious := param.UsePreviousValue
	if usePrevious == nil {
		t.Fatalf("usePrevious is not set for '%s' in params map", ParameterKeyAsgMaxSize)
	}

	if aws.BoolValue(usePrevious) {
		t.Errorf("usePrevious value is true for '%s', expected false", ParameterKeyAsgMaxSize)
	}

}
开发者ID:uttarasridhar,项目名称:amazon-ecs-cli,代码行数:53,代码来源:params_test.go

示例6: Marshal

// Marshal parses the response from the aws sdk into an awsm Subnet
func (s *Subnet) Marshal(subnet *ec2.Subnet, region string, vpcList *Vpcs) {
	s.Name = GetTagValue("Name", subnet.Tags)
	s.Class = GetTagValue("Class", subnet.Tags)
	s.SubnetID = aws.StringValue(subnet.SubnetId)
	s.VpcID = aws.StringValue(subnet.VpcId)
	s.VpcName = vpcList.GetVpcName(s.VpcID)
	s.State = aws.StringValue(subnet.State)
	s.AvailabilityZone = aws.StringValue(subnet.AvailabilityZone)
	s.Default = aws.BoolValue(subnet.DefaultForAz)
	s.CIDRBlock = aws.StringValue(subnet.CidrBlock)
	s.AvailableIPs = int(aws.Int64Value(subnet.AvailableIpAddressCount))
	s.MapPublicIP = aws.BoolValue(subnet.MapPublicIpOnLaunch)
	s.Region = region
}
开发者ID:murdinc,项目名称:awsm,代码行数:15,代码来源:subnets.go

示例7: updateEndpointForS3Config

// Request handler to automatically add the bucket name to the endpoint domain
// if possible. This style of bucket is valid for all bucket names which are
// DNS compatible and do not contain "."
func updateEndpointForS3Config(r *request.Request) {
	forceHostStyle := aws.BoolValue(r.Config.S3ForcePathStyle)
	accelerate := aws.BoolValue(r.Config.S3UseAccelerate)

	if accelerate && accelerateOpBlacklist.Continue(r) {
		if forceHostStyle {
			if r.Config.Logger != nil {
				r.Config.Logger.Log("ERROR: aws.Config.S3UseAccelerate is not compatible with aws.Config.S3ForcePathStyle, ignoring S3ForcePathStyle.")
			}
		}
		updateEndpointForAccelerate(r)
	} else if !forceHostStyle && r.Operation.Name != opGetBucketLocation {
		updateEndpointForHostStyle(r)
	}
}
开发者ID:ColourboxDevelopment,项目名称:aws-sdk-go,代码行数:18,代码来源:host_style_bucket.go

示例8: fillPresignedURL

func fillPresignedURL(r *request.Request) {
	if !r.ParamsFilled() {
		return
	}

	origParams := r.Params.(*CopySnapshotInput)

	// Stop if PresignedURL/DestinationRegion is set
	if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil {
		return
	}

	origParams.DestinationRegion = r.Config.Region
	newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput)

	// Create a new request based on the existing request. We will use this to
	// presign the CopySnapshot request against the source region.
	cfg := r.Config.Copy(aws.NewConfig().
		WithEndpoint("").
		WithRegion(aws.StringValue(origParams.SourceRegion)))

	clientInfo := r.ClientInfo
	resolved, err := r.Config.EndpointResolver.EndpointFor(
		clientInfo.ServiceName, aws.StringValue(cfg.Region),
		func(opt *endpoints.Options) {
			opt.DisableSSL = aws.BoolValue(cfg.DisableSSL)
			opt.UseDualStack = aws.BoolValue(cfg.UseDualStack)
		},
	)
	if err != nil {
		r.Error = err
		return
	}

	clientInfo.Endpoint = resolved.URL
	clientInfo.SigningRegion = resolved.SigningRegion

	// Presign a CopySnapshot request with modified params
	req := request.New(*cfg, clientInfo, r.Handlers, r.Retryer, r.Operation, newParams, r.Data)
	url, err := req.Presign(5 * time.Minute) // 5 minutes should be enough.
	if err != nil {                          // bubble error back up to original request
		r.Error = err
		return
	}

	// We have our URL, set it on params
	origParams.PresignedUrl = &url
}
开发者ID:hooklift,项目名称:terraform,代码行数:48,代码来源:customizations.go

示例9: 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

示例10: nextPageTokens

// nextPageTokens returns the tokens to use when asking for the next page of
// data.
func (r *Request) nextPageTokens() []interface{} {
	if r.Operation.Paginator == nil {
		return nil
	}

	if r.Operation.TruncationToken != "" {
		tr, _ := awsutil.ValuesAtPath(r.Data, r.Operation.TruncationToken)
		if len(tr) == 0 {
			return nil
		}

		switch v := tr[0].(type) {
		case *bool:
			if !aws.BoolValue(v) {
				return nil
			}
		case bool:
			if v == false {
				return nil
			}
		}
	}

	tokens := []interface{}{}
	for _, outToken := range r.Operation.OutputTokens {
		v, _ := awsutil.ValuesAtPath(r.Data, outToken)
		if len(v) > 0 {
			tokens = append(tokens, v[0])
		}
	}

	return tokens
}
开发者ID:toni-moreno,项目名称:grafana,代码行数:35,代码来源:request_pagination.go

示例11: Initialize

// Initialize initializes the service.
func (s *Service) Initialize() {
	if s.Config == nil {
		s.Config = &aws.Config{}
	}
	if s.Config.HTTPClient == nil {
		s.Config.HTTPClient = http.DefaultClient
	}

	if s.RetryRules == nil {
		s.RetryRules = retryRules
	}

	if s.ShouldRetry == nil {
		s.ShouldRetry = shouldRetry
	}

	s.DefaultMaxRetries = 3
	s.Handlers.Validate.PushBack(ValidateEndpointHandler)
	s.Handlers.Build.PushBack(UserAgentHandler)
	s.Handlers.Sign.PushBack(BuildContentLength)
	s.Handlers.Send.PushBack(SendHandler)
	s.Handlers.AfterRetry.PushBack(AfterRetryHandler)
	s.Handlers.ValidateResponse.PushBack(ValidateResponseHandler)
	s.AddDebugHandlers()
	s.buildEndpoint()

	if !aws.BoolValue(s.Config.DisableParamValidation) {
		s.Handlers.Validate.PushBack(ValidateParameters)
	}
}
开发者ID:jkakar,项目名称:aws-sdk-go,代码行数:31,代码来源:service.go

示例12: Initialize

// Initialize initializes the service.
func (s *Service) Initialize() {
	if s.Config == nil {
		s.Config = &aws.Config{}
	}
	if s.Config.HTTPClient == nil {
		s.Config.HTTPClient = http.DefaultClient
	}
	if s.Config.SleepDelay == nil {
		s.Config.SleepDelay = time.Sleep
	}

	s.Retryer = DefaultRetryer{s}
	s.DefaultMaxRetries = 3
	s.Handlers.Validate.PushBackNamed(corehandlers.ValidateEndpointHandler)
	s.Handlers.Build.PushBackNamed(corehandlers.UserAgentHandler)
	s.Handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler)
	s.Handlers.Send.PushBackNamed(corehandlers.SendHandler)
	s.Handlers.AfterRetry.PushBackNamed(corehandlers.AfterRetryHandler)
	s.Handlers.ValidateResponse.PushBackNamed(corehandlers.ValidateResponseHandler)
	if !aws.BoolValue(s.Config.DisableParamValidation) {
		s.Handlers.Validate.PushBackNamed(corehandlers.ValidateParametersHandler)
	}
	s.AddDebugHandlers()
	s.buildEndpoint()
}
开发者ID:erinboyd,项目名称:origin,代码行数:26,代码来源:service.go

示例13: initHandlers

func initHandlers(s *Session) {
	// Add the Validate parameter handler if it is not disabled.
	s.Handlers.Validate.Remove(corehandlers.ValidateParametersHandler)
	if !aws.BoolValue(s.Config.DisableParamValidation) {
		s.Handlers.Validate.PushBackNamed(corehandlers.ValidateParametersHandler)
	}
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:7,代码来源:session.go

示例14: 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

示例15: resourceAwsSpotFleetRequestUpdate

func resourceAwsSpotFleetRequestUpdate(d *schema.ResourceData, meta interface{}) error {
	// http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifySpotFleetRequest.html
	conn := meta.(*AWSClient).ec2conn

	d.Partial(true)

	req := &ec2.ModifySpotFleetRequestInput{
		SpotFleetRequestId: aws.String(d.Id()),
	}

	if val, ok := d.GetOk("target_capacity"); ok {
		req.TargetCapacity = aws.Int64(int64(val.(int)))
	}

	if val, ok := d.GetOk("excess_capacity_termination_policy"); ok {
		req.ExcessCapacityTerminationPolicy = aws.String(val.(string))
	}

	resp, err := conn.ModifySpotFleetRequest(req)
	if err == nil && aws.BoolValue(resp.Return) {
		// TODO: rollback to old values?
	}

	return nil
}
开发者ID:mhlias,项目名称:terraform,代码行数:25,代码来源:resource_aws_spot_fleet_request.go


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