(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string)
| 203 | } |
| 204 | |
| 205 | func runConfigInterpolate(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) ([]byte, error) { |
| 206 | backend, err := compose.NewComposeService(dockerCli) |
| 207 | if err != nil { |
| 208 | return nil, err |
| 209 | } |
| 210 | |
| 211 | project, err := opts.ToProject(ctx, dockerCli, backend, services) |
| 212 | if err != nil { |
| 213 | return nil, err |
| 214 | } |
| 215 | |
| 216 | if opts.resolveImageDigests { |
| 217 | project, err = project.WithImagesResolved(compose.ImageDigestResolver(ctx, dockerCli.ConfigFile(), dockerCli.Client())) |
| 218 | if err != nil { |
| 219 | return nil, err |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | if !opts.noResolveEnv { |
| 224 | project, err = project.WithServicesEnvironmentResolved(true) |
| 225 | if err != nil { |
| 226 | return nil, err |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | if !opts.noConsistency { |
| 231 | err := project.CheckContainerNameUnicity() |
| 232 | if err != nil { |
| 233 | return nil, err |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | if opts.lockImageDigests { |
| 238 | project = imagesOnly(project) |
| 239 | } |
| 240 | |
| 241 | var content []byte |
| 242 | switch opts.Format { |
| 243 | case "json": |
| 244 | content, err = project.MarshalJSON() |
| 245 | case "yaml": |
| 246 | content, err = project.MarshalYAML() |
| 247 | default: |
| 248 | return nil, fmt.Errorf("unsupported format %q", opts.Format) |
| 249 | } |
| 250 | if err != nil { |
| 251 | return nil, err |
| 252 | } |
| 253 | return content, nil |
| 254 | } |
| 255 | |
| 256 | // imagesOnly return project with all attributes removed but service.images |
| 257 | func imagesOnly(project *types.Project) *types.Project { |
no test coverage detected