MCPcopy Create free account
hub / github.com/docker/docker-agent / hookWorkingDir

Function hookWorkingDir

pkg/hooks/handler.go:165–177  ·  view source on GitHub ↗

hookWorkingDir resolves the directory a command hook runs in. An absolute override wins; a relative override is joined onto the executor's working directory; with no override the executor's working directory is used. Falling back to the executor's working directory (rather than "", which would inher

(base, override string)

Source from the content-addressed store, hash-verified

163// working_dir field (issue #2615); expansion runs before the absolute
164// check so ~/... overrides win.
165func hookWorkingDir(base, override string) string {
166 override = path.ExpandWorkingDir("hook working_dir", override)
167 if filepath.IsAbs(override) {
168 return override
169 }
170 if override == "" {
171 return base
172 }
173 if base == "" {
174 return override
175 }
176 return filepath.Join(base, override)
177}
178
179// hookEnv layers the hook's env overrides onto the executor's env. Only
180// the plain ${env.X} form is expanded (against the OS environment) in

Callers 2

newCommandFactoryFunction · 0.85
RunMethod · 0.85

Calls 1

ExpandWorkingDirFunction · 0.92

Tested by

no test coverage detected