本文整理匯總了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
}
示例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
}
示例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
}
示例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))
}
}
示例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)
}
}
示例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
}
示例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)
}
}
示例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
}
示例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
}
示例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
}
示例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)
}
}
示例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()
}
示例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)
}
}
示例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
}
示例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
}