Browse Source

use cli-plugins/metadata package

The metadata types and consts where moved to a separate package,
so update the code to use the new location instead of the aliases
provided.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Sebastiaan van Stijn 4 months ago
parent
commit
909211dd61
5 changed files with 12 additions and 10 deletions
  1. 2 2
      cmd/compose/compose.go
  2. 2 2
      cmd/main.go
  3. 2 1
      pkg/compose/build_bake.go
  4. 2 1
      pkg/compose/plugins.go
  5. 4 4
      pkg/compose/shellout.go

+ 2 - 2
cmd/compose/compose.go

@@ -36,7 +36,7 @@ import (
 	composegoutils "github.com/compose-spec/compose-go/v2/utils"
 	"github.com/docker/buildx/util/logutil"
 	dockercli "github.com/docker/cli/cli"
-	"github.com/docker/cli/cli-plugins/manager"
+	"github.com/docker/cli/cli-plugins/metadata"
 	"github.com/docker/cli/cli/command"
 	"github.com/docker/cli/pkg/kvfile"
 	"github.com/docker/compose/v2/cmd/formatter"
@@ -416,7 +416,7 @@ const PluginName = "compose"
 
 // RunningAsStandalone detects when running as a standalone program
 func RunningAsStandalone() bool {
-	return len(os.Args) < 2 || os.Args[1] != manager.MetadataSubcommandName && os.Args[1] != PluginName
+	return len(os.Args) < 2 || os.Args[1] != metadata.MetadataSubcommandName && os.Args[1] != PluginName
 }
 
 // RootCommand returns the compose command with its child commands

+ 2 - 2
cmd/main.go

@@ -20,7 +20,7 @@ import (
 	"os"
 
 	dockercli "github.com/docker/cli/cli"
-	"github.com/docker/cli/cli-plugins/manager"
+	"github.com/docker/cli/cli-plugins/metadata"
 	"github.com/docker/cli/cli-plugins/plugin"
 	"github.com/docker/cli/cli/command"
 	"github.com/docker/compose/v2/cmd/cmdtrace"
@@ -68,7 +68,7 @@ func pluginMain() {
 		})
 		return cmd
 	},
-		manager.Metadata{
+		metadata.Metadata{
 			SchemaVersion: "0.1.0",
 			Vendor:        "Docker Inc.",
 			Version:       internal.Version,

+ 2 - 1
pkg/compose/build_bake.go

@@ -34,6 +34,7 @@ import (
 	"strings"
 
 	"github.com/compose-spec/compose-go/v2/types"
+	"github.com/containerd/errdefs"
 	"github.com/docker/cli/cli-plugins/manager"
 	"github.com/docker/cli/cli/command"
 	"github.com/docker/compose/v2/pkg/api"
@@ -75,7 +76,7 @@ func buildWithBake(dockerCli command.Cli) (bool, error) {
 
 	_, err = manager.GetPlugin("buildx", dockerCli, &cobra.Command{})
 	if err != nil {
-		if manager.IsNotFound(err) {
+		if errdefs.IsNotFound(err) {
 			logrus.Warnf("Docker Compose is configured to build using Bake, but buildx isn't installed")
 			return false, nil
 		}

+ 2 - 1
pkg/compose/plugins.go

@@ -30,6 +30,7 @@ import (
 	"sync"
 
 	"github.com/compose-spec/compose-go/v2/types"
+	"github.com/containerd/errdefs"
 	"github.com/docker/cli/cli-plugins/manager"
 	"github.com/docker/cli/cli/config"
 	"github.com/docker/compose/v2/pkg/progress"
@@ -163,7 +164,7 @@ func (s *composeService) getPluginBinaryPath(provider string) (path string, err
 	if err == nil {
 		path = plugin.Path
 	}
-	if manager.IsNotFound(err) {
+	if errdefs.IsNotFound(err) {
 		path, err = exec.LookPath(executable(provider))
 	}
 	return path, err

+ 4 - 4
pkg/compose/shellout.go

@@ -21,7 +21,7 @@ import (
 	"os/exec"
 
 	"github.com/compose-spec/compose-go/v2/types"
-	"github.com/docker/cli/cli-plugins/manager"
+	"github.com/docker/cli/cli-plugins/metadata"
 	"github.com/docker/cli/cli/context/docker"
 	"github.com/docker/compose/v2/internal"
 	"go.opentelemetry.io/otel"
@@ -32,7 +32,7 @@ import (
 func (s *composeService) prepareShellOut(gctx context.Context, env types.Mapping, cmd *exec.Cmd) error {
 	env = env.Clone()
 	// remove DOCKER_CLI_PLUGIN... variable so a docker-cli plugin will detect it run standalone
-	delete(env, manager.ReexecEnvvar)
+	delete(env, metadata.ReexecEnvvar)
 
 	// propagate opentelemetry context to child process, see https://github.com/open-telemetry/oteps/blob/main/text/0258-env-context-baggage-carriers.md
 	carrier := propagation.MapCarrier{}
@@ -42,11 +42,11 @@ func (s *composeService) prepareShellOut(gctx context.Context, env types.Mapping
 	env["DOCKER_CONTEXT"] = s.dockerCli.CurrentContext()
 	env["USER_AGENT"] = "compose/" + internal.Version
 
-	metadata, err := s.dockerCli.ContextStore().GetMetadata(s.dockerCli.CurrentContext())
+	md, err := s.dockerCli.ContextStore().GetMetadata(s.dockerCli.CurrentContext())
 	if err != nil {
 		return err
 	}
-	endpoint, err := docker.EndpointFromContext(metadata)
+	endpoint, err := docker.EndpointFromContext(md)
 	if err != nil {
 		return err
 	}