Skip to content

Commit

Permalink
fix: options shouldn't be applied if empty value (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewab authored Apr 26, 2024
1 parent afd451b commit 3fcc050
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type ClientOption func(configuration *internal.Configuration)
// Optional. Default is https://csp.infoblox.com
func WithCSPUrl(cspURL string) ClientOption {
return func(configuration *internal.Configuration) {
configuration.CSPURL = cspURL
if cspURL != "" {
configuration.CSPURL = cspURL
}
}
}

Expand All @@ -27,15 +29,19 @@ func WithCSPUrl(cspURL string) ClientOption {
// Required.
func WithAPIKey(apiKey string) ClientOption {
return func(configuration *internal.Configuration) {
configuration.APIKey = apiKey
if apiKey != "" {
configuration.APIKey = apiKey
}
}
}

// WithHTTPClient returns a ClientOption that sets the HTTPClient to use for the SDK.
// Optional. The default HTTPClient will be used if not provided.
func WithHTTPClient(httpClient *http.Client) ClientOption {
return func(configuration *internal.Configuration) {
configuration.HTTPClient = httpClient
if httpClient != nil {
configuration.HTTPClient = httpClient
}
}
}

Expand All @@ -52,7 +58,9 @@ func WithDefaultTags(defaultTags map[string]string) ClientOption {
// Optional. If not provided, the client name will be set to "bloxone-go-client".
func WithClientName(clientName string) ClientOption {
return func(configuration *internal.Configuration) {
configuration.ClientName = clientName
if clientName != "" {
configuration.ClientName = clientName
}
}
}

Expand Down

0 comments on commit 3fcc050

Please sign in to comment.