@@ -20,8 +20,8 @@ import (
20
20
type Config struct {
21
21
// Required
22
22
InstanceName string
23
- Auth AuthConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
24
- APIType string `json:"apiType"`
23
+ Auth AuthConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
24
+ APIType EnvironmentConfig // User can either supply these values manually or pass from LoadAuthConfig/Env vars
25
25
// Optional
26
26
LogLevel logger.LogLevel // Field for defining tiered logging level.
27
27
MaxRetryAttempts int // Config item defines the max number of retry request attempts for retryable HTTP methods.
@@ -43,14 +43,19 @@ type PerformanceMetrics struct {
43
43
lock sync.Mutex
44
44
}
45
45
46
- // ClientAuthConfig represents the structure to read authentication details from a JSON configuration file.
47
- type AuthConfig struct {
46
+ // EnvironmentConfig represents the structure to read authentication details from a JSON configuration file.
47
+ type EnvironmentConfig struct {
48
48
InstanceName string `json:"instanceName,omitempty"`
49
49
OverrideBaseDomain string `json:"overrideBaseDomain,omitempty"`
50
- Username string `json:"username,omitempty"`
51
- Password string `json:"password,omitempty"`
52
- ClientID string `json:"clientID,omitempty"`
53
- ClientSecret string `json:"clientSecret,omitempty"`
50
+ APIType string `json:"apiType,omitempty"`
51
+ }
52
+
53
+ // AuthConfig represents the structure to read authentication details from a JSON configuration file.
54
+ type AuthConfig struct {
55
+ Username string `json:"username,omitempty"`
56
+ Password string `json:"password,omitempty"`
57
+ ClientID string `json:"clientID,omitempty"`
58
+ ClientSecret string `json:"clientSecret,omitempty"`
54
59
}
55
60
56
61
// Client represents an HTTP client to interact with a specific API.
@@ -84,14 +89,14 @@ func BuildClient(config Config) (*Client, error) {
84
89
}
85
90
86
91
// Use the APIType from the config to determine which API handler to load
87
- apiHandler , err := LoadAPIHandler (config .APIType , log )
92
+ apiHandler , err := LoadAPIHandler (config .APIType . APIType , log )
88
93
if err != nil {
89
- return nil , log .Error ("Failed to load API handler" , zap .String ("APIType" , config .APIType ), zap .Error (err ))
94
+ return nil , log .Error ("Failed to load API handler" , zap .String ("APIType" , config .APIType . APIType ), zap .Error (err ))
90
95
}
91
96
92
97
log .Info ("Initializing new HTTP client" ,
93
98
zap .String ("InstanceName" , config .InstanceName ), // Using zap.String for structured logging
94
- zap .String ("APIType" , config .APIType ), // Using zap.String for structured logging
99
+ zap .String ("APIType" , config .APIType . APIType ), // Using zap.String for structured logging
95
100
zap .Int ("LogLevel" , int (config .LogLevel )), // Using zap.Int to log LogLevel as an integer
96
101
)
97
102
0 commit comments