@@ -123,7 +123,7 @@ func runUp(ctx context.Context, opts upOptions, services []string) error {
123
123
return err
124
124
}
125
125
126
- err = applyScale (opts .scale , project )
126
+ err = applyScaleOpt (opts .scale , project )
127
127
if err != nil {
128
128
return err
129
129
}
@@ -142,7 +142,7 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
142
142
return err
143
143
}
144
144
145
- err = applyScale (opts .scale , project )
145
+ err = applyScaleOpt (opts .scale , project )
146
146
if err != nil {
147
147
return err
148
148
}
@@ -215,8 +215,7 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
215
215
return err
216
216
}
217
217
218
- func applyScale (opts []string , project * types.Project ) error {
219
- SCALE:
218
+ func applyScaleOpt (opts []string , project * types.Project ) error {
220
219
for _ , scale := range opts {
221
220
split := strings .Split (scale , "=" )
222
221
if len (split ) != 2 {
@@ -227,26 +226,33 @@ SCALE:
227
226
if err != nil {
228
227
return err
229
228
}
230
- for i , s := range project .Services {
231
- if s .Name == name {
232
- service , err := project .GetService (name )
233
- if err != nil {
234
- return err
235
- }
236
- if service .Deploy == nil {
237
- service .Deploy = & types.DeployConfig {}
238
- }
239
- count := uint64 (replicas )
240
- service .Deploy .Replicas = & count
241
- project .Services [i ] = service
242
- continue SCALE
243
- }
229
+ err = setServiceScale (project , name , replicas )
230
+ if err != nil {
231
+ return err
244
232
}
245
- return fmt .Errorf ("unknown service %q" , name )
246
233
}
247
234
return nil
248
235
}
249
236
237
+ func setServiceScale (project * types.Project , name string , replicas int ) error {
238
+ for i , s := range project .Services {
239
+ if s .Name == name {
240
+ service , err := project .GetService (name )
241
+ if err != nil {
242
+ return err
243
+ }
244
+ if service .Deploy == nil {
245
+ service .Deploy = & types.DeployConfig {}
246
+ }
247
+ count := uint64 (replicas )
248
+ service .Deploy .Replicas = & count
249
+ project .Services [i ] = service
250
+ return nil
251
+ }
252
+ }
253
+ return fmt .Errorf ("unknown service %q" , name )
254
+ }
255
+
250
256
func setup (ctx context.Context , opts composeOptions , services []string ) (* client.Client , * types.Project , error ) {
251
257
c , err := client .NewWithDefaultLocalBackend (ctx )
252
258
if err != nil {
0 commit comments