Skip to content

Commit

Permalink
Processed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ramondeklein committed Feb 3, 2025
1 parent efb88c5 commit 9e44368
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22-alpine as build
FROM golang:1.23-alpine as build

LABEL maintainer="MinIO Inc <[email protected]>"

Expand Down
7 changes: 2 additions & 5 deletions cmd/kes/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,13 @@ func startServer(addrFlag, configFlag string, verbose bool) error {
defer cancel()

srv := &kes.Server{}
logLevel := slog.LevelInfo
if rawConfig.Log != nil {
srv.ErrLevel.Set(rawConfig.Log.ErrLevel)
srv.AuditLevel.Set(rawConfig.Log.AuditLevel)
logLevel = rawConfig.Log.LogLevel
}
if verbose {
logLevel = slog.LevelDebug
if verbose || srv.ErrLevel.Level() == slog.LevelDebug {
slog.SetLogLoggerLevel(slog.LevelDebug)
}
slog.SetLogLoggerLevel(logLevel)

conf, err := rawConfig.Config(ctx)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions internal/keystore/vault/log.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vault

import (
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
Expand All @@ -11,6 +12,17 @@ import (
vaultapi "github.com/hashicorp/vault/api"
)

// NewLoggerTransport returns a new http.RoundTripper that logs HTTP requests and responses
// (when debug logging is enabled).
func NewLoggerTransport(ctx context.Context, rt http.RoundTripper) http.RoundTripper {
if !slog.Default().Enabled(ctx, slog.LevelDebug) {
return rt
}
return &loggingTransport{
RoundTripper: rt,
}
}

type loggingTransport struct {
http.RoundTripper
}
Expand Down
4 changes: 1 addition & 3 deletions internal/keystore/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ func Connect(ctx context.Context, c *Config) (*Store, error) {
tr.DisableKeepAlives = true
tr.MaxIdleConnsPerHost = -1
}
if slog.Default().Enabled(ctx, slog.LevelDebug) {
config.HttpClient.Transport = &loggingTransport{config.HttpClient.Transport}
}
config.HttpClient.Transport = NewLoggerTransport(ctx, config.HttpClient.Transport)
vaultClient, err := vaultapi.NewClient(config)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/sys/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type BinaryInfo struct {
Version string // The version of this binary
CommitID string // The git commit hash
Runtime string // The Go runtime version, e.g. go1.22.0
Runtime string // The Go runtime version, e.g. go1.23.5
Compiler string // The Go compiler used to build this binary
}

Expand Down
6 changes: 0 additions & 6 deletions kesconf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ type ymlFile struct {
Log struct {
Error env[string] `yaml:"error"`
Audit env[string] `yaml:"audit"`
Level env[string] `yaml:"level"`
} `yaml:"log"`

Keys []struct {
Expand Down Expand Up @@ -300,10 +299,6 @@ func ymlToServerConfig(y *ymlFile) (*File, error) {
if err != nil {
return nil, err
}
logLevel, err := parseLogLevel(y.Log.Level.Value)
if err != nil {
return nil, err
}

for path, api := range y.API.Paths {
if api.Timeout.Value < 0 {
Expand Down Expand Up @@ -359,7 +354,6 @@ func ymlToServerConfig(y *ymlFile) (*File, error) {
Log: &LogConfig{
ErrLevel: errLevel,
AuditLevel: auditLevel,
LogLevel: logLevel,
},
KeyStore: keystore,
}
Expand Down
3 changes: 0 additions & 3 deletions kesconf/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ type LogConfig struct {
// Audit determines whether the KES server logs audit events to STDOUT.
// It does not en/disable audit logging in general.
AuditLevel slog.Level

// Log level for which to report KES diagnostic messages.
LogLevel slog.Level
}

// APIConfig is a structure that holds the API configuration
Expand Down

0 comments on commit 9e44368

Please sign in to comment.