提交 3171493e 编写于 作者: T Thomas Stromberg

Rename to PathMutexSpec

上级 c5f65baf
......@@ -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 {
......
......@@ -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 {
......
......@@ -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 {
......@@ -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,
......
......@@ -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)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册