mirror of https://github.com/docker/cli.git
Add merge to ShellCommand properties in config
Signed-off-by: Stoica-Marcu Floris-Andrei <floris.sm@gmail.com>
This commit is contained in:
parent
fbea85d472
commit
cff702d889
|
@ -59,6 +59,7 @@ func mergeServices(base, override []types.ServiceConfig) ([]types.ServiceConfig,
|
||||||
reflect.TypeOf([]types.ServiceConfigObjConfig{}): mergeSlice(toServiceConfigObjConfigsMap, toSServiceConfigObjConfigsSlice),
|
reflect.TypeOf([]types.ServiceConfigObjConfig{}): mergeSlice(toServiceConfigObjConfigsMap, toSServiceConfigObjConfigsSlice),
|
||||||
reflect.TypeOf(&types.UlimitsConfig{}): mergeUlimitsConfig,
|
reflect.TypeOf(&types.UlimitsConfig{}): mergeUlimitsConfig,
|
||||||
reflect.TypeOf([]types.ServiceVolumeConfig{}): mergeSlice(toServiceVolumeConfigsMap, toServiceVolumeConfigsSlice),
|
reflect.TypeOf([]types.ServiceVolumeConfig{}): mergeSlice(toServiceVolumeConfigsMap, toServiceVolumeConfigsSlice),
|
||||||
|
reflect.TypeOf(types.ShellCommand{}): mergeShellCommand,
|
||||||
reflect.TypeOf(&types.ServiceNetworkConfig{}): mergeServiceNetworkConfig,
|
reflect.TypeOf(&types.ServiceNetworkConfig{}): mergeServiceNetworkConfig,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -235,9 +236,9 @@ func mergeUlimitsConfig(dst, src reflect.Value) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: unparam
|
//nolint: unparam
|
||||||
func mergeServiceVolumeConfig(dst, src reflect.Value) error {
|
func mergeShellCommand(dst, src reflect.Value) error {
|
||||||
if dst.Elem().FieldByName("target").String() == src.Elem().FieldByName("target").String() {
|
if src.Len() != 0 {
|
||||||
dst.Set(src.Elem())
|
dst.Set(src)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1017,6 +1017,59 @@ func TestLoadMultipleNetworks(t *testing.T) {
|
||||||
}, config)
|
}, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadMultipleServiceCommands(t *testing.T) {
|
||||||
|
base := map[string]interface{}{
|
||||||
|
"version": "3.7",
|
||||||
|
"services": map[string]interface{}{
|
||||||
|
"foo": map[string]interface{}{
|
||||||
|
"image": "baz",
|
||||||
|
"command": "foo bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"volumes": map[string]interface{}{},
|
||||||
|
"networks": map[string]interface{}{},
|
||||||
|
"secrets": map[string]interface{}{},
|
||||||
|
"configs": map[string]interface{}{},
|
||||||
|
}
|
||||||
|
override := map[string]interface{}{
|
||||||
|
"version": "3.7",
|
||||||
|
"services": map[string]interface{}{
|
||||||
|
"foo": map[string]interface{}{
|
||||||
|
"image": "baz",
|
||||||
|
"command": "foo baz",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"volumes": map[string]interface{}{},
|
||||||
|
"networks": map[string]interface{}{},
|
||||||
|
"secrets": map[string]interface{}{},
|
||||||
|
"configs": map[string]interface{}{},
|
||||||
|
}
|
||||||
|
configDetails := types.ConfigDetails{
|
||||||
|
ConfigFiles: []types.ConfigFile{
|
||||||
|
{Filename: "base.yml", Config: base},
|
||||||
|
{Filename: "override.yml", Config: override},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
config, err := Load(configDetails)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.DeepEqual(t, &types.Config{
|
||||||
|
Filename: "base.yml",
|
||||||
|
Version: "3.7",
|
||||||
|
Services: []types.ServiceConfig{
|
||||||
|
{
|
||||||
|
Name: "foo",
|
||||||
|
Image: "baz",
|
||||||
|
Command: types.ShellCommand{"foo", "baz"},
|
||||||
|
Environment: types.MappingWithEquals{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Volumes: map[string]types.VolumeConfig{},
|
||||||
|
Secrets: map[string]types.SecretConfig{},
|
||||||
|
Configs: map[string]types.ConfigObjConfig{},
|
||||||
|
Networks: map[string]types.NetworkConfig{},
|
||||||
|
}, config)
|
||||||
|
}
|
||||||
|
|
||||||
func TestLoadMultipleServiceVolumes(t *testing.T) {
|
func TestLoadMultipleServiceVolumes(t *testing.T) {
|
||||||
base := map[string]interface{}{
|
base := map[string]interface{}{
|
||||||
"version": "3.7",
|
"version": "3.7",
|
||||||
|
|
Loading…
Reference in New Issue