mirror of https://github.com/docker/cli.git
allow for dangling symlinks
Signed-off-by: Will Wang <willww64@gmail.com>
This commit is contained in:
parent
115fdd979b
commit
c6d1de3397
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -167,9 +168,9 @@ func (configFile *ConfigFile) Save() (retErr error) {
|
||||||
return errors.Wrap(err, "error closing temp file")
|
return errors.Wrap(err, "error closing temp file")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle situation where the configfile is a symlink
|
|
||||||
cfgFile := configFile.Filename
|
cfgFile := configFile.Filename
|
||||||
if f, err := filepath.EvalSymlinks(cfgFile); err == nil {
|
// Handle situations where `configFile.Filename` is a symlink, and allow for dangling symlinks
|
||||||
|
if f, err := filepath.EvalSymlinks(cfgFile); err == nil || errors.Is(err, fs.ErrNotExist) {
|
||||||
cfgFile = f
|
cfgFile = f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue