mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-09 08:26:47 +00:00
Fix vendoring for go-execute
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
376c8e5d7b
commit
d19d8998d8
10
Gopkg.lock
generated
10
Gopkg.lock
generated
@ -37,6 +37,14 @@
|
|||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "9e921883ac929bbe515b39793ece99ce3a9d7706"
|
revision = "9e921883ac929bbe515b39793ece99ce3a9d7706"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:74860eb071d52337d67e9ffd6893b29affebd026505aa917ec23131576a91a77"
|
||||||
|
name = "github.com/alexellis/go-execute"
|
||||||
|
packages = ["pkg/v1"]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "961405ea754427780f2151adff607fa740d377f7"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:386ca0ac781cc1b630b3ed21725759770174140164b3faf3810e6ed6366a970b"
|
digest = "1:386ca0ac781cc1b630b3ed21725759770174140164b3faf3810e6ed6366a970b"
|
||||||
name = "github.com/containerd/containerd"
|
name = "github.com/containerd/containerd"
|
||||||
@ -440,7 +448,7 @@
|
|||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
input-imports = [
|
input-imports = [
|
||||||
"github.com/alexellis/go-execute",
|
"github.com/alexellis/go-execute/pkg/v1",
|
||||||
"github.com/containerd/containerd",
|
"github.com/containerd/containerd",
|
||||||
"github.com/containerd/containerd/cio",
|
"github.com/containerd/containerd/cio",
|
||||||
"github.com/containerd/containerd/containers",
|
"github.com/containerd/containerd/containers",
|
||||||
|
@ -67,17 +67,17 @@ Or get from binaries:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# For x86_64
|
# For x86_64
|
||||||
sudo curl -fSLs "https://github.com/alexellis/faasd/releases/download/0.2.0/faasd" \
|
sudo curl -fSLs "https://github.com/alexellis/faasd/releases/download/0.2.1/faasd" \
|
||||||
-o "/usr/local/bin/faasd" \
|
-o "/usr/local/bin/faasd" \
|
||||||
&& sudo chmod a+x "/usr/local/bin/faasd"
|
&& sudo chmod a+x "/usr/local/bin/faasd"
|
||||||
|
|
||||||
# armhf
|
# armhf
|
||||||
sudo curl -fSLs "https://github.com/alexellis/faasd/releases/download/0.2.0/faasd-armhf" \
|
sudo curl -fSLs "https://github.com/alexellis/faasd/releases/download/0.2.1/faasd-armhf" \
|
||||||
-o "/usr/local/bin/faasd" \
|
-o "/usr/local/bin/faasd" \
|
||||||
&& sudo chmod a+x "/usr/local/bin/faasd"
|
&& sudo chmod a+x "/usr/local/bin/faasd"
|
||||||
|
|
||||||
# arm64
|
# arm64
|
||||||
sudo curl -fSLs "https://github.com/alexellis/faasd/releases/download/0.2.0/faasd-arm64" \
|
sudo curl -fSLs "https://github.com/alexellis/faasd/releases/download/0.2.1/faasd-arm64" \
|
||||||
-o "/usr/local/bin/faasd" \
|
-o "/usr/local/bin/faasd" \
|
||||||
&& sudo chmod a+x "/usr/local/bin/faasd"
|
&& sudo chmod a+x "/usr/local/bin/faasd"
|
||||||
```
|
```
|
||||||
|
21
vendor/github.com/alexellis/go-execute/LICENSE
generated
vendored
Normal file
21
vendor/github.com/alexellis/go-execute/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Inlets
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
117
vendor/github.com/alexellis/go-execute/pkg/v1/exec.go
generated
vendored
Normal file
117
vendor/github.com/alexellis/go-execute/pkg/v1/exec.go
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
package execute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ExecTask struct {
|
||||||
|
Command string
|
||||||
|
Args []string
|
||||||
|
Shell bool
|
||||||
|
Env []string
|
||||||
|
Cwd string
|
||||||
|
|
||||||
|
// StreamStdio prints stdout and stderr directly to os.Stdout/err as
|
||||||
|
// the command runs.
|
||||||
|
StreamStdio bool
|
||||||
|
|
||||||
|
// PrintCommand prints the command before executing
|
||||||
|
PrintCommand bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExecResult struct {
|
||||||
|
Stdout string
|
||||||
|
Stderr string
|
||||||
|
ExitCode int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (et ExecTask) Execute() (ExecResult, error) {
|
||||||
|
argsSt := ""
|
||||||
|
if len(et.Args) > 0 {
|
||||||
|
argsSt = strings.Join(et.Args, " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
if et.PrintCommand {
|
||||||
|
fmt.Println("exec: ", et.Command, argsSt)
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
|
||||||
|
if et.Shell {
|
||||||
|
var args []string
|
||||||
|
if len(et.Args) == 0 {
|
||||||
|
startArgs := strings.Split(et.Command, " ")
|
||||||
|
script := strings.Join(startArgs, " ")
|
||||||
|
args = append([]string{"-c"}, fmt.Sprintf("%s", script))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
script := strings.Join(et.Args, " ")
|
||||||
|
args = append([]string{"-c"}, fmt.Sprintf("%s %s", et.Command, script))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = exec.Command("/bin/bash", args...)
|
||||||
|
} else {
|
||||||
|
if strings.Index(et.Command, " ") > 0 {
|
||||||
|
parts := strings.Split(et.Command, " ")
|
||||||
|
command := parts[0]
|
||||||
|
args := parts[1:]
|
||||||
|
cmd = exec.Command(command, args...)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cmd = exec.Command(et.Command, et.Args...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Dir = et.Cwd
|
||||||
|
|
||||||
|
if len(et.Env) > 0 {
|
||||||
|
cmd.Env = os.Environ()
|
||||||
|
for _, env := range et.Env {
|
||||||
|
cmd.Env = append(cmd.Env, env)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stdoutBuff := bytes.Buffer{}
|
||||||
|
stderrBuff := bytes.Buffer{}
|
||||||
|
|
||||||
|
var stdoutWriters io.Writer
|
||||||
|
var stderrWriters io.Writer
|
||||||
|
|
||||||
|
if et.StreamStdio {
|
||||||
|
stdoutWriters = io.MultiWriter(os.Stdout, &stdoutBuff)
|
||||||
|
stderrWriters = io.MultiWriter(os.Stderr, &stderrBuff)
|
||||||
|
} else {
|
||||||
|
stdoutWriters = &stdoutBuff
|
||||||
|
stderrWriters = &stderrBuff
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Stdout = stdoutWriters
|
||||||
|
cmd.Stderr = stderrWriters
|
||||||
|
|
||||||
|
startErr := cmd.Start()
|
||||||
|
|
||||||
|
if startErr != nil {
|
||||||
|
return ExecResult{}, startErr
|
||||||
|
}
|
||||||
|
|
||||||
|
exitCode := 0
|
||||||
|
execErr := cmd.Wait()
|
||||||
|
if execErr != nil {
|
||||||
|
if exitError, ok := execErr.(*exec.ExitError); ok {
|
||||||
|
|
||||||
|
exitCode = exitError.ExitCode()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExecResult{
|
||||||
|
Stdout: string(stdoutBuff.Bytes()),
|
||||||
|
Stderr: string(stderrBuff.Bytes()),
|
||||||
|
ExitCode: exitCode,
|
||||||
|
}, nil
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user