MCPcopy
hub / github.com/docker/compose / resolveAppIDIn

Function resolveAppIDIn

cmd/compose/hooks.go:123–145  ·  view source on GitHub ↗

Split from defaultResolveAppID so tests can pass a t.TempDir() instead of mutating process state via t.Chdir.

(ctx context.Context, flags map[string]string, workDir string)

Source from the content-addressed store, hash-verified

121// Split from defaultResolveAppID so tests can pass a t.TempDir() instead
122// of mutating process state via t.Chdir.
123func resolveAppIDIn(ctx context.Context, flags map[string]string, workDir string) string {
124 if hasFlag(flags, projectScopingFlags...) {
125 return ""
126 }
127 ctx, cancel := context.WithTimeout(ctx, projectNameResolveTimeout)
128 defer cancel()
129
130 opts, err := cli.NewProjectOptions(nil,
131 cli.WithWorkingDirectory(workDir),
132 cli.WithOsEnv,
133 cli.WithDotEnv,
134 cli.WithConfigFileEnv,
135 cli.WithDefaultConfigPath,
136 )
137 if err != nil {
138 return ""
139 }
140 project, err := opts.LoadProject(ctx)
141 if err != nil {
142 return ""
143 }
144 return project.Name
145}
146
147func hasFlag(flags map[string]string, names ...string) bool {
148 for _, n := range names {

Calls 2

hasFlagFunction · 0.85
LoadProjectMethod · 0.65