Skip to content

Commit

Permalink
do not use interactive mode if stdin is a file, #31
Browse files Browse the repository at this point in the history
  • Loading branch information
kovetskiy committed Jun 24, 2021
1 parent 4a19883 commit 376244e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
7 changes: 6 additions & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ func runRemoteExecutionNode(
ssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
}

err := remoteCommand.(*runcmd.RemoteCmd).GetSession().RequestPty("xterm", 40, 80, modes)
err := remoteCommand.(*runcmd.RemoteCmd).GetSession().RequestPty(
"xterm",
40,
80,
modes,
)
if err != nil {
return nil, karma.Format(
err,
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ require (
github.com/reconquest/barely v0.0.0-20160729074550-0f12e3bb2e13
github.com/reconquest/colorgful v0.0.0-20190805091748-28d18b838c4a
github.com/reconquest/hierr-go v0.0.0-20170824213838-7d09c0176fd2
github.com/reconquest/karma-go v0.0.0-20200326104714-79480464fdb5
github.com/reconquest/karma-go v0.0.0-20200928103525-22da92476de6
github.com/reconquest/lineflushwriter-go v0.0.0-20200617113125-f7349730c72d
github.com/reconquest/loreley v0.0.0-20200601121626-621c1cd37fd1
github.com/reconquest/nopio-go v0.0.0-20161213101805-20796acb207f // indirect
github.com/reconquest/prefixwriter-go v0.0.0-20160818100856-f514fb348765
github.com/reconquest/runcmd v0.0.0-20200630085320-e45566d1097c
github.com/youmark/pkcs8 v0.0.0-20200520070018-fad002e585ce
github.com/zazab/zhash v0.0.0-20170403032415-ad45b89afe7a // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
)

replace github.com/reconquest/runcmd => /home/operator/go/src/github.com/reconquest/runcmd
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/reconquest/hierr-go v0.0.0-20170824213838-7d09c0176fd2 h1:v3ctQXyIHpr
github.com/reconquest/hierr-go v0.0.0-20170824213838-7d09c0176fd2/go.mod h1:dF8sYs86hXr+kKjDVvxDZYMUsTm5yr0PFQqLer/xsrk=
github.com/reconquest/karma-go v0.0.0-20200326104714-79480464fdb5 h1:zDWjDur+l8W6pKksuc1VdKcdYrfHrTO9jRN131XoG1g=
github.com/reconquest/karma-go v0.0.0-20200326104714-79480464fdb5/go.mod h1:oTXKs9J7KQ1gCpnvSwCbH9vlvELZFfUSbEbrr2ABeo0=
github.com/reconquest/karma-go v0.0.0-20200928103525-22da92476de6 h1:R2eR77EaZCxUQnVZcMbMOmxPMxRqkiYtF5jMjKOrvrE=
github.com/reconquest/karma-go v0.0.0-20200928103525-22da92476de6/go.mod h1:yuQiKpTdmXSX7E+h+3dD4jx09P/gHc67mRxN3eFLt7o=
github.com/reconquest/lineflushwriter-go v0.0.0-20200617113125-f7349730c72d h1:fQnunwvkgVfr6IOe06+SRnQ9v83nc98+izA83DZKvRQ=
github.com/reconquest/lineflushwriter-go v0.0.0-20200617113125-f7349730c72d/go.mod h1:tpO+vNC9ppBvJErZXrQpfwiVDuza5k1nRWH7SrutKtY=
github.com/reconquest/loreley v0.0.0-20200601121626-621c1cd37fd1 h1:J1vuEtEaaHo01+gxE6jIMtTwLrYzsraHmnqbNvha2Jw=
Expand All @@ -39,11 +41,22 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c h1:jceGD5YNJGgGMkJz79agzOln1K9TaZUjv5ird16qniQ=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ func formatUsage(template string) (string, error) {

func handleEvaluate(args map[string]interface{}) error {
var (
stdin, _ = args["--stdin"].(string)
rootDir, _ = args["--root"].(string)
sudo = args["--sudo"].(bool)
shell = args["--shell"].(string)
serial = args["--serial"].(bool)
stdin, hasStdin = args["--stdin"].(string)
rootDir, _ = args["--root"].(string)
sudo = args["--sudo"].(bool)
shell = args["--shell"].(string)
serial = args["--serial"].(bool)

command = args["<command>"].([]string)
)
Expand All @@ -354,7 +354,7 @@ func handleEvaluate(args map[string]interface{}) error {
command: command,
directory: rootDir,
serial: serial,
term: true,
term: !hasStdin,
}

return run(cluster, runner, stdin)
Expand Down Expand Up @@ -386,13 +386,16 @@ func run(
)
}

defer inputFile.Close()

_, err = io.Copy(execution.stdin, inputFile)
if err != nil {
return hierr.Errorf(
err,
`can't copy input file to the execution processes`,
)
}

}

debugf(`commands are running, waiting for finish`)
Expand Down

0 comments on commit 376244e

Please sign in to comment.