-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.go
34 lines (28 loc) · 907 Bytes
/
platform.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package config
import (
"strings"
"github.com/dronestock/docker/internal/internal/constant"
"github.com/goexl/gox"
)
type Platform struct {
// 操作系统
Os string `default:"${OS=linux}" json:"os,omitempty" validate:"omitempty,oneof=linux windows"`
// 架构
Arch string `default:"${ARCH=amd64}" json:"arch,omitempty" validate:"omitempty,oneof=amd64 i386 arm arm64"`
// 变体
// nolint:lll
Variant string `default:"${VARIANT}" json:"variant,omitempty" validate:"omitempty,required_if=Arch arm,oneof=v5 v6 v7"`
}
func (p *Platform) Argument() string {
builder := gox.StringBuilder()
if "" != p.Os && "" != p.Arch {
builder.Append(p.Os).Append(constant.Slash).Append(p.Arch)
}
if "" != p.Os && "" != p.Arch && "" != p.Variant {
builder.Append(constant.Slash).Append(p.Variant)
}
return builder.String()
}
func (p *Platform) Qemu() bool {
return strings.Contains(p.Arch, "arm")
}