Skip to content

Commit b08886a

Browse files
authored
cleanup double pointer
1 parent 92513c3 commit b08886a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

azure-devops-client/main.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ func (c *AzureDevopsClient) SupportsPatAuthentication() bool {
160160
}
161161

162162
func (c *AzureDevopsClient) rest() *resty.Client {
163-
164-
var client, err = c.restWithAuthentication(&c.restClient, "dev.azure.com")
163+
var client, err = c.restWithAuthentication(c.restClient, "dev.azure.com")
165164

166165
if err != nil {
167166
c.logger.Fatalf("could not create a rest client: %v", err)
@@ -171,8 +170,7 @@ func (c *AzureDevopsClient) rest() *resty.Client {
171170
}
172171

173172
func (c *AzureDevopsClient) restVsrm() *resty.Client {
174-
175-
var client, err = c.restWithAuthentication(&c.restClientVsrm, "vsrm.dev.azure.com")
173+
var client, err = c.restWithAuthentication(c.restClientVsrm, "vsrm.dev.azure.com")
176174

177175
if err != nil {
178176
c.logger.Fatalf("could not create a rest client: %v", err)
@@ -181,14 +179,13 @@ func (c *AzureDevopsClient) restVsrm() *resty.Client {
181179
return client
182180
}
183181

184-
func (c *AzureDevopsClient) restWithAuthentication(restClient **resty.Client, domain string) (*resty.Client, error) {
185-
186-
if *restClient == nil {
187-
*restClient = c.restWithoutToken(domain)
182+
func (c *AzureDevopsClient) restWithAuthentication(restClient *resty.Client, domain string) (*resty.Client, error) {
183+
if restClient == nil {
184+
restClient = c.restWithoutToken(domain)
188185
}
189186

190187
if c.SupportsPatAuthentication() {
191-
(*restClient).SetBasicAuth("", *c.accessToken)
188+
restClient.SetBasicAuth("", *c.accessToken)
192189
} else {
193190
ctx := context.Background()
194191
opts := policy.TokenRequestOptions{
@@ -199,10 +196,10 @@ func (c *AzureDevopsClient) restWithAuthentication(restClient **resty.Client, do
199196
panic(err)
200197
}
201198

202-
(*restClient).SetBasicAuth("", accessToken.Token)
199+
restClient.SetBasicAuth("", accessToken.Token)
203200
}
204201

205-
return (*restClient), nil
202+
return restClient, nil
206203
}
207204

208205
func (c *AzureDevopsClient) restWithoutToken(domain string) *resty.Client {

0 commit comments

Comments
 (0)