Let single line command be a single command (#1009)

* rm go-shlex usage

* update
This commit is contained in:
6543 2022-07-19 07:20:27 +02:00 committed by GitHub
parent c3eed4ec01
commit 69ec44075c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 11 deletions

1
go.mod
View file

@ -11,7 +11,6 @@ require (
github.com/docker/docker v20.10.14+incompatible
github.com/docker/go-units v0.4.0
github.com/drone/envsubst v1.0.3
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf
github.com/gin-gonic/gin v1.7.7
github.com/go-ap/httpsig v0.0.0-20210714162115-62a09257db51

2
go.sum
View file

@ -143,8 +143,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf h1:NrF81UtW8gG2LBGkXFQFqlfNnvMt9WdB46sfdJY4oqc=
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo=

View file

@ -72,7 +72,7 @@ func TestUnmarshalContainer(t *testing.T) {
},
CapAdd: []string{"ALL"},
CapDrop: []string{"NET_ADMIN", "SYS_ADMIN"},
Command: types.Command{"bundle", "exec", "thin", "-p", "3000"},
Command: types.Command{"bundle exec thin -p 3000"},
Commands: types.Stringorslice{"go build", "go test"},
CPUQuota: types.StringorInt(11),
CPUSet: "1,2",

View file

@ -5,8 +5,6 @@ import (
"fmt"
"github.com/docker/docker/api/types/strslice"
// TODO: search for maintained
"github.com/flynn/go-shlex"
)
// Command represents a docker command, can be a string or an array of strings.
@ -16,11 +14,7 @@ type Command strslice.StrSlice
func (s *Command) UnmarshalYAML(unmarshal func(interface{}) error) error {
var stringType string
if err := unmarshal(&stringType); err == nil {
parts, err := shlex.Split(stringType)
if err != nil {
return err
}
*s = parts
*s = []string{stringType}
return nil
}

View file

@ -37,6 +37,11 @@ func TestUnmarshalCommand(t *testing.T) {
- sleep 3s`), s3)
assert.Nil(t, err)
assert.Equal(t, Command{`echo AAA; echo "wow"`, `sleep 3s`}, s3.Command)
s4 := &StructCommand{}
err = yaml.Unmarshal([]byte(`command: echo AAA; echo "wow"`), s4)
assert.Nil(t, err)
assert.Equal(t, Command{`echo AAA; echo "wow"`}, s4.Command)
}
var sampleEmptyCommand = `{}`