Skip to content

Commit 141921e

Browse files
idsulikglours
authored andcommitted
lint fix
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com> (cherry picked from commit 6a35be5) Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
1 parent c6bec2e commit 141921e

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

pkg/compose/run.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,7 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
9898
Add(api.OneoffLabel, "True")
9999

100100
// Only ensure image exists for the target service, dependencies were already handled by startDependencies
101-
var buildOpts *api.BuildOptions
102-
if opts.Build != nil {
103-
// Create a copy of build options and restrict to only the target service
104-
buildOptsCopy := *opts.Build
105-
buildOptsCopy.Services = []string{opts.Service}
106-
buildOpts = &buildOptsCopy
107-
}
101+
buildOpts := prepareBuildOptions(opts)
108102
if err := s.ensureImagesExists(ctx, project, buildOpts, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
109103
return "", err
110104
}
@@ -155,6 +149,16 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
155149
return created.ID, err
156150
}
157151

152+
func prepareBuildOptions(opts api.RunOptions) *api.BuildOptions {
153+
if opts.Build == nil {
154+
return nil
155+
}
156+
// Create a copy of build options and restrict to only the target service
157+
buildOptsCopy := *opts.Build
158+
buildOptsCopy.Services = []string{opts.Service}
159+
return &buildOptsCopy
160+
}
161+
158162
func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts api.RunOptions) {
159163
service.Tty = opts.Tty
160164
service.StdinOpen = opts.Interactive

0 commit comments

Comments
 (0)