Skip to content

Commit 402d08e

Browse files
committed
Create constant for authentication tokens path
To appease the linter.
1 parent 6a08f10 commit 402d08e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

agent_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (s *agentTokens) Read(ctx context.Context, agentTokenID string) (*AgentToke
116116
return nil, ErrInvalidAgentTokenID
117117
}
118118

119-
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(agentTokenID))
119+
u := fmt.Sprintf(AuthenticationTokensPath, url.PathEscape(agentTokenID))
120120
req, err := s.client.NewRequest("GET", u, nil)
121121
if err != nil {
122122
return nil, err

team_token.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313
// Compile-time proof of interface implementation.
1414
var _ TeamTokens = (*teamTokens)(nil)
1515

16+
const (
17+
AuthenticationTokensPath = "authentication-tokens/%s"
18+
)
19+
1620
// TeamTokens describes all the team token related methods that the
1721
// Terraform Enterprise API supports.
1822
//
@@ -130,7 +134,7 @@ func (s *teamTokens) ReadByID(ctx context.Context, tokenID string) (*TeamToken,
130134
return nil, ErrInvalidTokenID
131135
}
132136

133-
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(tokenID))
137+
u := fmt.Sprintf(AuthenticationTokensPath, url.PathEscape(tokenID))
134138
req, err := s.client.NewRequest("GET", u, nil)
135139
if err != nil {
136140
return nil, err
@@ -166,7 +170,7 @@ func (s *teamTokens) DeleteByID(ctx context.Context, tokenID string) error {
166170
return ErrInvalidTokenID
167171
}
168172

169-
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(tokenID))
173+
u := fmt.Sprintf(AuthenticationTokensPath, url.PathEscape(tokenID))
170174
req, err := s.client.NewRequest("DELETE", u, nil)
171175
if err != nil {
172176
return err

user_token.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (s *userTokens) Read(ctx context.Context, tokenID string) (*UserToken, erro
119119
return nil, ErrInvalidTokenID
120120
}
121121

122-
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(tokenID))
122+
u := fmt.Sprintf(AuthenticationTokensPath, url.PathEscape(tokenID))
123123
req, err := s.client.NewRequest("GET", u, nil)
124124
if err != nil {
125125
return nil, err
@@ -140,7 +140,7 @@ func (s *userTokens) Delete(ctx context.Context, tokenID string) error {
140140
return ErrInvalidTokenID
141141
}
142142

143-
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(tokenID))
143+
u := fmt.Sprintf(AuthenticationTokensPath, url.PathEscape(tokenID))
144144
req, err := s.client.NewRequest("DELETE", u, nil)
145145
if err != nil {
146146
return err

0 commit comments

Comments
 (0)