浏览代码

don't use unitialized cli to setup DryRunClient

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 2 年之前
父节点
当前提交
b5f5e27597
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 1 1
      pkg/api/dryrunclient.go
  2. 5 2
      pkg/compose/compose.go

+ 1 - 1
pkg/api/dryrunclient.go

@@ -70,7 +70,7 @@ type execDetails struct {
 }
 
 // NewDryRunClient produces a DryRunClient
-func NewDryRunClient(apiClient client.APIClient, cli *command.DockerCli) (*DryRunClient, error) {
+func NewDryRunClient(apiClient client.APIClient, cli command.Cli) (*DryRunClient, error) {
 	b, err := builder.New(cli, builder.WithSkippedValidation())
 	if err != nil {
 		return nil, err

+ 5 - 2
pkg/compose/compose.go

@@ -88,8 +88,11 @@ func (s *composeService) DryRunMode(ctx context.Context, dryRun bool) (context.C
 		if err != nil {
 			return ctx, err
 		}
-		err = cli.Initialize(flags.NewClientOptions(), command.WithInitializeClient(func(cli *command.DockerCli) (client.APIClient, error) {
-			return api.NewDryRunClient(s.apiClient(), cli)
+
+		options := flags.NewClientOptions()
+		options.Context = s.dockerCli.CurrentContext()
+		err = cli.Initialize(options, command.WithInitializeClient(func(cli *command.DockerCli) (client.APIClient, error) {
+			return api.NewDryRunClient(s.apiClient(), s.dockerCli)
 		}))
 		if err != nil {
 			return ctx, err