Skip to content

Commit b072049

Browse files
committed
review
1 parent 6ff168d commit b072049

File tree

2 files changed

+4
-56
lines changed

2 files changed

+4
-56
lines changed

main.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ func getEnvInt64(key string, defaultVal int64) int64 {
5959
return defaultVal
6060
}
6161

62-
// validateTLSClientConfig validates TLS client configuration
63-
func validateTLSClientConfig(certFile, keyFile string) error {
64-
if (certFile != "") != (keyFile != "") {
65-
return errors.New("TLS client key file and cert file should both be present")
66-
}
67-
return nil
68-
}
69-
7062
// loadScripts loads Lua scripts from the provided script paths
7163
func loadScripts(scriptPath string) (map[string][]byte, error) {
7264
if scriptPath == "" {
@@ -206,16 +198,10 @@ func main() {
206198
}
207199
}
208200

209-
var ls map[string][]byte
210-
if *scriptPath != "" {
211-
scripts := strings.Split(*scriptPath, ",")
212-
ls = make(map[string][]byte, len(scripts))
213-
for _, script := range scripts {
214-
if ls[script], err = os.ReadFile(script); err != nil {
215-
slog.Error("Error loading script file", "file", script, "error", err)
216-
os.Exit(1)
217-
}
218-
}
201+
ls, err := loadScripts(*scriptPath)
202+
if err != nil {
203+
slog.Error("Error loading script files", "scriptPath", scriptPath, "error", err)
204+
os.Exit(1)
219205
}
220206

221207
registry := createPrometheusRegistry(*redisMetricsOnly)

main_test.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -210,35 +210,6 @@ func TestGetEnvInt64(t *testing.T) {
210210
}
211211
}
212212

213-
func TestValidateTLSClientConfig(t *testing.T) {
214-
tests := []struct {
215-
name string
216-
certFile string
217-
keyFile string
218-
expectError bool
219-
}{
220-
{"both files provided", "/path/to/cert.pem", "/path/to/key.pem", false},
221-
{"both files empty", "", "", false},
222-
{"only cert file provided", "/path/to/cert.pem", "", true},
223-
{"only key file provided", "", "/path/to/key.pem", true},
224-
}
225-
226-
for _, tt := range tests {
227-
t.Run(tt.name, func(t *testing.T) {
228-
err := validateTLSClientConfig(tt.certFile, tt.keyFile)
229-
if tt.expectError {
230-
if err == nil {
231-
t.Errorf("validateTLSClientConfig(%s, %s) expected error but got none", tt.certFile, tt.keyFile)
232-
}
233-
} else {
234-
if err != nil {
235-
t.Errorf("validateTLSClientConfig(%s, %s) unexpected error: %v", tt.certFile, tt.keyFile, err)
236-
}
237-
}
238-
})
239-
}
240-
}
241-
242213
func TestLoadScripts(t *testing.T) {
243214
// Create temporary directory for test scripts
244215
tmpDir := t.TempDir()
@@ -368,15 +339,6 @@ func TestMainFunctionsIntegration(t *testing.T) {
368339
t.Errorf("Script content mismatch")
369340
}
370341

371-
// Test TLS validation
372-
if err := validateTLSClientConfig("/cert.pem", ""); err == nil {
373-
t.Error("Expected TLS validation error for mismatched cert/key")
374-
}
375-
376-
if err := validateTLSClientConfig("/cert.pem", "/key.pem"); err != nil {
377-
t.Errorf("Unexpected TLS validation error: %v", err)
378-
}
379-
380342
// Test registry creation
381343
registry := createPrometheusRegistry(true)
382344
if registry == nil {

0 commit comments

Comments
 (0)