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)
| 121 | // Split from defaultResolveAppID so tests can pass a t.TempDir() instead |
| 122 | // of mutating process state via t.Chdir. |
| 123 | func 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 | |
| 147 | func hasFlag(flags map[string]string, names ...string) bool { |
| 148 | for _, n := range names { |