(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts scaleOptions, serviceReplicaTuples map[string]int)
| 61 | } |
| 62 | |
| 63 | func runScale(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts scaleOptions, serviceReplicaTuples map[string]int) error { |
| 64 | backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | |
| 69 | services := slices.Sorted(maps.Keys(serviceReplicaTuples)) |
| 70 | project, _, err := opts.ToProject(ctx, dockerCli, backend, services) |
| 71 | if err != nil { |
| 72 | return err |
| 73 | } |
| 74 | |
| 75 | if opts.noDeps { |
| 76 | if project, err = project.WithSelectedServices(services, types.IgnoreDependencies); err != nil { |
| 77 | return err |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | for key, value := range serviceReplicaTuples { |
| 82 | service, err := project.GetService(key) |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | service.SetScale(value) |
| 87 | project.Services[key] = service |
| 88 | } |
| 89 | |
| 90 | return backend.Scale(ctx, project, api.ScaleOptions{Services: services}) |
| 91 | } |
| 92 | |
| 93 | func parseServicesReplicasArgs(args []string) (map[string]int, error) { |
| 94 | serviceReplicaTuples := map[string]int{} |
no test coverage detected