From b46a486d2946b19c550a65d560da3c0437eda907 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Mon, 1 Sep 2025 19:58:19 -0700 Subject: [PATCH] cleanup: s3 iam server debug logging done with debuglogger Move the debug output to the standard debuglogger for more consistency across the project. --- auth/iam.go | 3 +-- auth/iam_s3_object.go | 7 +++---- cmd/versitygw/main.go | 9 +-------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/auth/iam.go b/auth/iam.go index c0aa5d1..90e9240 100644 --- a/auth/iam.go +++ b/auth/iam.go @@ -135,7 +135,6 @@ type Opts struct { S3Bucket string S3Endpoint string S3DisableSSlVerfiy bool - S3Debug bool CacheDisable bool CacheTTL int CachePrune int @@ -161,7 +160,7 @@ func New(o *Opts) (IAMService, error) { fmt.Printf("initializing LDAP IAM with %q\n", o.LDAPServerURL) case o.S3Endpoint != "": svc, err = NewS3(o.RootAccount, o.S3Access, o.S3Secret, o.S3Region, o.S3Bucket, - o.S3Endpoint, o.S3DisableSSlVerfiy, o.S3Debug) + o.S3Endpoint, o.S3DisableSSlVerfiy) fmt.Printf("initializing S3 IAM with '%v/%v'\n", o.S3Endpoint, o.S3Bucket) case o.VaultEndpointURL != "": diff --git a/auth/iam_s3_object.go b/auth/iam_s3_object.go index 2cee171..ba848be 100644 --- a/auth/iam_s3_object.go +++ b/auth/iam_s3_object.go @@ -33,6 +33,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/aws/smithy-go" + "github.com/versity/versitygw/debuglogger" ) // IAMServiceS3 stores user accounts in an S3 object @@ -56,14 +57,13 @@ type IAMServiceS3 struct { bucket string endpoint string sslSkipVerify bool - debug bool rootAcc Account client *s3.Client } var _ IAMService = &IAMServiceS3{} -func NewS3(rootAcc Account, access, secret, region, bucket, endpoint string, sslSkipVerify, debug bool) (*IAMServiceS3, error) { +func NewS3(rootAcc Account, access, secret, region, bucket, endpoint string, sslSkipVerify bool) (*IAMServiceS3, error) { if access == "" { return nil, fmt.Errorf("must provide s3 IAM service access key") } @@ -87,7 +87,6 @@ func NewS3(rootAcc Account, access, secret, region, bucket, endpoint string, ssl bucket: bucket, endpoint: endpoint, sslSkipVerify: sslSkipVerify, - debug: debug, rootAcc: rootAcc, } @@ -235,7 +234,7 @@ func (s *IAMServiceS3) getConfig() (aws.Config, error) { config.WithHTTPClient(client), } - if s.debug { + if debuglogger.IsIAMDebugEnabled() { opts = append(opts, config.WithClientLogMode(aws.LogSigning|aws.LogRetries|aws.LogRequest|aws.LogResponse|aws.LogRequestEventMessage|aws.LogResponseEventMessage)) } diff --git a/cmd/versitygw/main.go b/cmd/versitygw/main.go index 126a80e..fc831e2 100644 --- a/cmd/versitygw/main.go +++ b/cmd/versitygw/main.go @@ -72,7 +72,7 @@ var ( s3IamAccess, s3IamSecret string s3IamRegion, s3IamBucket string s3IamEndpoint string - s3IamSslNoVerify, s3IamDebug bool + s3IamSslNoVerify bool iamCacheDisable bool iamCacheTTL int iamCachePrune int @@ -497,12 +497,6 @@ func initFlags() []cli.Flag { EnvVars: []string{"VGW_S3_IAM_NO_VERIFY"}, Destination: &s3IamSslNoVerify, }, - &cli.BoolFlag{ - Name: "s3-iam-debug", - Usage: "s3 IAM debug output", - EnvVars: []string{"VGW_S3_IAM_DEBUG"}, - Destination: &s3IamDebug, - }, &cli.BoolFlag{ Name: "iam-cache-disable", Usage: "disable local iam cache", @@ -692,7 +686,6 @@ func runGateway(ctx context.Context, be backend.Backend) error { S3Bucket: s3IamBucket, S3Endpoint: s3IamEndpoint, S3DisableSSlVerfiy: s3IamSslNoVerify, - S3Debug: s3IamDebug, CacheDisable: iamCacheDisable, CacheTTL: iamCacheTTL, CachePrune: iamCachePrune,