1
0
mirror of https://github.com/docker/cli.git synced 2025-08-29 00:47:54 +03:00

Simplify cli plugin config file entry

Make it a simple `map[string]string` for now.

Added a unit test for it.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell
2019-02-18 11:49:41 +00:00
parent 4eb642be46
commit 20439aa662
10 changed files with 185 additions and 85 deletions

View File

@@ -41,12 +41,21 @@ func main() {
// the path where a plugin overrides this
// hook.
PersistentPreRunE: plugin.PersistentPreRunE,
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
if 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()
},
}
flags := cmd.Flags()
flags.StringVar(&who, "who", "World", "Who are we addressing?")
flags.StringVar(&who, "who", "", "Who are we addressing?")
cmd.AddCommand(goodbye, apiversion)
return cmd