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

Function runHash

cmd/compose/config.go:434–474  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, opts configOptions)

Source from the content-addressed store, hash-verified

432}
433
434func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
435 var services []string
436 if opts.hash != "*" {
437 services = append(services, strings.Split(opts.hash, ",")...)
438 }
439
440 backend, err := compose.NewComposeService(dockerCli)
441 if err != nil {
442 return err
443 }
444
445 project, _, err := opts.ProjectOptions.ToProject(ctx, dockerCli, backend, nil, cli.WithoutEnvironmentResolution)
446 if err != nil {
447 return err
448 }
449
450 if err := applyPlatforms(project, true); err != nil {
451 return err
452 }
453
454 if len(services) == 0 {
455 services = project.ServiceNames()
456 }
457
458 sorted := services
459 slices.Sort(sorted)
460
461 for _, name := range sorted {
462 s, err := project.GetService(name)
463 if err != nil {
464 return err
465 }
466
467 hash, err := compose.ServiceHash(s)
468 if err != nil {
469 return err
470 }
471 _, _ = fmt.Fprintf(dockerCli.Out(), "%s %s\n", name, hash)
472 }
473 return nil
474}
475
476func runProfiles(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
477 set := map[string]struct{}{}

Callers 1

configCommandFunction · 0.85

Calls 5

NewComposeServiceFunction · 0.92
ServiceHashFunction · 0.92
applyPlatformsFunction · 0.85
ToProjectMethod · 0.45
OutMethod · 0.45

Tested by

no test coverage detected