Skip to content

Commit

Permalink
Rename to PathMutexSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
tstromberg committed Dec 11, 2019
1 parent c5f65ba commit 3171493
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig) error {
//
// If another process updates the shared certificate, it's invalid.
// TODO: Instead of racey manipulation of a shared certificate, use per-profile certs
spec := lock.UserMutexSpec(filepath.Join(localPath, "certs"))
spec := lock.PathMutexSpec(filepath.Join(localPath, "certs"))
glog.Infof("acquiring lock: %+v", spec)
releaser, err := mutex.Acquire(spec)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/kubeconfig/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func PopulateFromSettings(cfg *Settings, apiCfg *api.Config) error {
// activeContext is true when minikube is the CurrentContext
// If no CurrentContext is set, the given name will be used.
func Update(kcs *Settings) error {
spec := lock.UserMutexSpec(filepath.Join(kcs.filePath(), "settings.Update"))
spec := lock.PathMutexSpec(filepath.Join(kcs.filePath(), "settings.Update"))
glog.Infof("acquiring lock: %+v", spec)
releaser, err := mutex.Acquire(spec)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/lock/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (

// WriteFile decorates ioutil.WriteFile with a file lock and retry
func WriteFile(filename string, data []byte, perm os.FileMode) error {
spec := pathSpec(filename)
spec := PathMutexSpec(filename)
glog.Infof("WriteFile acquiring %s: %+v", filename, spec)
releaser, err := mutex.Acquire(spec)
if err != nil {
Expand All @@ -51,8 +51,8 @@ func WriteFile(filename string, data []byte, perm os.FileMode) error {
return err
}

// pathSpec returns a mutex spec for a path
func pathSpec(path string) mutex.Spec {
// PathMutexSpec returns a mutex spec for a path
func PathMutexSpec(path string) mutex.Spec {
s := mutex.Spec{
Name: fmt.Sprintf("mk%x", sha1.Sum([]byte(path)))[0:40],
Clock: clock.WallClock,
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/lock/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestUserMutexSpec(t *testing.T) {

for _, tc := range tests {
t.Run(tc.description, func(t *testing.T) {
got := pathSpec(tc.path)
got := PathMutexSpec(tc.path)
if len(got.Name) != 40 {
t.Errorf("%s is not 40 chars long", got.Name)
}
Expand Down

0 comments on commit 3171493

Please sign in to comment.