fix command to accept variadic args
This commit is contained in:
parent
8b6475b8d4
commit
76b4e78a6a
@ -55,12 +55,10 @@ type ReadOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithCommand specifies the command to execute
|
// WithCommand specifies the command to execute
|
||||||
func WithCommand(c string, args ...string) CreateOption {
|
func WithCommand(args ...string) CreateOption {
|
||||||
return func(o *CreateOptions) {
|
return func(o *CreateOptions) {
|
||||||
// set command
|
// set command
|
||||||
o.Command = []string{c}
|
o.Command = args
|
||||||
// set args
|
|
||||||
o.Command = append(o.Command, args...)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +33,8 @@ func toService(s *pb.Service) *runtime.Service {
|
|||||||
func toCreateOptions(opts *pb.CreateOptions) []runtime.CreateOption {
|
func toCreateOptions(opts *pb.CreateOptions) []runtime.CreateOption {
|
||||||
options := []runtime.CreateOption{}
|
options := []runtime.CreateOption{}
|
||||||
// command options
|
// command options
|
||||||
l := len(opts.Command)
|
if len(opts.Command) > 0 {
|
||||||
if l == 1 {
|
options = append(options, runtime.WithCommand(opts.Command...))
|
||||||
options = append(options, runtime.WithCommand(opts.Command[0]))
|
|
||||||
}
|
|
||||||
if l > 1 {
|
|
||||||
options = append(options, runtime.WithCommand(opts.Command[0], opts.Command[1:]...))
|
|
||||||
}
|
}
|
||||||
// env options
|
// env options
|
||||||
if len(opts.Env) > 0 {
|
if len(opts.Env) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user