Merge pull request #6768 from vrothberg/fix-6766

generate systemd: improve pod-flags filter
This commit is contained in:
OpenShift Merge Robot
2020-06-29 04:56:31 -04:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,8 @@
package generate
import (
"strings"
"github.com/pkg/errors"
)
@ -44,6 +46,9 @@ func filterPodFlags(command []string) []string {
i++
continue
}
if strings.HasPrefix(s, "--pod=") || strings.HasPrefix(s, "--pod-id-file=") {
continue
}
processed = append(processed, s)
}
return processed

View File

@ -1,6 +1,7 @@
package generate
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
@ -14,12 +15,16 @@ func TestFilterPodFlags(t *testing.T) {
{[]string{"podman", "pod", "create"}},
{[]string{"podman", "pod", "create", "--name", "foo"}},
{[]string{"podman", "pod", "create", "--pod-id-file", "foo"}},
{[]string{"podman", "pod", "create", "--pod-id-file=foo"}},
{[]string{"podman", "run", "--pod", "foo"}},
{[]string{"podman", "run", "--pod=foo"}},
}
for _, test := range tests {
processed := filterPodFlags(test.input)
assert.NotContains(t, processed, "--pod-id-file")
assert.NotContains(t, processed, "--pod")
for _, s := range processed {
assert.False(t, strings.HasPrefix(s, "--pod-id-file"))
assert.False(t, strings.HasPrefix(s, "--pod"))
}
}
}