(ctx context.Context, dockerCli command.Cli, services ...string)
| 244 | } |
| 245 | |
| 246 | func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) { |
| 247 | name := o.ProjectName |
| 248 | var project *types.Project |
| 249 | if len(o.ConfigPaths) > 0 || o.ProjectName == "" { |
| 250 | backend, err := compose.NewComposeService(dockerCli) |
| 251 | if err != nil { |
| 252 | return nil, "", err |
| 253 | } |
| 254 | |
| 255 | p, _, err := o.ToProject(ctx, dockerCli, backend, services, cli.WithDiscardEnvFile, cli.WithoutEnvironmentResolution) |
| 256 | if err != nil { |
| 257 | envProjectName := os.Getenv(ComposeProjectName) |
| 258 | if envProjectName != "" { |
| 259 | return nil, envProjectName, nil |
| 260 | } |
| 261 | return nil, "", err |
| 262 | } |
| 263 | project = p |
| 264 | name = p.Name |
| 265 | } |
| 266 | return project, name, nil |
| 267 | } |
| 268 | |
| 269 | func (o *ProjectOptions) toProjectName(ctx context.Context, dockerCli command.Cli) (string, error) { |
| 270 | if o.ProjectName != "" { |
no test coverage detected