fix: use pointer receivers for composeService methods with sync.Once fields

Moving runtimeVersionCache from a package-level var to instance fields on
composeService caused copylocks violations in methods using value receivers,
since sync.Once contains sync.noCopy. Switch the 4 affected methods to
pointer receivers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2026-03-30 17:19:55 +02:00 committed by Nicolas De loof
parent 5f6f35ed22
commit c7d1a6030e
2 changed files with 4 additions and 4 deletions

View file

@ -568,7 +568,7 @@ func dockerFilePath(ctxName string, dockerfile string) string {
return dockerfile
}
func (s composeService) dryRunBake(cfg bakeConfig) map[string]string {
func (s *composeService) dryRunBake(cfg bakeConfig) map[string]string {
bakeResponse := map[string]string{}
for name, target := range cfg.Targets {
dryRunUUID := fmt.Sprintf("dryRun-%x", sha1.Sum([]byte(name)))
@ -581,7 +581,7 @@ func (s composeService) dryRunBake(cfg bakeConfig) map[string]string {
return bakeResponse
}
func (s composeService) displayDryRunBuildEvent(name, dryRunUUID, tag string) {
func (s *composeService) displayDryRunBuildEvent(name, dryRunUUID, tag string) {
s.events.On(api.Resource{
ID: name + " ==>",
Status: api.Done,

View file

@ -31,7 +31,7 @@ import (
"github.com/docker/compose/v5/pkg/utils"
)
func (s composeService) runHook(ctx context.Context, ctr container.Summary, service types.ServiceConfig, hook types.ServiceHook, listener api.ContainerEventListener) error {
func (s *composeService) runHook(ctx context.Context, ctr container.Summary, service types.ServiceConfig, hook types.ServiceHook, listener api.ContainerEventListener) error {
wOut := utils.GetWriter(func(line string) {
listener(api.ContainerEvent{
Type: api.HookEventLog,
@ -96,7 +96,7 @@ func (s composeService) runHook(ctx context.Context, ctr container.Summary, serv
return nil
}
func (s composeService) runWaitExec(ctx context.Context, execID string, service types.ServiceConfig, listener api.ContainerEventListener) error {
func (s *composeService) runWaitExec(ctx context.Context, execID string, service types.ServiceConfig, listener api.ContainerEventListener) error {
_, err := s.apiClient().ExecStart(ctx, execID, client.ExecStartOptions{
Detach: listener == nil,
TTY: service.Tty,