Skip to content

Commit

Permalink
Allow relative paths in kt-auth.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten authored and fgeller committed Sep 9, 2023
1 parent 9d4c73f commit 663b21a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"regexp"
"strings"
"syscall"
Expand Down Expand Up @@ -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
Expand All @@ -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)
}

0 comments on commit 663b21a

Please sign in to comment.