From 25893ba61e12d8d1db52e49ee91d3422b055604e Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 23 Jul 2019 09:23:17 -0400 Subject: [PATCH] aws/endpoints: Expose DNSSuffix for partitions Reference: https://github.com/aws/aws-sdk-go/issues/2710 --- aws/endpoints/endpoints.go | 7 +++++-- aws/endpoints/endpoints_test.go | 5 ++++- aws/endpoints/v3model.go | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/aws/endpoints/endpoints.go b/aws/endpoints/endpoints.go index f82babf6f95..9c936be6cf9 100644 --- a/aws/endpoints/endpoints.go +++ b/aws/endpoints/endpoints.go @@ -170,10 +170,13 @@ func PartitionForRegion(ps []Partition, regionID string) (Partition, bool) { // A Partition provides the ability to enumerate the partition's regions // and services. type Partition struct { - id string - p *partition + id, dnsSuffix string + p *partition } +// DNSSuffix returns the base domain name of the partition. +func (p Partition) DNSSuffix() string { return p.dnsSuffix } + // ID returns the identifier of the partition. func (p Partition) ID() string { return p.id } diff --git a/aws/endpoints/endpoints_test.go b/aws/endpoints/endpoints_test.go index 23c63e96f7b..7c569258db1 100644 --- a/aws/endpoints/endpoints_test.go +++ b/aws/endpoints/endpoints_test.go @@ -330,8 +330,11 @@ func TestPartitionForRegion(t *testing.T) { if !ok { t.Fatalf("expect partition to be found") } + if e, a := expect.DNSSuffix(), actual.DNSSuffix(); e != a { + t.Errorf("expect %s partition DNSSuffix, got %s", e, a) + } if e, a := expect.ID(), actual.ID(); e != a { - t.Errorf("expect %s partition, got %s", e, a) + t.Errorf("expect %s partition ID, got %s", e, a) } } diff --git a/aws/endpoints/v3model.go b/aws/endpoints/v3model.go index ff6f76db6eb..523ad79ac0a 100644 --- a/aws/endpoints/v3model.go +++ b/aws/endpoints/v3model.go @@ -54,8 +54,9 @@ type partition struct { func (p partition) Partition() Partition { return Partition{ - id: p.ID, - p: &p, + dnsSuffix: p.DNSSuffix, + id: p.ID, + p: &p, } }