Skip to content

Commit

Permalink
fix(cosign/distrobox): entrypoint changes from 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scottames committed Jul 20, 2024
1 parent 2448fda commit 8359122
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cosign/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (f *Cosign) Sign(
) ([]string, error) {
stdouts := []string{}
for _, d := range digests {
cmd := []string{"sign", d, "--key", "env://COSIGN_PRIVATE_KEY"}
cmd := []string{"cosign", "sign", d, "--key", "env://COSIGN_PRIVATE_KEY"}
if registryUsername != nil && registryPassword != nil {
pwd, err := registryPassword.Plaintext(ctx)
if err != nil {
Expand Down
31 changes: 20 additions & 11 deletions distrobox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,33 @@ import (
"regexp"
)

var distrobox = "distrobox"

type Distrobox struct{}

// ContainerWithDistroboxClonedToTmp returns a Container with the Distrobox
// ContainerWithDistroboxCloned returns a Container with the Distrobox
// project cloned inside
func (d *Distrobox) ContainerWithDistroboxClonedToTmp(
func (d *Distrobox) ContainerWithDistroboxCloned(
// container to use to clone the distrobox project
// note: `git` is expected to be the entrypoint!
// +optional
// +default="cgr.dev/chainguard/git:latest"
from string,
// desired path inside the container to clone the distrobox project
// +optional
// +default="/tmp"
destination string,
path *string,
) *dagger.Container {
if path == nil {
path = &distrobox
}
return dag.
Container().
From(from).
WithExec([]string{
"git",
"clone",
"https://github.com/89luca89/distrobox.git",
"--single-branch", fmt.Sprintf("%s/distrobox", destination),
"--single-branch", *path,
})
}

Expand Down Expand Up @@ -65,7 +70,7 @@ func (d *Distrobox) ContainerWithFileFromUrl(
Container().
From(from).
WithExec([]string{
"-fsSL", "-o", filePath, url,
"curl", "-fsSL", "-o", filePath, url,
})
}

Expand All @@ -87,7 +92,8 @@ func (d *Distrobox) HostSpawnFile(
hostSpawnVersion, err := d.FindStringSubmatchInFile(
ctx, d.HostExecFile(
"cgr.dev/chainguard/git:latest", // HostExecFile uses git (not curl)
"/tmp"), `host_spawn_version="(.*?)"`,
&distrobox,
), `host_spawn_version="(.*?)"`,
)
if err != nil {
return nil, err
Expand All @@ -113,13 +119,16 @@ func (d *Distrobox) HostExecFile(
from string,
// desired path inside the container to clone the distrobox project
// +optional
// +default="/tmp"
path string,
path *string,
) *dagger.File {
if path == nil {
path = &distrobox
}

return d.
ContainerWithDistroboxClonedToTmp(from, path).
ContainerWithDistroboxCloned(from, path).
File(
fmt.Sprintf("%s/distrobox/distrobox-host-exec", path),
fmt.Sprintf("%s/distrobox-host-exec", *path),
)
}

Expand Down

0 comments on commit 8359122

Please sign in to comment.