2019-04-30 05:19:58 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/cli/cli-plugins/manager"
|
|
|
|
"github.com/docker/cli/cli-plugins/plugin"
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "nopersistentprerun",
|
|
|
|
Short: "Testing without PersistentPreRun hooks",
|
2020-01-16 06:46:07 -05:00
|
|
|
// PersistentPreRunE: Not specified, we need to test that it works in the absence of an explicit call
|
2019-04-30 05:19:58 -04:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
cli := dockerCli.Client()
|
|
|
|
ping, err := cli.Ping(context.Background())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
fmt.Println(ping.APIVersion)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return cmd
|
|
|
|
},
|
|
|
|
manager.Metadata{
|
|
|
|
SchemaVersion: "0.1.0",
|
|
|
|
Vendor: "Docker Inc.",
|
|
|
|
Version: "testing",
|
|
|
|
})
|
|
|
|
}
|