MCPcopy Index your code
hub / github.com/devspace-sh/devspace / ensurePath

Function ensurePath

helper/cmd/sync/upstream.go:71–98  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

69}
70
71func ensurePath(args []string) (string, error) {
72 // Create the directory if it does not exist
73 path := args[0]
74 _, err := os.Stat(path)
75 if err != nil && os.IsNotExist(err) {
76 err := os.MkdirAll(path, 0755)
77 if err != nil {
78 return "", err
79 }
80 }
81
82 // we have to resolve the real local path, because the watcher gives us the real path always
83 realLocalPath, err := filepath.EvalSymlinks(path)
84 if err != nil {
85 return "", err
86 }
87
88 absolutePath, err := filepath.Abs(realLocalPath)
89 if err != nil {
90 return "", err
91 }
92
93 if absolutePath == "/" && path != "/" {
94 return "", fmt.Errorf("you are trying to sync the complete container root (/). By default this is not allowed, because this usually leads to unwanted behaviour. Please specify the correct container directory via the `--path` flag or `.path: localPath:/remotePath` option")
95 }
96
97 return absolutePath, nil
98}

Callers 2

RunMethod · 0.85
RunMethod · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected