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

Function runConfigInterpolate

cmd/compose/config.go:205–254  ·  cmd/compose/config.go::runConfigInterpolate
(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string)

Source from the content-addressed store, hash-verified

203}
204
205func 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
257func imagesOnly(project *types.Project) *types.Project {

Callers 1

runConfigFunction · 0.85

Calls 7

NewComposeServiceFunction · 0.92
ImageDigestResolverFunction · 0.92
imagesOnlyFunction · 0.85
MarshalJSONMethod · 0.80
ToProjectMethod · 0.45
ConfigFileMethod · 0.45
ClientMethod · 0.45

Tested by

no test coverage detected