Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit e9b1d14

Browse files
aiordacheaiordache
authored andcommitted
Pointers value access fixes
Signed-off-by: aiordache <[email protected]> (cherry picked from commit 65d6fe57546b4f7a58ecf878d8740155285bc19a)
1 parent 31703ac commit e9b1d14

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

pkg/amazon/sdk/sdk.go

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (s sdk) ListStackParameters(ctx context.Context, name string) (map[string]s
301301
}
302302
parameters := map[string]string{}
303303
for _, parameter := range st.Stacks[0].Parameters {
304-
parameters[*parameter.ParameterKey] = *parameter.ParameterValue
304+
parameters[aws.StringValue(parameter.ParameterKey)] = aws.StringValue(parameter.ParameterValue)
305305
}
306306
return parameters, nil
307307
}
@@ -318,10 +318,10 @@ func (s sdk) ListStackResources(ctx context.Context, name string) ([]compose.Sta
318318
resources := []compose.StackResource{}
319319
for _, r := range res.StackResourceSummaries {
320320
resources = append(resources, compose.StackResource{
321-
LogicalID: *r.LogicalResourceId,
322-
Type: *r.ResourceType,
323-
ARN: *r.PhysicalResourceId,
324-
Status: *r.ResourceStatus,
321+
LogicalID: aws.StringValue(r.LogicalResourceId),
322+
Type: aws.StringValue(r.ResourceType),
323+
ARN: aws.StringValue(r.PhysicalResourceId),
324+
Status: aws.StringValue(r.ResourceStatus),
325325
})
326326
}
327327
return resources, nil
@@ -350,7 +350,7 @@ func (s sdk) CreateSecret(ctx context.Context, secret compose.Secret) (string, e
350350
if err != nil {
351351
return "", err
352352
}
353-
return *response.ARN, nil
353+
return aws.StringValue(response.ARN), nil
354354
}
355355

356356
func (s sdk) InspectSecret(ctx context.Context, id string) (compose.Secret, error) {
@@ -361,11 +361,11 @@ func (s sdk) InspectSecret(ctx context.Context, id string) (compose.Secret, erro
361361
}
362362
labels := map[string]string{}
363363
for _, tag := range response.Tags {
364-
labels[*tag.Key] = *tag.Value
364+
labels[aws.StringValue(tag.Key)] = aws.StringValue(tag.Value)
365365
}
366366
secret := compose.Secret{
367-
ID: *response.ARN,
368-
Name: *response.Name,
367+
ID: aws.StringValue(response.ARN),
368+
Name: aws.StringValue(response.Name),
369369
Labels: labels,
370370
}
371371
if response.Description != nil {
@@ -431,8 +431,8 @@ func (s sdk) GetLogs(ctx context.Context, name string, consumer compose.LogConsu
431431
}
432432

433433
for _, event := range events.Events {
434-
p := strings.Split(*event.LogStreamName, "/")
435-
consumer.Log(p[1], p[2], *event.Message)
434+
p := strings.Split(aws.StringValue(event.LogStreamName), "/")
435+
consumer.Log(p[1], p[2], aws.StringValue(event.Message))
436436
startTime = *event.IngestionTime
437437
}
438438
}
@@ -455,7 +455,7 @@ func (s sdk) DescribeServices(ctx context.Context, cluster string, arns []string
455455
var name string
456456
for _, t := range service.Tags {
457457
if *t.Key == compose.ServiceTag {
458-
name = *t.Value
458+
name = aws.StringValue(t.Value)
459459
}
460460
}
461461
if name == "" {
@@ -472,10 +472,10 @@ func (s sdk) DescribeServices(ctx context.Context, cluster string, arns []string
472472
return nil, err
473473
}
474474
status = append(status, compose.ServiceStatus{
475-
ID: *service.ServiceName,
475+
ID: aws.StringValue(service.ServiceName),
476476
Name: name,
477-
Replicas: int(*service.RunningCount),
478-
Desired: int(*service.DesiredCount),
477+
Replicas: int(aws.Int64Value(service.RunningCount)),
478+
Desired: int(aws.Int64Value(service.DesiredCount)),
479479
LoadBalancers: loadBalancers,
480480
})
481481
}
@@ -505,8 +505,12 @@ func (s sdk) getURLWithPortMapping(ctx context.Context, targetGroupArns []string
505505
return nil, err
506506
}
507507
filterLB := func(arn *string, lbs []*elbv2.LoadBalancer) *elbv2.LoadBalancer {
508+
if aws.StringValue(arn) == "" {
509+
// load balancer arn is nil/""
510+
return nil
511+
}
508512
for _, lb := range lbs {
509-
if *lb.LoadBalancerArn == *arn {
513+
if aws.StringValue(lb.LoadBalancerArn) == aws.StringValue(arn) {
510514
return lb
511515
}
512516
}
@@ -520,10 +524,10 @@ func (s sdk) getURLWithPortMapping(ctx context.Context, targetGroupArns []string
520524
continue
521525
}
522526
loadBalancers = append(loadBalancers, compose.LoadBalancer{
523-
URL: *lb.DNSName,
524-
TargetPort: int(*tg.Port),
525-
PublishedPort: int(*tg.Port),
526-
Protocol: *tg.Protocol,
527+
URL: aws.StringValue(lb.DNSName),
528+
TargetPort: int(aws.Int64Value(tg.Port)),
529+
PublishedPort: int(aws.Int64Value(tg.Port)),
530+
Protocol: aws.StringValue(tg.Protocol),
527531
})
528532

529533
}
@@ -556,7 +560,7 @@ func (s sdk) GetPublicIPs(ctx context.Context, interfaces ...string) (map[string
556560
publicIPs := map[string]string{}
557561
for _, interf := range desc.NetworkInterfaces {
558562
if interf.Association != nil {
559-
publicIPs[*interf.NetworkInterfaceId] = *interf.Association.PublicIp
563+
publicIPs[aws.StringValue(interf.NetworkInterfaceId)] = aws.StringValue(interf.Association.PublicIp)
560564
}
561565
}
562566
return publicIPs, nil
@@ -581,5 +585,9 @@ func (s sdk) GetLoadBalancerURL(ctx context.Context, arn string) (string, error)
581585
if err != nil {
582586
return "", err
583587
}
584-
return *lbs.LoadBalancers[0].DNSName, nil
588+
dnsName := aws.StringValue(lbs.LoadBalancers[0].DNSName)
589+
if dnsName == "" {
590+
return "", fmt.Errorf("Load balancer %s doesn't have a dns name", aws.StringValue(lbs.LoadBalancers[0].LoadBalancerArn))
591+
}
592+
return dnsName, nil
585593
}

0 commit comments

Comments
 (0)