@@ -23,40 +23,40 @@ import (
23
23
)
24
24
25
25
type apiClientOpt struct {
26
- uri string
27
- insecure bool
28
- username string
29
- password string
30
- headers map [string ]string
31
- timeout int
32
- idAttribute string
33
- createMethod string
34
- readMethod string
35
- readData string
36
- updateMethod string
37
- updateData string
38
- destroyMethod string
39
- destroyData string
40
- copyKeys []string
41
- writeReturnsObject bool
42
- createReturnsObject bool
43
- xssiPrefix string
44
- useCookies bool
45
- rateLimit float64
46
- oauthClientIDEnvVar string
26
+ uri string
27
+ insecure bool
28
+ username string
29
+ password string
30
+ headers map [string ]string
31
+ timeout int
32
+ idAttribute string
33
+ createMethod string
34
+ readMethod string
35
+ readData string
36
+ updateMethod string
37
+ updateData string
38
+ destroyMethod string
39
+ destroyData string
40
+ copyKeys []string
41
+ writeReturnsObject bool
42
+ createReturnsObject bool
43
+ xssiPrefix string
44
+ useCookies bool
45
+ rateLimit float64
46
+ oauthClientIDEnvVar string
47
47
oauthClientSecretEnvVar string
48
- oauthClientID string
49
- oauthClientSecret string
50
- oauthScopes []string
51
- oauthTokenURL string
52
- oauthEndpointParams url.Values
53
- certFile string
54
- keyFile string
55
- rootCAFile string
56
- certString string
57
- keyString string
58
- rootCAString string
59
- debug bool
48
+ oauthClientID string
49
+ oauthClientSecret string
50
+ oauthScopes []string
51
+ oauthTokenURL string
52
+ oauthEndpointParams url.Values
53
+ certFile string
54
+ keyFile string
55
+ rootCAFile string
56
+ certString string
57
+ keyString string
58
+ rootCAString string
59
+ debug bool
60
60
}
61
61
62
62
/*APIClient is a HTTP client with additional controlling fields*/
@@ -84,12 +84,13 @@ type APIClient struct {
84
84
oauthConfig * clientcredentials.Config
85
85
}
86
86
87
+ // Helper function for optional environment imports
87
88
func GetEnvStringOrDefault (key , def string ) string {
88
- if env := os .Getenv (key ); env != "" {
89
- log .Printf ("Got env for %s" , key )
90
- return env
91
- }
92
- return def
89
+ if env := os .Getenv (key ); env != "" {
90
+ log .Printf ("Got env for %s" , key )
91
+ return env
92
+ }
93
+ return def
93
94
}
94
95
95
96
// NewAPIClient makes a new api client for RESTful calls
@@ -215,7 +216,7 @@ func NewAPIClient(opt *apiClientOpt) (*APIClient, error) {
215
216
debug : opt .debug ,
216
217
}
217
218
218
- resolvedClientID := GetEnvStringOrDefault (opt .oauthClientIDEnvVar , opt .oauthClientID )
219
+ resolvedClientID := GetEnvStringOrDefault (opt .oauthClientIDEnvVar , opt .oauthClientID )
219
220
resolvedClientSecret := GetEnvStringOrDefault (opt .oauthClientSecretEnvVar , opt .oauthClientSecret )
220
221
221
222
if resolvedClientID != "" && resolvedClientSecret != "" && opt .oauthTokenURL != "" {
0 commit comments