Skip to content

Commit d85be94

Browse files
authored
Merge pull request #6 from deploymenttheory/dev
Dev
2 parents bd5b7b0 + 6159d37 commit d85be94

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

httpclient/httpclient_client.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
type Config struct {
2121
// Required
2222
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
2525
// Optional
2626
LogLevel logger.LogLevel // Field for defining tiered logging level.
2727
MaxRetryAttempts int // Config item defines the max number of retry request attempts for retryable HTTP methods.
@@ -43,14 +43,19 @@ type PerformanceMetrics struct {
4343
lock sync.Mutex
4444
}
4545

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 {
4848
InstanceName string `json:"instanceName,omitempty"`
4949
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"`
5459
}
5560

5661
// Client represents an HTTP client to interact with a specific API.
@@ -84,14 +89,14 @@ func BuildClient(config Config) (*Client, error) {
8489
}
8590

8691
// 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)
8893
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))
9095
}
9196

9297
log.Info("Initializing new HTTP client",
9398
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
95100
zap.Int("LogLevel", int(config.LogLevel)), // Using zap.Int to log LogLevel as an integer
96101
)
97102

logger/loggerconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func BuildLogger(logLevel LogLevel) Logger {
2929
Level: zap.NewAtomicLevelAt(zapLogLevel), // Default log level is Info
3030
Development: false, // Set to true if the logger is used in a development environment
3131
Encoding: "json", // Use JSON format for structured logging
32-
DisableCaller: false,
33-
DisableStacktrace: false,
32+
DisableCaller: true,
33+
DisableStacktrace: true,
3434
Sampling: nil,
3535
EncoderConfig: encoderCfg,
3636
OutputPaths: []string{

0 commit comments

Comments
 (0)