|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"slices"
|
|
|
|
"slices"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/portainer/portainer/pkg/libstack"
|
|
|
|
"github.com/portainer/portainer/pkg/libstack"
|
|
|
|
|
|
|
|
|
|
|
@ -21,6 +22,8 @@ import (
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mu sync.Mutex
|
|
|
|
|
|
|
|
|
|
|
|
func withCli(
|
|
|
|
func withCli(
|
|
|
|
ctx context.Context,
|
|
|
|
ctx context.Context,
|
|
|
|
options libstack.Options,
|
|
|
|
options libstack.Options,
|
|
|
@ -47,9 +50,12 @@ func withCli(
|
|
|
|
|
|
|
|
|
|
|
|
opts.ConfigDir = tempDir
|
|
|
|
opts.ConfigDir = tempDir
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mu.Lock()
|
|
|
|
if err := cli.Initialize(opts); err != nil {
|
|
|
|
if err := cli.Initialize(opts); err != nil {
|
|
|
|
|
|
|
|
mu.Unlock()
|
|
|
|
return fmt.Errorf("unable to initialize the Docker client: %w", err)
|
|
|
|
return fmt.Errorf("unable to initialize the Docker client: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mu.Unlock()
|
|
|
|
defer cli.Client().Close()
|
|
|
|
defer cli.Client().Close()
|
|
|
|
|
|
|
|
|
|
|
|
for _, r := range options.Registries {
|
|
|
|
for _, r := range options.Registries {
|
|
|
|