diff --git a/cmd/s3-genindex/main.go b/cmd/s3-genindex/main.go index a362417..04b8fea 100644 --- a/cmd/s3-genindex/main.go +++ b/cmd/s3-genindex/main.go @@ -64,7 +64,7 @@ func processS3Bucket(s3Config *S3Config, opts *indexgen.Options) error { // Get credentials from environment variables accessKey := os.Getenv("AWS_ACCESS_KEY_ID") secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY") - + if accessKey == "" || secretKey == "" { return fmt.Errorf("AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables must be set") } @@ -77,8 +77,8 @@ func processS3Bucket(s3Config *S3Config, opts *indexgen.Options) error { // Create S3 client with custom endpoint resolver client := s3.NewFromConfig(cfg, func(o *s3.Options) { - o.BaseEndpoint = aws.String(fmt.Sprintf("%s://%s", - map[bool]string{true: "https", false: "http"}[s3Config.UseSSL], + o.BaseEndpoint = aws.String(fmt.Sprintf("%s://%s", + map[bool]string{true: "https", false: "http"}[s3Config.UseSSL], s3Config.Endpoint)) o.UsePathStyle = true // Use path-style URLs for MinIO compatibility }) @@ -126,15 +126,15 @@ func processS3Bucket(s3Config *S3Config, opts *indexgen.Options) error { } entry := indexgen.FileEntry{ - Name: keyName, - Path: keyName, - IsDir: false, - Size: *obj.Size, - ModTime: *obj.LastModified, - IsSymlink: false, - IconType: indexgen.GetIconType(keyName), - SizePretty: indexgen.PrettySize(*obj.Size), - ModTimeISO: obj.LastModified.Format("2006-01-02T15:04:05Z"), + Name: keyName, + Path: keyName, + IsDir: false, + Size: *obj.Size, + ModTime: *obj.LastModified, + IsSymlink: false, + IconType: indexgen.GetIconType(keyName), + SizePretty: indexgen.PrettySize(*obj.Size), + ModTimeISO: obj.LastModified.Format("2006-01-02T15:04:05Z"), } // Set CSS class based on file type diff --git a/cmd/s3-genindex/main_test.go b/cmd/s3-genindex/main_test.go index 6b1ffe1..f7c007e 100644 --- a/cmd/s3-genindex/main_test.go +++ b/cmd/s3-genindex/main_test.go @@ -150,28 +150,28 @@ func TestS3FlagHandling(t *testing.T) { func TestMutualExclusionAndRequiredFlags(t *testing.T) { tests := []struct { - name string - args []string + name string + args []string shouldExitWithError bool }{ { - name: "no flags provided", - args: []string{"s3-genindex"}, + name: "no flags provided", + args: []string{"s3-genindex"}, shouldExitWithError: true, }, { - name: "directory flag only", - args: []string{"s3-genindex", "-d", "/tmp"}, + name: "directory flag only", + args: []string{"s3-genindex", "-d", "/tmp"}, shouldExitWithError: false, }, { - name: "s3 flag only", - args: []string{"s3-genindex", "-s3", "http://example.com/bucket"}, + name: "s3 flag only", + args: []string{"s3-genindex", "-s3", "http://example.com/bucket"}, shouldExitWithError: false, }, { - name: "both flags provided (mutual exclusion)", - args: []string{"s3-genindex", "-d", "/tmp", "-s3", "http://example.com/bucket"}, + name: "both flags provided (mutual exclusion)", + args: []string{"s3-genindex", "-d", "/tmp", "-s3", "http://example.com/bucket"}, shouldExitWithError: true, }, } @@ -257,7 +257,7 @@ func TestParseS3URL(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result, err := parseS3URL(tt.url) - + if tt.hasError { if err == nil { t.Errorf("parseS3URL(%q) expected error, got nil", tt.url)