Skip to content

Commit

Permalink
Map Docker architecture values to biome values (#318)
Browse files Browse the repository at this point in the history
[Fixes ch5015]
  • Loading branch information
zombiezen authored Jun 4, 2021
1 parent c693c95 commit 4e4bbd7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/biome/biome.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const (
const (
Intel64 = "amd64"
Intel32 = "386"
ARM64 = "arm64"
)

// Dirs holds paths to special directories in a Context.
Expand Down
23 changes: 19 additions & 4 deletions internal/biome/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,25 @@ func DockerDescriptor(ctx context.Context, client *docker.Client) (*Descriptor,
if info.OSType == "" || info.Architecture == "" {
return nil, fmt.Errorf("docker info: missing OSType and/or Architecture")
}
return &Descriptor{
OS: info.OSType,
Arch: info.Architecture,
}, nil
desc := &Descriptor{
OS: info.OSType,
// While the Docker documentation claims that it uses runtime.GOARCH,
// it actually uses the syscall equivalent of `uname -m`.
// Source: https://github.com/moby/moby/blob/v20.10.7/pkg/platform/architecture_unix.go
Arch: map[string]string{
"x86": Intel32,
"x86_64": Intel64,
// macOS uses arm64 and Linux uses aarch64. https://stackoverflow.com/a/47274698
// Not sure if we'll encounter the Docker daemon running on macOS directly,
// but including both variants for sake of completeness.
"arm64": ARM64,
"aarch64": ARM64,
}[info.Architecture],
}
if desc.Arch == "" {
return nil, fmt.Errorf("docker info: unknown architecture %q", info.Architecture)
}
return desc, nil
}

// Dirs returns special directories.
Expand Down

0 comments on commit 4e4bbd7

Please sign in to comment.