Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use dagger to detect the arch and platform in stead of go runtime #655

Merged
merged 1 commit into from
Jan 27, 2025
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
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
Loading