-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Ian Campbell
committed
Feb 25, 2019
1 parent
4eb642b
commit 20439aa
Showing
10 changed files
with
184 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"auths": {}, | ||
"plugins": { | ||
"plugin1": { | ||
"data1": "some replacement string", | ||
"data3": "some additional string" | ||
}, | ||
"plugin3": { | ||
"data5": "a new plugin" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cliplugins | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/docker/cli/cli/config" | ||
"gotest.tools/assert" | ||
"gotest.tools/icmd" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
run, cfg, cleanup := prepare(t) | ||
defer cleanup() | ||
|
||
cfg.SetPluginConfig("helloworld", "who", "Cambridge") | ||
err := cfg.Save() | ||
assert.NilError(t, err) | ||
|
||
res := icmd.RunCmd(run("helloworld")) | ||
res.Assert(t, icmd.Expected{ | ||
ExitCode: 0, | ||
Out: "Hello Cambridge!", | ||
}) | ||
|
||
cfg2, err := config.Load(filepath.Dir(cfg.GetFilename())) | ||
assert.NilError(t, err) | ||
assert.DeepEqual(t, cfg2.Plugins, map[string]map[string]string{ | ||
"helloworld": { | ||
"who": "Cambridge", | ||
"lastwho": "Cambridge", | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.