Renamed docker-classic to “com.docker.com”.

This commit is contained in:
Guillaume Tardif 2020-06-17 17:57:44 +02:00
parent 5103d54330
commit bbcdad39d5
18 changed files with 53 additions and 46 deletions

View file

@ -32,7 +32,7 @@ import (
"github.com/spf13/cobra"
"github.com/docker/api/cli/dockerclassic"
"github.com/docker/api/cli/mobycli"
"github.com/docker/api/context/store"
)
@ -76,7 +76,7 @@ $ docker context create my-context --description "some description" --docker "ho
Use: "create CONTEXT",
Short: "Create new context",
RunE: func(cmd *cobra.Command, args []string) error {
return dockerclassic.ExecCmd(cmd)
return mobycli.ExecCmd(cmd)
},
Long: longHelp,
}

View file

@ -28,7 +28,7 @@
package context
import (
"github.com/docker/api/cli/dockerclassic"
"github.com/docker/api/cli/mobycli"
"github.com/spf13/cobra"
)
@ -39,7 +39,7 @@ func inspectCommand() *cobra.Command {
Short: "Display detailed information on one or more contexts",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return dockerclassic.ExecCmd(cmd)
return mobycli.ExecCmd(cmd)
},
}
return cmd

View file

@ -32,10 +32,11 @@ import (
"errors"
"fmt"
"github.com/spf13/cobra"
apicontext "github.com/docker/api/context"
"github.com/docker/api/context/store"
"github.com/docker/api/multierror"
"github.com/spf13/cobra"
)
type removeOpts struct {

View file

@ -8,7 +8,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/docker/api/cli/dockerclassic"
"github.com/docker/api/cli/mobycli"
"github.com/docker/api/client"
"github.com/docker/api/errdefs"
)
@ -22,7 +22,7 @@ func Command() *cobra.Command {
Args: cobra.MaximumNArgs(1),
RunE: runLogin,
}
// define flags for backward compatibility with docker-classic
// define flags for backward compatibility with com.docker.cli
flags := cmd.Flags()
flags.StringP("username", "u", "", "Username")
flags.StringP("password", "p", "", "Password")
@ -41,7 +41,7 @@ func runLogin(cmd *cobra.Command, args []string) error {
return errors.New("unknown backend type for cloud login: " + backend)
}
}
return dockerclassic.ExecCmd(cmd)
return mobycli.ExecCmd(cmd)
}
func cloudLogin(cmd *cobra.Command, backendType string) error {

View file

@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
"github.com/docker/api/cli/dockerclassic"
"github.com/docker/api/cli/mobycli"
)
const cliVersion = "0.1.0"
@ -19,7 +19,7 @@ func VersionCommand() *cobra.Command {
Args: cobra.MaximumNArgs(0),
RunE: runVersion,
}
// define flags for backward compatibility with docker-classic
// define flags for backward compatibility with com.docker.cli
flags := cmd.Flags()
flags.String("format", "", "Format the output using the given Go template")
flags.String("kubeconfig", "", "Kubernetes config file")
@ -28,11 +28,11 @@ func VersionCommand() *cobra.Command {
}
func runVersion(cmd *cobra.Command, args []string) error {
versionResult, _ := dockerclassic.ExecSilent(cmd.Context())
versionResult, _ := mobycli.ExecSilent(cmd.Context())
// we don't want to fail on error, there is an error if the engine is not available but it displays client version info
// Still, technically the [] byte versionResult could be nil, just let the original command display what it has to display
if versionResult == nil {
return dockerclassic.ExecCmd(cmd)
return mobycli.ExecCmd(cmd)
}
var s string = string(versionResult)
fmt.Print(strings.Replace(s, "\n Version:", "\n Azure integration "+cliVersion+"\n Version:", 1))

View file

@ -52,7 +52,7 @@ import (
contextcmd "github.com/docker/api/cli/cmd/context"
"github.com/docker/api/cli/cmd/login"
"github.com/docker/api/cli/cmd/run"
"github.com/docker/api/cli/dockerclassic"
"github.com/docker/api/cli/mobycli"
cliopts "github.com/docker/api/cli/options"
"github.com/docker/api/config"
apicontext "github.com/docker/api/context"
@ -101,7 +101,7 @@ func main() {
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if !isOwnCommand(cmd) {
dockerclassic.Exec(cmd.Context())
mobycli.Exec(cmd.Context())
}
return nil
},
@ -127,7 +127,7 @@ func main() {
helpFunc := root.HelpFunc()
root.SetHelpFunc(func(cmd *cobra.Command, args []string) {
if !isOwnCommand(cmd) {
dockerclassic.Exec(cmd.Context())
mobycli.Exec(cmd.Context())
}
helpFunc(cmd, args)
})
@ -168,7 +168,7 @@ func main() {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
dockerclassic.Exec(ctx)
mobycli.Exec(ctx)
checkIfUnknownCommandExistInDefaultContext(err, currentContext)
fmt.Fprintln(os.Stderr, err)
@ -182,7 +182,7 @@ func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string
if len(submatch) == 2 {
dockerCommand := string(submatch[1])
if dockerclassic.IsDefaultContextCommand(dockerCommand) {
if mobycli.IsDefaultContextCommand(dockerCommand) {
fmt.Fprintf(os.Stderr, "Command \"%s\" not available in current context (%s), you can use the \"default\" context to run this command\n", dockerCommand, currentContext)
os.Exit(1)
}

View file

@ -1,4 +1,4 @@
package dockerclassic
package mobycli
import (
"context"
@ -13,10 +13,10 @@ import (
"github.com/docker/api/context/store"
)
// ClassicCliName name of the classic cli binary
const ClassicCliName = "docker-classic"
// ComDockerCli name of the classic cli binary
const ComDockerCli = "com.docker.cli"
// Exec delegates to docker-classic
// Exec delegates to com.docker.cli
func Exec(ctx context.Context) {
currentContext := apicontext.CurrentContext(ctx)
s := store.ContextStore(ctx)
@ -25,7 +25,7 @@ func Exec(ctx context.Context) {
// Only run original docker command if the current context is not
// ours.
if err != nil {
cmd := exec.CommandContext(ctx, ClassicCliName, os.Args[1:]...)
cmd := exec.CommandContext(ctx, ComDockerCli, os.Args[1:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
@ -40,7 +40,7 @@ func Exec(ctx context.Context) {
}
}
// ExecCmd delegates the cli command to docker-classic. The error is never returned (process will exit with docker classic exit code), the return type is to make it easier to use with cobra commands
// ExecCmd delegates the cli command to com.docker.cli. The error is never returned (process will exit with docker classic exit code), the return type is to make it easier to use with cobra commands
func ExecCmd(command *cobra.Command) error {
Exec(command.Context())
return nil
@ -48,7 +48,7 @@ func ExecCmd(command *cobra.Command) error {
// IsDefaultContextCommand checks if the command exists in the classic cli (issues a shellout --help)
func IsDefaultContextCommand(dockerCommand string) bool {
cmd := exec.Command(ClassicCliName, dockerCommand, "--help")
cmd := exec.Command(ComDockerCli, dockerCommand, "--help")
b, e := cmd.CombinedOutput()
if e != nil {
fmt.Println(e)
@ -60,6 +60,6 @@ func IsDefaultContextCommand(dockerCommand string) bool {
// ExecSilent executes a command and do redirect output to stdOut, return output
func ExecSilent(ctx context.Context) ([]byte, error) {
cmd := exec.CommandContext(ctx, ClassicCliName, os.Args[1:]...)
cmd := exec.CommandContext(ctx, ComDockerCli, os.Args[1:]...)
return cmd.CombinedOutput()
}

View file

@ -1,4 +1,4 @@
package dockerclassic
package mobycli
import (
"fmt"