|
|
@ -4,7 +4,6 @@ import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"maps"
|
|
|
|
"maps"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"slices"
|
|
|
|
"slices"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
@ -19,6 +18,7 @@ import (
|
|
|
|
"github.com/docker/cli/cli/flags"
|
|
|
|
"github.com/docker/cli/cli/flags"
|
|
|
|
"github.com/docker/compose/v2/pkg/api"
|
|
|
|
"github.com/docker/compose/v2/pkg/api"
|
|
|
|
"github.com/docker/compose/v2/pkg/compose"
|
|
|
|
"github.com/docker/compose/v2/pkg/compose"
|
|
|
|
|
|
|
|
"github.com/docker/docker/registry"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -42,14 +42,6 @@ func withCli(
|
|
|
|
opts.Hosts = []string{options.Host}
|
|
|
|
opts.Hosts = []string{options.Host}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tempDir, err := os.MkdirTemp("", "docker-config")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("unable to create a temporary directory for the Docker config: %w", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer os.RemoveAll(tempDir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opts.ConfigDir = tempDir
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mu.Lock()
|
|
|
|
mu.Lock()
|
|
|
|
if err := cli.Initialize(opts); err != nil {
|
|
|
|
if err := cli.Initialize(opts); err != nil {
|
|
|
|
mu.Unlock()
|
|
|
|
mu.Unlock()
|
|
|
@ -59,11 +51,11 @@ func withCli(
|
|
|
|
defer cli.Client().Close()
|
|
|
|
defer cli.Client().Close()
|
|
|
|
|
|
|
|
|
|
|
|
for _, r := range options.Registries {
|
|
|
|
for _, r := range options.Registries {
|
|
|
|
creds := cli.ConfigFile().GetCredentialsStore(r.ServerAddress)
|
|
|
|
if r.ServerAddress == "" || r.ServerAddress == registry.DefaultNamespace {
|
|
|
|
|
|
|
|
r.ServerAddress = registry.IndexServer
|
|
|
|
if err := creds.Store(r); err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("unable to store the Docker credentials: %w", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cli.ConfigFile().AuthConfigs[r.ServerAddress] = r
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return cliFn(ctx, cli)
|
|
|
|
return cliFn(ctx, cli)
|
|
|
|