Move the exec helper
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
f0332b7578
commit
2a6b453fc1
7 changed files with 4 additions and 58 deletions
|
|
@ -19,7 +19,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cloudbase/garm/util/exec"
|
||||
"github.com/cloudbase/garm-provider-common/util/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -28,7 +28,6 @@ require (
|
|||
golang.org/x/crypto v0.7.0
|
||||
golang.org/x/oauth2 v0.8.0
|
||||
golang.org/x/sync v0.1.0
|
||||
golang.org/x/sys v0.8.0
|
||||
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gorm.io/datatypes v1.1.1
|
||||
|
|
@ -99,6 +98,7 @@ require (
|
|||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/term v0.8.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
|
|
|
|||
2
runner/providers/external/external.go
vendored
2
runner/providers/external/external.go
vendored
|
|
@ -12,10 +12,10 @@ import (
|
|||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
|
||||
garmErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
garmExec "github.com/cloudbase/garm-provider-common/util/exec"
|
||||
"github.com/cloudbase/garm/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
garmExec "github.com/cloudbase/garm/util/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
package exec
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func Exec(ctx context.Context, providerBin string, stdinData []byte, environ []string) ([]byte, error) {
|
||||
stdout := &bytes.Buffer{}
|
||||
stderr := &bytes.Buffer{}
|
||||
c := exec.CommandContext(ctx, providerBin)
|
||||
c.Env = environ
|
||||
c.Stdin = bytes.NewBuffer(stdinData)
|
||||
c.Stdout = stdout
|
||||
c.Stderr = stderr
|
||||
|
||||
if err := c.Run(); err != nil {
|
||||
return nil, errors.Wrapf(err, "provider binary failed with stdout: %s; stderr: %s", stdout.String(), stderr.String())
|
||||
}
|
||||
|
||||
return stdout.Bytes(), nil
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package exec
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func IsExecutable(path string) bool {
|
||||
return unix.Access(path, unix.X_OK) == nil
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package exec
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IsExecutable(path string) bool {
|
||||
pathExt := os.Getenv("PATHEXT")
|
||||
execList := strings.Split(pathExt, ";")
|
||||
for _, ext := range execList {
|
||||
if strings.HasSuffix(path, ext) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
|
|
@ -42,6 +42,7 @@ github.com/cloudbase/garm-provider-common/errors
|
|||
github.com/cloudbase/garm-provider-common/execution
|
||||
github.com/cloudbase/garm-provider-common/params
|
||||
github.com/cloudbase/garm-provider-common/util
|
||||
github.com/cloudbase/garm-provider-common/util/exec
|
||||
# github.com/cloudflare/circl v1.3.3
|
||||
## explicit; go 1.19
|
||||
github.com/cloudflare/circl/dh/x25519
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue