diff --git a/pkg/infrastructure/mutex/mutex.go b/pkg/infrastructure/mutex/mutex.go index 1e45aa6b9..cf42f7e88 100644 --- a/pkg/infrastructure/mutex/mutex.go +++ b/pkg/infrastructure/mutex/mutex.go @@ -6,7 +6,6 @@ import ( "os" "path" - "github.com/alexflint/go-filemutex" "github.com/google/wire" "github.com/int128/kubelogin/pkg/infrastructure/logger" ) @@ -54,7 +53,11 @@ func internalRelease(fm *filemutex.FileMutex, lfn string, log logger.Interface) // LockFileName get the lock file name from the lock name. func LockFileName(name string) string { - return path.Join(os.TempDir(), fmt.Sprintf(".kubelogin.%s.lock", name)) + dirname, err := os.UserHomeDir() + if err != nil { + dirname = os.TempDir() + } + return path.Join(dirname, fmt.Sprintf(".kubelogin.%s.lock", name)) } // Acquire acquire a lock for the specified name. The context could be used to set a timeout.