From 663b21ab72249da2d2357e43c010d1b66f6c947b Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Fri, 8 Sep 2023 13:13:36 +0200 Subject: [PATCH] Allow relative paths in kt-auth.json --- common.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common.go b/common.go index 7a7f5b3..9767dfa 100644 --- a/common.go +++ b/common.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "math/rand" "os" + "path/filepath" "regexp" "strings" "syscall" @@ -291,6 +292,12 @@ func setupAuthTLS(auth authConfig, saramaCfg *sarama.Config) error { return nil } +func qualifyPath(argFN string, target *string) { + if *target != "" && !filepath.IsAbs(*target) { + *target = filepath.Join(filepath.Dir(argFN), *target) + } +} + func readAuthFile(argFN string, envFN string, target *authConfig) { if argFN == "" && envFN == "" { return @@ -309,4 +316,8 @@ func readAuthFile(argFN string, envFN string, target *authConfig) { if err := json.Unmarshal(byts, target); err != nil { failf("failed to unmarshal auth file err=%v", err) } + + qualifyPath(fn, &target.CACert) + qualifyPath(fn, &target.ClientCert) + qualifyPath(fn, &target.ClientCertKey) }