mirror of https://github.com/docker/cli.git
Default config/secret target to source name
When using advanced syntax for setting config and secret values, default the target value to the source value when the user does not specify a target. Signed-off-by: Nick Adcock <nick.adcock@docker.com>
This commit is contained in:
parent
4c2d7b7f70
commit
9698b7a374
|
@ -72,6 +72,9 @@ func (o *ConfigOpt) Set(value string) error {
|
||||||
if options.ConfigName == "" {
|
if options.ConfigName == "" {
|
||||||
return fmt.Errorf("source is required")
|
return fmt.Errorf("source is required")
|
||||||
}
|
}
|
||||||
|
if options.File.Name == "" {
|
||||||
|
options.File.Name = options.ConfigName
|
||||||
|
}
|
||||||
|
|
||||||
o.values = append(o.values, options)
|
o.values = append(o.values, options)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestConfigOptionsSource(t *testing.T) {
|
||||||
assert.Assert(t, is.Len(reqs, 1))
|
assert.Assert(t, is.Len(reqs, 1))
|
||||||
req := reqs[0]
|
req := reqs[0]
|
||||||
assert.Check(t, is.Equal("foo", req.ConfigName))
|
assert.Check(t, is.Equal("foo", req.ConfigName))
|
||||||
|
assert.Check(t, is.Equal("foo", req.File.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfigOptionsSourceTarget(t *testing.T) {
|
func TestConfigOptionsSourceTarget(t *testing.T) {
|
||||||
|
|
|
@ -72,6 +72,9 @@ func (o *SecretOpt) Set(value string) error {
|
||||||
if options.SecretName == "" {
|
if options.SecretName == "" {
|
||||||
return fmt.Errorf("source is required")
|
return fmt.Errorf("source is required")
|
||||||
}
|
}
|
||||||
|
if options.File.Name == "" {
|
||||||
|
options.File.Name = options.SecretName
|
||||||
|
}
|
||||||
|
|
||||||
o.values = append(o.values, options)
|
o.values = append(o.values, options)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestSecretOptionsSource(t *testing.T) {
|
||||||
assert.Assert(t, is.Len(reqs, 1))
|
assert.Assert(t, is.Len(reqs, 1))
|
||||||
req := reqs[0]
|
req := reqs[0]
|
||||||
assert.Check(t, is.Equal("foo", req.SecretName))
|
assert.Check(t, is.Equal("foo", req.SecretName))
|
||||||
|
assert.Check(t, is.Equal("foo", req.File.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSecretOptionsSourceTarget(t *testing.T) {
|
func TestSecretOptionsSourceTarget(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue