Skip to content

Commit

Permalink
aws/endpoints: Expose DNSSuffix for partitions (#2711)
Browse files Browse the repository at this point in the history
Exposes the underlying partition metadata's DNSSuffix value via the `DNSSuffix` method on the endpoint's `Partition` type. This allows access to the partition's DNS suffix, e.g. "amazon.com".

Fix #2710
  • Loading branch information
bflad authored and jasdel committed Aug 2, 2019
1 parent 3280460 commit 061e5b2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### SDK Features

### SDK Enhancements
* `aws/endpoints`: Expose DNSSuffix for partitions ([#2711](https://github.com/aws/aws-sdk-go/pull/2711))
* Exposes the underlying partition metadata's DNSSuffix value via the `DNSSuffix` method on the endpoint's `Partition` type. This allows access to the partition's DNS suffix, e.g. "amazon.com".
* Fixes [#2710](https://github.com/aws/aws-sdk-go/issues/2710)

### SDK Bugs
7 changes: 5 additions & 2 deletions aws/endpoints/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
5 changes: 4 additions & 1 deletion aws/endpoints/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
5 changes: 3 additions & 2 deletions aws/endpoints/v3model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down

0 comments on commit 061e5b2

Please sign in to comment.