Skip to content

Commit

Permalink
Fix misc in client
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com>
  • Loading branch information
pierre-emmanuelJ committed Jan 10, 2024
1 parent 572c29b commit e773f36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
17 changes: 3 additions & 14 deletions v3/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion v3/generator/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func Generate(doc libopenapi.Document, path, packageName string) error {
"context"
"runtime"
"time"
"errors"
"github.com/exoscale/egoscale/v3/credentials"
"github.com/exoscale/egoscale/version"
Expand Down
16 changes: 3 additions & 13 deletions v3/generator/client/client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type Client struct {
apiSecret string
serverURL string
httpClient *http.Client
timeout time.Duration
pollingInterval time.Duration
trace bool

Expand All @@ -40,18 +39,6 @@ const pollingInterval = 3 * time.Second
// ClientOpt represents a function setting Exoscale API client option.
type ClientOpt func(*Client) error

// ClientOptWithTimeout returns a ClientOpt overriding the default client timeout.
func ClientOptWithTimeout(v time.Duration) ClientOpt {
return func(c *Client) error {
if v <= 0 {
return errors.New("timeout value must be greater than 0")
}
c.timeout = v

return nil
}
}

// ClientOptWithTrace returns a ClientOpt enabling HTTP request/response tracing.
func ClientOptWithTrace() ClientOpt {
return func(c *Client) error {
Expand Down Expand Up @@ -122,6 +109,7 @@ func (c *Client) WithURL(url URL) *Client {
httpClient: c.httpClient,
requestInterceptors: c.requestInterceptors,
pollingInterval: c.pollingInterval,
trace: c.trace,
}
}

Expand All @@ -147,6 +135,7 @@ func (c *Client) WithHttpClient(client *http.Client) *Client {
httpClient: client,
requestInterceptors: c.requestInterceptors,
pollingInterval: c.pollingInterval,
trace: c.trace,
}
}

Expand All @@ -159,6 +148,7 @@ func (c *Client) WithRequestInterceptor(f ...RequestInterceptorFn) *Client {
httpClient: c.httpClient,
requestInterceptors: append(c.requestInterceptors, f...),
pollingInterval: c.pollingInterval,
trace: c.trace,
}
}

Expand Down

0 comments on commit e773f36

Please sign in to comment.