Skip to content

Commit

Permalink
Allow per user based kubelogin lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
tommylogik committed Mar 17, 2023
1 parent 4df4f41 commit a571293
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/infrastructure/mutex/mutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"path"

"github.com/alexflint/go-filemutex"
"github.com/google/wire"
"github.com/int128/kubelogin/pkg/infrastructure/logger"
)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a571293

Please sign in to comment.