Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Revert "The current ParseCommand assumes that only one command and si…
Browse files Browse the repository at this point in the history
…ngle"

This reverts commit efe2c4a.
  • Loading branch information
mkilpatrick committed Nov 27, 2019
1 parent efe2c4a commit 8edae99
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
9 changes: 0 additions & 9 deletions commandline/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package commandline

import (
"fmt"
"strings"
)

const quotes = "quotes"
Expand Down Expand Up @@ -71,11 +70,3 @@ func ParseCommand(cmd string) (string, []string, error) {

return args[0], args[1:], nil
}

func TokenizeCommand(cmd string) ([]string) {
return strings.FieldsFunc(cmd, isSpaceOrTab)
}

func isSpaceOrTab(r rune) bool {
return r == ' ' || r == '\t';
}
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/docker/go-connections v0.3.0 // indirect
github.com/docker/go-units v0.3.2 // indirect
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4
github.com/ebuchman/go-shell-pipes v0.0.0-20150412091402-83e132480862
github.com/fatih/color v1.6.0
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a // indirect
Expand Down Expand Up @@ -57,5 +56,3 @@ require (
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3
)

go 1.13
4 changes: 1 addition & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.6.2+incompatible h1:4FI6af79dfCS/CYb+RRtkSHw3q1L/bnDjG1PcPZtQhM=
github.com/docker/distribution v2.6.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1 h1:5VBhsO6ckUxB0A8CE5LlUJdXzik9cbEbBTQ/ggeml7M=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o=
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.2 h1:Kjm80apys7gTtfVmCvVY8gwu10uofaFSrmAKOVrtueE=
github.com/docker/go-units v0.3.2/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 h1:qk/FSDDxo05wdJH28W+p5yivv7LuLYLRXPPD8KQCtZs=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/ebuchman/go-shell-pipes v0.0.0-20150412091402-83e132480862 h1:UdoFAkqVuHxDOaAUR/7Fkq/NZbswHya30diyAKCq4z0=
github.com/ebuchman/go-shell-pipes v0.0.0-20150412091402-83e132480862/go.mod h1:IwOyG/0EgKg/s4V9ToqEXvObxu7iIU+/d0M4mvAowJc=
github.com/fatih/color v1.6.0 h1:66qjqZk8kalYAvDRtM1AdAJQI0tj4Wrue3Eq3B3pmFU=
github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
Expand Down
16 changes: 9 additions & 7 deletions services/backends/commandline/buildandrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/theothertomelliott/gopsutil-nocgo/process"
"github.com/yext/edward/commandline"
"github.com/yext/edward/services"
"github.com/ebuchman/go-shell-pipes"
)

type buildandrun struct {
Expand Down Expand Up @@ -181,16 +180,19 @@ func (b *buildandrun) Stop(workingDir string, getenv func(string) string) ([]byt

var out []byte
if b.Backend.Commands.Stop != "" {
cmdTokens := commandline.TokenizeCommand(b.Backend.Commands.Stop)
byteString, err := pipes.RunStrings(cmdTokens...)
cmd, err := commandline.ConstructCommand(workingDir, b.Service.Path, b.Backend.Commands.Stop, getenv)
if err != nil {
return nil, errors.WithStack(err)
}

out, err = cmd.CombinedOutput()
if err != nil {
return []byte(byteString), errors.WithStack(err)
return out, errors.WithStack(err)
}

if b.waitForCompletionWithTimeout(1 * time.Second) {
return []byte(byteString), nil
}
if b.waitForCompletionWithTimeout(1 * time.Second) {
return out, nil
}
}

err := InterruptGroup(b.cmd.Process.Pid, b.Service)
Expand Down

0 comments on commit 8edae99

Please sign in to comment.