Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pkg/devcontainer/crane/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ type Content struct {
Files map[string]string `json:"files"`
}

type command struct {
type Command struct {
cmd string
args []string
}

func New(cmd string) *command {
newCommand := &command{cmd: getBinName()}
func New(cmd string) *Command {
newCommand := &Command{cmd: getBinName()}
return newCommand.WithArg(cmd)
}

func (c *command) WithFlag(flag, val string) *command {
func (c *Command) WithFlag(flag, val string) *Command {
c.args = append(c.args, flag, val)
return c
}

func (c *command) WithArg(arg string) *command {
func (c *Command) WithArg(arg string) *Command {
c.args = append(c.args, arg)
return c
}

func (c *command) Run() (string, error) {
func (c *Command) Run() (string, error) {
cmd := exec.Command(c.cmd, c.args...)

var outBuf, errBuf bytes.Buffer
Expand Down Expand Up @@ -85,15 +85,15 @@ func PullConfigFromSource(
return "", fmt.Errorf("failed to pull config from source based on options")
}

command := New(PullCommand).
cmd := New(PullCommand).
WithArg(EnvironmentCrane).
WithArg(options.Platform.EnvironmentTemplate)

if options.Platform.EnvironmentTemplateVersion != "" {
command = command.WithFlag("--version", options.Platform.EnvironmentTemplateVersion)
cmd = cmd.WithFlag("--version", options.Platform.EnvironmentTemplateVersion)
}

data, err = command.Run()
data, err = cmd.Run()
if err != nil {
return "", err
}
Expand Down
Loading