Skip to content

Commit 5d42545

Browse files
kaminekpeknur
andauthored
refactor(client): use default SDK client (#96)
Signed-off-by: Amine Kherbouche <kaminek92@gmail.com> Co-authored-by: Pekka Nurmi <pekka.nurmi@upcloud.com>
1 parent 2d7f830 commit 5d42545

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

internal/config/config.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,15 @@ func (s *Config) CreateService() (internal.AllServices, error) {
196196
return nil, fmt.Errorf("user credentials not found, these must be set in config file (%s) or via environment variables", configDetails)
197197
}
198198

199-
hc := &http.Client{Transport: &transport{}, Timeout: s.ClientTimeout()}
200-
whc := client.NewWithHTTPClient(
201-
username,
202-
password,
203-
hc,
204-
)
199+
client := client.New(username, password)
205200
// TODO: remove this after go-api actually respects 0 timeout
206201
// this is in order to enforce our custom (no) timeout because currently go-api
207202
// assumes 0 timeout means 'not set' rather than 'no timeout'.
208203
// see https://github.com/UpCloudLtd/upcloud-go-api/blob/2964ed7e597209b50a21f34259a20249e9aa220c/upcloud/client/client.go#L48
209-
hc.Timeout = s.ClientTimeout()
204+
client.SetTimeout(s.ClientTimeout())
205+
client.UserAgent = fmt.Sprintf("upctl/%s", Version)
210206

211-
whc.UserAgent = fmt.Sprintf("upctl/%s", Version)
212-
svc := service.New(whc)
207+
svc := service.New(client)
213208
// TODO; remove this when refactor is complete
214209
s.Service = internal.Wrapper{Service: svc}
215210
return svc, nil

0 commit comments

Comments
 (0)