-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
52 lines (45 loc) · 1.36 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
package identity
import (
"github.com/KarlGW/azcfg/internal/request"
)
// CredentialOptions contains options for the various credential
// types.
type CredentialOptions struct {
// httpClient is a user provided client to override the default client.
httpClient request.Client
// clientID is the client ID of the client credential or
// user assigned identity.
clientID string
// clientSecret is the secret of a client credential with a shared
// secret (client secret credential).
clientSecret string
// resourceID of the user assigned identity, use this or clientID
// to target a specific user assigned identity.
resourceID string
}
// CredentialOption is a function to set *CredentialOptions.
type CredentialOption func(o *CredentialOptions)
// WithClientID sets the client ID.
func WithClientID(id string) CredentialOption {
return func(o *CredentialOptions) {
o.clientID = id
}
}
// WithResourceID sets the resource ID.
func WithResourceID(id string) CredentialOption {
return func(o *CredentialOptions) {
o.resourceID = id
}
}
// WithSecret sets the client secret.
func WithSecret(secret string) CredentialOption {
return func(o *CredentialOptions) {
o.clientSecret = secret
}
}
// WithHTTPClient sets the HTTP client of the credential.
func WithHTTPClient(c request.Client) CredentialOption {
return func(o *CredentialOptions) {
o.httpClient = c
}
}