MCPcopy Create free account
hub / github.com/containerd/nerdctl / Config

Method Config

pkg/composer/config.go:44–77  ·  view source on GitHub ↗
(ctx context.Context, w io.Writer, co ConfigOptions)

Source from the content-addressed store, hash-verified

42}
43
44func (c *Composer) Config(ctx context.Context, w io.Writer, co ConfigOptions) error {
45 if co.Services {
46 for _, service := range c.project.Services {
47 fmt.Fprintln(w, service.Name)
48 }
49 return nil
50 }
51 if co.Volumes {
52 for volume := range c.project.Volumes {
53 fmt.Fprintln(w, volume)
54 }
55 return nil
56 }
57 if co.Hash != "" {
58 var services []string
59 if co.Hash != "*" {
60 services = strings.Split(co.Hash, ",")
61 }
62 return c.project.ForEachService(services, func(names string, svc *types.ServiceConfig) error {
63 hash, err := ServiceHash(*svc)
64 if err != nil {
65 return err
66 }
67 _, err = fmt.Fprintf(w, "%s %s\n", svc.Name, hash)
68 return err
69 })
70 }
71 projectYAML, err := yaml.Marshal(c.project)
72 if err != nil {
73 return err
74 }
75 fmt.Fprintf(w, "%s", projectYAML)
76 return nil
77}
78
79// ServiceHash is from https://github.com/docker/compose/blob/v2.2.2/pkg/compose/hash.go#L28-L38
80func ServiceHash(o types.ServiceConfig) (string, error) {

Callers 4

getImageConfigFunction · 0.45
ReadManifestFunction · 0.45
ReadImageConfigFunction · 0.45
configActionFunction · 0.45

Calls 2

ServiceHashFunction · 0.85
MarshalMethod · 0.80

Tested by

no test coverage detected