You've already forked dcmerge
feat: support service.command
This patch extends dcmerge to support the command attribut of a defined service.
For example:
```yaml
services:
busybox
command: [ "/usr/bin/cp", "--recursive", "--force", "/tmp/bar.txt", "/tmp/foo.txt"]
image: library/busybox:latest
```
The command attribute is interpreted as a whole. This means that individual
arguments are not merged as a comparison, as this would change the meaning of
the command attribute.
This commit is contained in:
@@ -301,6 +301,7 @@ func TestService_Equal(t *testing.T) {
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.Service{
|
||||
Command: []string{},
|
||||
CapabilitiesAdd: []string{},
|
||||
CapabilitiesDrop: []string{},
|
||||
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||
@@ -316,6 +317,7 @@ func TestService_Equal(t *testing.T) {
|
||||
Volumes: []string{},
|
||||
},
|
||||
equalableB: &dockerCompose.Service{
|
||||
Command: []string{},
|
||||
CapabilitiesAdd: []string{},
|
||||
CapabilitiesDrop: []string{},
|
||||
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||
@@ -332,6 +334,15 @@ func TestService_Equal(t *testing.T) {
|
||||
},
|
||||
expectedResult: true,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
equalableB: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
expectedResult: true,
|
||||
},
|
||||
{
|
||||
equalableA: &dockerCompose.Service{
|
||||
CapabilitiesAdd: []string{"NET_ADMIN"},
|
||||
@@ -636,6 +647,52 @@ func TestService_MergeExistingWin(t *testing.T) {
|
||||
expectedService: &dockerCompose.Service{},
|
||||
},
|
||||
|
||||
// Command
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{""},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
|
||||
// CapabilitiesAdd
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
@@ -1620,6 +1677,52 @@ func TestService_MergeLastWin(t *testing.T) {
|
||||
expectedService: &dockerCompose.Service{},
|
||||
},
|
||||
|
||||
// Command
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
Command: []string{"/usr/bin/cp", "--recursive", "/tmp/foo.txt", "/tmp/bar.txt"},
|
||||
},
|
||||
serviceDeploymentB: &dockerCompose.Service{
|
||||
Command: []string{""},
|
||||
},
|
||||
expectedService: &dockerCompose.Service{
|
||||
Command: []string{""},
|
||||
},
|
||||
},
|
||||
|
||||
// CapabilitiesAdd
|
||||
{
|
||||
serviceDeploymentA: &dockerCompose.Service{
|
||||
|
||||
Reference in New Issue
Block a user