-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscript_runner.go
44 lines (36 loc) · 1.03 KB
/
script_runner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package miniconda
import (
"fmt"
"github.com/paketo-buildpacks/packit/v2/pexec"
)
//go:generate faux --interface Executable --output fakes/executable.go
// Executable defines the interface for invoking an executable.
type Executable interface {
Execute(execution pexec.Execution) error
}
// ScriptRunner implements the Runner interface
type ScriptRunner struct {
executable Executable
}
// NewScriptRunner creates an instance of the ScriptRunner given an Executable that runs `bash`.
func NewScriptRunner(executable Executable) ScriptRunner {
return ScriptRunner{
executable: executable,
}
}
// Run invokes the miniconda script located in the given runPath, which
// installs conda into the a layer path designated by condaLayerPath.
func (s ScriptRunner) Run(runPath, condaLayerPath string) error {
err := s.executable.Execute(pexec.Execution{
Args: []string{
runPath,
"-b",
"-f",
"-p", condaLayerPath,
},
})
if err != nil {
return fmt.Errorf("failed while running miniconda install script: %w", err)
}
return nil
}