Skip to content

Commit

Permalink
Respect KUBECACHEDIR environment variable (#975)
Browse files Browse the repository at this point in the history
This adds a check for the existence of a (non-empty) `KUBECACHEDIR`
environment variable that will be used to construct the cache directory
path if present.
  • Loading branch information
towo committed Dec 16, 2023
1 parent e41b425 commit 9da00c5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"path/filepath"
"runtime"
"os"

"github.com/google/wire"
"github.com/int128/kubelogin/pkg/infrastructure/logger"
Expand All @@ -23,8 +24,17 @@ type Interface interface {
Run(ctx context.Context, args []string, version string) int
}

func getDefaultTokenCacheDir(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}

var defaultListenAddress = []string{"127.0.0.1:8000", "127.0.0.1:18000"}
var defaultTokenCacheDir = filepath.Join("~", ".kube", "cache", "oidc-login")
var defaultTokenCacheDir = filepath.Join(
getDefaultTokenCacheDir("KUBECACHEDIR", filepath.Join("~", ".kube", "cache")),
"oidc-login")

const defaultAuthenticationTimeoutSec = 180

Expand Down

0 comments on commit 9da00c5

Please sign in to comment.