Refine S3 Tables implementation to address code review feedback
- Standardize namespace representation to []string - Improve listing logic with pagination and StartFromFileName - Enhance error handling with sentinel errors and robust checks - Add JSON encoding error logging - Fix CI workflow to use gofmt -l - Standardize timestamps in directory creation - Validate single-level namespaces
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -98,3 +99,26 @@ func splitPath(path string) (dir, name string) {
|
||||
name = filepath.Base(path)
|
||||
return
|
||||
}
|
||||
|
||||
// validateNamespace validates that the namespace provided is supported (single-level)
|
||||
func validateNamespace(namespace []string) (string, error) {
|
||||
if len(namespace) == 0 {
|
||||
return "", fmt.Errorf("namespace is required")
|
||||
}
|
||||
if len(namespace) > 1 {
|
||||
return "", fmt.Errorf("multi-level namespaces are not supported")
|
||||
}
|
||||
name := namespace[0]
|
||||
if len(name) < 1 || len(name) > 255 {
|
||||
return "", fmt.Errorf("namespace name must be between 1 and 255 characters")
|
||||
}
|
||||
return name, nil
|
||||
}
|
||||
|
||||
// flattenNamespace joins namespace elements into a single string (using dots as per AWS S3 Tables)
|
||||
func flattenNamespace(namespace []string) string {
|
||||
if len(namespace) == 0 {
|
||||
return ""
|
||||
}
|
||||
return strings.Join(namespace, ".")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user