(ctx context.Context, w io.Writer, co ConfigOptions)
| 42 | } |
| 43 | |
| 44 | func (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 |
| 80 | func ServiceHash(o types.ServiceConfig) (string, error) { |
no test coverage detected