Skip to content

Commit 44e4a50

Browse files
Remove unnecessary usages of envstr
1 parent a3732f0 commit 44e4a50

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

cmd/internal/config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ type Config struct {
4343
KtQueryServiceConfig *ServiceConfig `yaml:"kt-query"`
4444
KtTestServiceConfig *ServiceConfig `yaml:"kt-test"`
4545

46-
LogOutputFile envstr `yaml:"log-output"`
47-
MetricsAddr envstr `yaml:"metrics-addr"`
48-
DatadogAddr envstr `yaml:"datadog-addr"`
49-
HealthAddr envstr `yaml:"health-addr"`
46+
LogOutputFile string `yaml:"log-output"`
47+
MetricsAddr string `yaml:"metrics-addr"`
48+
DatadogAddr string `yaml:"datadog-addr"`
49+
HealthAddr string `yaml:"health-addr"`
5050

5151
APIConfig *APIConfig `yaml:"api"`
5252
StreamConfig *StreamConfig `yaml:"stream"`
@@ -62,7 +62,7 @@ type CacheConfig struct {
6262
}
6363

6464
type ServiceConfig struct {
65-
ServerAddr envstr `yaml:"server-addr"`
65+
ServerAddr string `yaml:"server-addr"`
6666
// a map of headers to a list of authorized values. at least one header to value mapping must be present on client requests
6767
AuthorizedHeaders map[string][]string `yaml:"authorized-headers"`
6868
// a map of header values to auditor name. each key in this map should match a value in the AuthorizedHeaders map.
@@ -85,7 +85,7 @@ type APIConfig struct {
8585
FakeUpdates *FakeUpdates `yaml:"fake"`
8686

8787
// A map of auditor name to its hex-encoded public signature key.
88-
AuditorConfigs map[string]envstr `yaml:"auditors"`
88+
AuditorConfigs map[string]string `yaml:"auditors"`
8989
auditorConfigs map[string]ed25519.PublicKey
9090

9191
Distinguished time.Duration `yaml:"distinguished"`
@@ -308,7 +308,7 @@ func Read(filename string) (*Config, error) {
308308

309309
parsed.APIConfig.auditorConfigs = map[string]ed25519.PublicKey{}
310310
for auditorName, publicKey := range parsed.APIConfig.AuditorConfigs {
311-
pubKey, err := hex.DecodeString(publicKey.String())
311+
pubKey, err := hex.DecodeString(publicKey)
312312

313313
if err != nil {
314314
return nil, fmt.Errorf("failed to parse auditor public key: %v for auditor %s", err, auditorName)
@@ -344,7 +344,7 @@ func Read(filename string) (*Config, error) {
344344

345345
func (c *Config) SetLogOutput() error {
346346
if c.LogOutputFile != "" {
347-
f, err := os.OpenFile(c.LogOutputFile.String(), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
347+
f, err := os.OpenFile(c.LogOutputFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
348348
if err != nil {
349349
return fmt.Errorf("Failed to open log file: %v", err)
350350
}

cmd/kt-server/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ func main() {
5858

5959
var zeroLogLogger zerolog.Logger
6060
var logWriter io.Writer
61-
if len(config.LogOutputFile.String()) > 0 {
61+
if len(config.LogOutputFile) > 0 {
6262
logWriter = zerolog.MultiLevelWriter(
6363
consoleWriter,
6464
&lumberjack.Logger{
65-
Filename: config.LogOutputFile.String(),
65+
Filename: config.LogOutputFile,
6666
MaxBackups: 10,
6767
Compress: true,
6868
},
@@ -84,18 +84,18 @@ func main() {
8484
healthCheck.SetServingStatus(readiness, healthpb.HealthCheckResponse_NOT_SERVING)
8585

8686
// Configure healthCheck service to listen on its dedicated port
87-
lis, err := net.Listen("tcp", config.HealthAddr.String())
87+
lis, err := net.Listen("tcp", config.HealthAddr)
8888
if err != nil {
89-
util.Log().Fatalf("failed to listen on health check port %v: %v", config.HealthAddr.String(), err)
89+
util.Log().Fatalf("failed to listen on health check port %v: %v", config.HealthAddr, err)
9090
}
9191
util.Log().Infof("Starting health check server at: %v", config.HealthAddr)
9292

9393
// Start the health server.
9494
go healthServer.Serve(lis)
9595

9696
// Start the metrics server.
97-
exportMetrics(config.DatadogAddr.String())
98-
go metricsServer(config.MetricsAddr.String())
97+
exportMetrics(config.DatadogAddr)
98+
go metricsServer(config.MetricsAddr)
9999

100100
// Start the inserter thread.
101101
tx, err := config.DatabaseConfig.Connect()
@@ -246,5 +246,5 @@ func main() {
246246
}
247247

248248
func createListener(serviceConfig *config.ServiceConfig) (net.Listener, error) {
249-
return net.Listen("tcp", serviceConfig.ServerAddr.String())
249+
return net.Listen("tcp", serviceConfig.ServerAddr)
250250
}

0 commit comments

Comments
 (0)