diff --git a/go.mod b/go.mod index ee13905b..855d5ba3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( dario.cat/mergo v1.0.0 github.com/Jeffail/gabs/v2 v2.7.0 - github.com/bmc-toolbox/common v0.0.0-20240805193945-ce25765471a7 + github.com/bmc-toolbox/common v0.0.0-20240806132831-ba8adc6a35e3 github.com/bombsimon/logrusr/v2 v2.0.1 github.com/ghodss/yaml v1.0.0 github.com/go-logr/logr v1.4.1 diff --git a/go.sum b/go.sum index 293092a1..c6c8301e 100644 --- a/go.sum +++ b/go.sum @@ -6,10 +6,10 @@ github.com/VictorLowther/simplexml v0.0.0-20180716164440-0bff93621230 h1:t95Grn2 github.com/VictorLowther/simplexml v0.0.0-20180716164440-0bff93621230/go.mod h1:t2EzW1qybnPDQ3LR/GgeF0GOzHUXT5IVMLP2gkW1cmc= github.com/VictorLowther/soap v0.0.0-20150314151524-8e36fca84b22 h1:a0MBqYm44o0NcthLKCljZHe1mxlN6oahCQHHThnSwB4= github.com/VictorLowther/soap v0.0.0-20150314151524-8e36fca84b22/go.mod h1:/B7V22rcz4860iDqstGvia/2+IYWXf3/JdQCVd/1D2A= -github.com/bmc-toolbox/common v0.0.0-20240723135842-8256ba794af8 h1:KK812W5Tpk0n5qcS0vZ0IYqhoZNkV66NuCIon99OGQ8= -github.com/bmc-toolbox/common v0.0.0-20240723135842-8256ba794af8/go.mod h1:Cdnkm+edb6C0pVkyCrwh3JTXAe0iUF9diDG/DztPI9I= github.com/bmc-toolbox/common v0.0.0-20240805193945-ce25765471a7 h1:+NcnInwZxn25daBCb3d1y3x9QF23uob1ghdiimj2Dwo= github.com/bmc-toolbox/common v0.0.0-20240805193945-ce25765471a7/go.mod h1:Cdnkm+edb6C0pVkyCrwh3JTXAe0iUF9diDG/DztPI9I= +github.com/bmc-toolbox/common v0.0.0-20240806132831-ba8adc6a35e3 h1:/BjZSX/sphptIdxpYo4wxAQkgMLyMMgfdl48J9DKNeE= +github.com/bmc-toolbox/common v0.0.0-20240806132831-ba8adc6a35e3/go.mod h1:Cdnkm+edb6C0pVkyCrwh3JTXAe0iUF9diDG/DztPI9I= github.com/bombsimon/logrusr/v2 v2.0.1 h1:1VgxVNQMCvjirZIYaT9JYn6sAVGVEcNtRE0y4mvaOAM= github.com/bombsimon/logrusr/v2 v2.0.1/go.mod h1:ByVAX+vHdLGAfdroiMg6q0zgq2FODY2lc5YJvzmOJio= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 48e202ca..e22ec6d2 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -16,17 +16,9 @@ type Executor interface { ExecWithContext(context.Context) (*Result, error) SetArgs([]string) SetEnv([]string) - SetQuiet() - SetVerbose() GetCmd() string - DisableBinCheck() - SetStdin(io.Reader) - CmdPath() string CheckExecutable() error - // for tests SetStdout([]byte) - SetStderr([]byte) - SetExitCode(int) } func NewExecutor(cmd string) Executor { @@ -58,12 +50,6 @@ func (e *Execute) GetCmd() string { return strings.Join(cmd, " ") } -// CmdPath returns the absolute path to the executable -// this means the caller should not have disabled CheckBin. -func (e *Execute) CmdPath() string { - return e.Cmd -} - // SetArgs sets the command args func (e *Execute) SetArgs(a []string) { e.Args = a @@ -74,38 +60,10 @@ func (e *Execute) SetEnv(env []string) { e.Env = env } -// SetQuiet lowers the verbosity -func (e *Execute) SetQuiet() { - e.Quiet = true -} - -// SetVerbose does whats it says -func (e *Execute) SetVerbose() { - e.Quiet = false -} - -// SetStdin sets the reader to the command stdin -func (e *Execute) SetStdin(r io.Reader) { - e.Stdin = r -} - -// DisableBinCheck disables validating the binary exists and is executable -func (e *Execute) DisableBinCheck() { - e.CheckBin = false -} - // SetStdout doesn't do much, is around for tests func (e *Execute) SetStdout(_ []byte) { } -// SetStderr doesn't do much, is around for tests -func (e *Execute) SetStderr(_ []byte) { -} - -// SetExitCode doesn't do much, is around for tests -func (e *Execute) SetExitCode(_ int) { -} - // ExecWithContext executes the command and returns the Result object func (e *Execute) ExecWithContext(ctx context.Context) (result *Result, err error) { if e.CheckBin { diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index fa1c6e93..87079c84 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -17,7 +17,6 @@ func Test_Stdin(t *testing.T) { e.Cmd = "grep" e.Args = []string{"hello"} e.Stdin = bytes.NewReader([]byte("hello")) - e.SetQuiet() result, err := e.ExecWithContext(context.Background()) if err != nil { diff --git a/internal/sum/sum.go b/internal/sum/sum.go index 0eb28179..b643a959 100644 --- a/internal/sum/sum.go +++ b/internal/sum/sum.go @@ -68,7 +68,6 @@ func New(host, user, pass string, opts ...Option) (*Sum, error) { e := ex.NewExecutor(sum.SumPath) e.SetEnv([]string{"LC_ALL=C.UTF-8"}) - // e.SetQuiet() sum.Executor = e return sum, nil