Jelajahi Sumber

lint fix

Signed-off-by: Suleiman Dibirov <[email protected]>
Suleiman Dibirov 2 bulan lalu
induk
melakukan
6a35be5112
1 mengubah file dengan 11 tambahan dan 7 penghapusan
  1. 11 7
      pkg/compose/run.go

+ 11 - 7
pkg/compose/run.go

@@ -98,13 +98,7 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
 		Add(api.OneoffLabel, "True")
 
 	// Only ensure image exists for the target service, dependencies were already handled by startDependencies
-	var buildOpts *api.BuildOptions
-	if opts.Build != nil {
-		// Create a copy of build options and restrict to only the target service
-		buildOptsCopy := *opts.Build
-		buildOptsCopy.Services = []string{opts.Service}
-		buildOpts = &buildOptsCopy
-	}
+	buildOpts := prepareBuildOptions(opts)
 	if err := s.ensureImagesExists(ctx, project, buildOpts, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
 		return "", err
 	}
@@ -155,6 +149,16 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
 	return created.ID, err
 }
 
+func prepareBuildOptions(opts api.RunOptions) *api.BuildOptions {
+	if opts.Build == nil {
+		return nil
+	}
+	// Create a copy of build options and restrict to only the target service
+	buildOptsCopy := *opts.Build
+	buildOptsCopy.Services = []string{opts.Service}
+	return &buildOptsCopy
+}
+
 func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts api.RunOptions) {
 	service.Tty = opts.Tty
 	service.StdinOpen = opts.Interactive