Skip to content

Commit

Permalink
fix: Use dagger to detect the arch and platform in stead of go runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Mask <[email protected]>
  • Loading branch information
atmask committed Jan 25, 2025
1 parent 98c825d commit 7273908
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"log"
"maps"
"os"
"runtime"
"strings"

"dagger.io/dagger"
Expand Down Expand Up @@ -41,13 +40,6 @@ func init() {
func main() {
flag.Parse()

architecture = "x86_64"
platform = "linux/amd64"
if strings.Contains(runtime.GOARCH, "arm64") || strings.Contains(runtime.GOARCH, "aarch64") {
architecture = "arm64"
platform = "linux/arm64"
}

if err := run(); err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -84,6 +76,20 @@ func run() error {
Exclude: []string{".github/", "build/", "tmp/", ".git/"},
})

// Detect the architecture and platform of the host machine
architecture = "x86_64"
platform = "linux/amd64"
daggerPlatform, err := client.DefaultPlatform(ctx)
if err != nil {
fmt.Println("Error detecting host platform from Dagger: ", err)
fmt.Println("Defaulting to platform: linux/amd64, architecture: x86_64")
}
platform = string(daggerPlatform)
if strings.Contains(platform, "arm64") || strings.Contains(platform, "aarch64") {
architecture = "arm64"
platform = "linux/arm64"
}

flipt := client.Container().From("flipt/flipt:latest").
WithUser("root").
WithExec([]string{"mkdir", "-p", "/var/data/flipt"}).
Expand Down

0 comments on commit 7273908

Please sign in to comment.