From 950658bbb63480de254a166bdeaef1fc8b8fe644 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 24 Jan 2017 15:41:45 +0100 Subject: [PATCH] Add "src" alias for `--secret` This patch adds a "src" alias for `--secret` to be consistent with `--mount`. Signed-off-by: Sebastiaan van Stijn --- opts/secret.go | 2 +- opts/secret_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/opts/secret.go b/opts/secret.go index b77a33f685..1fefcf8434 100644 --- a/opts/secret.go +++ b/opts/secret.go @@ -50,7 +50,7 @@ func (o *SecretOpt) Set(value string) error { value := parts[1] switch key { - case "source": + case "source", "src": options.Source = value case "target": tDir, _ := filepath.Split(value) diff --git a/opts/secret_test.go b/opts/secret_test.go index ce4418a0bc..d978c86e22 100644 --- a/opts/secret_test.go +++ b/opts/secret_test.go @@ -35,6 +35,18 @@ func TestSecretOptionsSourceTarget(t *testing.T) { assert.Equal(t, req.Target, "testing") } +func TestSecretOptionsShorthand(t *testing.T) { + var opt SecretOpt + + testCase := "src=foo,target=testing" + assert.NilError(t, opt.Set(testCase)) + + reqs := opt.Value() + assert.Equal(t, len(reqs), 1) + req := reqs[0] + assert.Equal(t, req.Source, "foo") +} + func TestSecretOptionsCustomUidGid(t *testing.T) { var opt SecretOpt