-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
80 lines (69 loc) · 1.89 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package setting
import (
"time"
"github.com/KarlGW/azcfg/azure/cloud"
"github.com/KarlGW/azcfg/internal/httpr"
"github.com/KarlGW/azcfg/internal/request"
)
// WithHTTPClient sets the HTTP client for setting retrieval.
func WithHTTPClient(client request.Client) ClientOption {
return func(c *Client) {
c.c = client
}
}
// WithConcurrency sets the concurrency for setting retrieval.
func WithConcurrency(n int) ClientOption {
return func(c *Client) {
c.concurrency = n
}
}
// WithTimeout sets timeout for setting retrieval.
func WithTimeout(d time.Duration) ClientOption {
return func(c *Client) {
c.timeout = d
}
}
// WithRetryPolicy sets the retry policy for setting retrieval.
func WithRetryPolicy(r httpr.RetryPolicy) ClientOption {
return func(c *Client) {
c.retryPolicy = r
}
}
// WithCloud sets the Azure cloud for setting retrieval.
func WithCloud(c cloud.Cloud) ClientOption {
cl := c
return func(c *Client) {
if !cl.Valid() {
cl = cloud.AzurePublic
}
c.cloud = cl
}
}
// WithClientLabel sets label on the setting client.
func WithClientLabel(label string) ClientOption {
return func(c *Client) {
c.label = label
}
}
// WithClientLabels sets labels on the setting client based on the provided
// map. The key of the map should be the setting name, and the value
// should be the label.
func WithClientLabels(labels map[string]string) ClientOption {
return func(c *Client) {
c.labels = labels
}
}
// WithLabel sets label on the setting request. Overrides the label set on the client.
func WithLabel(label string) Option {
return func(o *Options) {
o.Label = label
}
}
// WithLabels sets labels on the setting requests based on the provided
// map. The key of the map should be the setting name, and the value
// should be the label. Overrides the labels set on the client.
func WithLabels(labels map[string]string) Option {
return func(o *Options) {
o.Labels = labels
}
}