Skip to content

Commit

Permalink
Add a convenience Name method to the TrustDomain type (#228)
Browse files Browse the repository at this point in the history
Code that needs a string representing the trust domain name currently goes
through the String() method:

```
var td spiffeid.TrustDomain = ...
var tdName = td.String()
```

However, the code reads more clearly if we introduce a Name method:

```
var td spiffeid.TrustDomain = ...
var tdName = td.Name()
```

Signed-off-by: Andrew Harding <[email protected]>
  • Loading branch information
azdagron authored Jun 6, 2023
1 parent f6a3281 commit afa8eae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion v2/spiffeid/trustdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ func TrustDomainFromURI(uri *url.URL) (TrustDomain, error) {
return id.TrustDomain(), nil
}

// String returns the trust domain as a string, e.g. example.org.
// Name returns the trust domain name as a string, e.g. example.org.
func (td TrustDomain) Name() string {
return td.name
}

// String returns the trust domain name as a string, e.g. example.org.
func (td TrustDomain) String() string {
return td.name
}
Expand Down

0 comments on commit afa8eae

Please sign in to comment.