|
@@ -12,24 +12,24 @@ import (
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
|
- plugin.Run(func(dockerCli command.Cli) *cobra.Command {
|
|
|
+ plugin.Run(func(dockerCLI command.Cli) *cobra.Command {
|
|
|
goodbye := &cobra.Command{
|
|
|
Use: "goodbye",
|
|
|
Short: "Say Goodbye instead of Hello",
|
|
|
Run: func(cmd *cobra.Command, _ []string) {
|
|
|
- fmt.Fprintln(dockerCli.Out(), "Goodbye World!")
|
|
|
+ _, _ = fmt.Fprintln(dockerCLI.Out(), "Goodbye World!")
|
|
|
},
|
|
|
}
|
|
|
apiversion := &cobra.Command{
|
|
|
Use: "apiversion",
|
|
|
Short: "Print the API version of the server",
|
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
|
- cli := dockerCli.Client()
|
|
|
- ping, err := cli.Ping(context.Background())
|
|
|
+ apiClient := dockerCLI.Client()
|
|
|
+ ping, err := apiClient.Ping(context.Background())
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- fmt.Println(ping.APIVersion)
|
|
|
+ _, _ = fmt.Println(ping.APIVersion)
|
|
|
return nil
|
|
|
},
|
|
|
}
|
|
@@ -38,7 +38,7 @@ func main() {
|
|
|
Use: "exitstatus2",
|
|
|
Short: "Exit with status 2",
|
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
|
- fmt.Fprintln(dockerCli.Err(), "Exiting with error status 2")
|
|
|
+ _, _ = fmt.Fprintln(dockerCLI.Err(), "Exiting with error status 2")
|
|
|
os.Exit(2)
|
|
|
return nil
|
|
|
},
|
|
@@ -56,33 +56,33 @@ func main() {
|
|
|
return err
|
|
|
}
|
|
|
if preRun {
|
|
|
- fmt.Fprintf(dockerCli.Err(), "Plugin PersistentPreRunE called")
|
|
|
+ _, _ = fmt.Fprintln(dockerCLI.Err(), "Plugin PersistentPreRunE called")
|
|
|
}
|
|
|
return nil
|
|
|
},
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
if debug {
|
|
|
- fmt.Fprintf(dockerCli.Err(), "Plugin debug mode enabled")
|
|
|
+ _, _ = fmt.Fprintln(dockerCLI.Err(), "Plugin debug mode enabled")
|
|
|
}
|
|
|
|
|
|
switch optContext {
|
|
|
case "Christmas":
|
|
|
- fmt.Fprintf(dockerCli.Out(), "Merry Christmas!\n")
|
|
|
+ _, _ = fmt.Fprintln(dockerCLI.Out(), "Merry Christmas!")
|
|
|
return nil
|
|
|
case "":
|
|
|
// nothing
|
|
|
}
|
|
|
|
|
|
if who == "" {
|
|
|
- who, _ = dockerCli.ConfigFile().PluginConfig("helloworld", "who")
|
|
|
+ who, _ = dockerCLI.ConfigFile().PluginConfig("helloworld", "who")
|
|
|
}
|
|
|
if who == "" {
|
|
|
who = "World"
|
|
|
}
|
|
|
|
|
|
- fmt.Fprintf(dockerCli.Out(), "Hello %s!\n", who)
|
|
|
- dockerCli.ConfigFile().SetPluginConfig("helloworld", "lastwho", who)
|
|
|
- return dockerCli.ConfigFile().Save()
|
|
|
+ _, _ = fmt.Fprintln(dockerCLI.Out(), "Hello", who)
|
|
|
+ dockerCLI.ConfigFile().SetPluginConfig("helloworld", "lastwho", who)
|
|
|
+ return dockerCLI.ConfigFile().Save()
|
|
|
},
|
|
|
}
|
|
|
|