github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/e2e/cli-plugins/plugins/nopersistentprerun/main.go (about) 1 package main 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/docker/cli/cli-plugins/manager" 8 "github.com/docker/cli/cli-plugins/plugin" 9 "github.com/docker/cli/cli/command" 10 "github.com/spf13/cobra" 11 ) 12 13 func main() { 14 plugin.Run(func(dockerCli command.Cli) *cobra.Command { 15 cmd := &cobra.Command{ 16 Use: "nopersistentprerun", 17 Short: "Testing without PersistentPreRun hooks", 18 // PersistentPreRunE: Not specified, we need to test that it works in the absence of an explicit call 19 RunE: func(cmd *cobra.Command, args []string) error { 20 cli := dockerCli.Client() 21 ping, err := cli.Ping(context.Background()) 22 if err != nil { 23 return err 24 } 25 fmt.Println(ping.APIVersion) 26 return nil 27 }, 28 } 29 return cmd 30 }, 31 manager.Metadata{ 32 SchemaVersion: "0.1.0", 33 Vendor: "Docker Inc.", 34 Version: "testing", 35 }) 36 }