Skip to content

Commit 0242283

Browse files
committed
umoci new: include host ARM variant by default
We generally need to specify the variant of the architecture if we are running on ARM. Rather than reimplementing /proc/cpuinfo parsing, just use containerd's platform parser since that is the standard thing used by most container tools. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 74874af commit 0242283

28 files changed

+2018
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ update to move away from our ancient pinned version of the runtime-spec.
6666
* `umoci config` now supports specifying the architecture variant of the image
6767
with `--platform.variant`. In addition, `--os` and `--architecture` can now
6868
be set using `--platform.os` and `--platform.arch` respectively.
69+
* `umoci new` will not automatically fill the architecture variant on ARM
70+
systems to match the host CPU.
6971

7072
### Changed ###
7173
* The output format of `umoci stat` has had some minor changes made to how

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ require (
2323
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1
2424
github.com/apex/log v1.9.0
2525
github.com/blang/semver/v4 v4.0.0
26+
github.com/containerd/platforms v0.2.1
2627
github.com/cyphar/filepath-securejoin v0.5.0
2728
github.com/docker/go-units v0.5.0
2829
github.com/klauspost/compress v1.11.3
@@ -42,6 +43,7 @@ require (
4243
)
4344

4445
require (
46+
github.com/containerd/log v0.1.0 // indirect
4547
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
4648
github.com/davecgh/go-spew v1.1.1 // indirect
4749
github.com/fatih/color v1.18.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
1010
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
1111
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
1212
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
13+
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
14+
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
15+
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
16+
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
1317
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
1418
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
1519
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=

new.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ package umoci
2121
import (
2222
"context"
2323
"fmt"
24-
"runtime"
2524
"time"
2625

2726
"github.com/apex/log"
27+
"github.com/containerd/platforms"
2828
imeta "github.com/opencontainers/image-spec/specs-go"
2929
ispec "github.com/opencontainers/image-spec/specs-go/v1"
3030

@@ -46,13 +46,14 @@ func NewImage(engineExt casext.Engine, tagName string, sourceDateEpoch *time.Tim
4646
createTime = *sourceDateEpoch
4747
}
4848

49-
// Set all of the defaults we need.
5049
g.SetCreated(createTime)
51-
g.SetPlatformOS(runtime.GOOS)
52-
g.SetPlatformArchitecture(runtime.GOARCH)
53-
// TODO: Set the arm variant, if applicable.
5450
g.ClearHistory()
5551

52+
hostPlatform := platforms.DefaultSpec()
53+
g.SetPlatformOS(hostPlatform.OS)
54+
g.SetPlatformArchitecture(hostPlatform.Architecture)
55+
g.SetPlatformVariant(hostPlatform.Variant)
56+
5657
// Make sure we have no diffids.
5758
g.SetRootfsType("layers")
5859
g.ClearRootfsDiffIDs()

vendor/github.com/containerd/log/.golangci.yml

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containerd/log/LICENSE

Lines changed: 191 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containerd/log/README.md

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)