Merge pull request #44380 from justinsb/route53_avoid_panic

Automatic merge from submit-queue

dnsprovider: Avoid panic if fields are nil

The aws-sdk has some helper functions which should generally be used
whenever dereferencing an AWS provided pointer, in case the pointer is
nil, which would otherwise be a panic.

Issue https://github.com/kubernetes/kops/issues/2347

```release-note
dnsprovider: avoid panic if route53 fields are nil
```
This commit is contained in:
Kubernetes Submit Queue 2017-04-12 22:26:19 -07:00 committed by GitHub
commit 66b8a88b83

View File

@ -20,6 +20,7 @@ import (
"k8s.io/kubernetes/federation/pkg/dnsprovider"
"k8s.io/kubernetes/federation/pkg/dnsprovider/rrstype"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/route53"
)
@ -32,24 +33,24 @@ type ResourceRecordSet struct {
}
func (rrset ResourceRecordSet) Name() string {
return *rrset.impl.Name
return aws.StringValue(rrset.impl.Name)
}
func (rrset ResourceRecordSet) Rrdatas() []string {
// Sigh - need to unpack the strings out of the route53 ResourceRecords
result := make([]string, len(rrset.impl.ResourceRecords))
for i, record := range rrset.impl.ResourceRecords {
result[i] = *record.Value
result[i] = aws.StringValue(record.Value)
}
return result
}
func (rrset ResourceRecordSet) Ttl() int64 {
return *rrset.impl.TTL
return aws.Int64Value(rrset.impl.TTL)
}
func (rrset ResourceRecordSet) Type() rrstype.RrsType {
return rrstype.RrsType(*rrset.impl.Type)
return rrstype.RrsType(aws.StringValue(rrset.impl.Type))
}
// Route53ResourceRecordSet returns the route53 ResourceRecordSet object for the ResourceRecordSet