Skip to content
Merged
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
14 changes: 14 additions & 0 deletions pkg/agent/delivery/remote_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"os/exec"
"path"

"github.com/devsy-org/devsy/pkg/agent"
"github.com/devsy-org/devsy/pkg/log"
Expand Down Expand Up @@ -40,6 +41,10 @@ func (d *RemoteDockerDelivery) DeliverPostStart(ctx context.Context, opts PostSt

destPath := agent.ContainerDevsyHelperLocation

if err := d.ensureDir(ctx, destPath); err != nil {
return fmt.Errorf("ensure target directory: %w", err)
}

if err := d.copyBinaryFromSource(ctx, opts.BinarySource, opts.Arch, destPath); err != nil {
return fmt.Errorf("copy binary to container: %w", err)
}
Expand Down Expand Up @@ -98,6 +103,15 @@ func (d *RemoteDockerDelivery) chmodBinary(ctx context.Context, destPath string)
return nil
}

func (d *RemoteDockerDelivery) ensureDir(ctx context.Context, filePath string) error {
dir := path.Dir(filePath)
out, err := d.cmd(ctx, "exec", d.ContainerID, "mkdir", "-p", dir).CombinedOutput()
if err != nil {
return fmt.Errorf("%s: %w", string(out), err)
}
return nil
}

func (d *RemoteDockerDelivery) cmd(ctx context.Context, args ...string) *exec.Cmd {
// #nosec G204 -- args are constructed internally, not from user input
cmd := exec.CommandContext(ctx, d.dockerCommand(), args...)
Expand Down
Loading