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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
package helperimage
import (
"fmt"
"runtime"
"gitlab.com/gitlab-org/gitlab-runner/shells"
)
const (
platformAmd64 = "amd64"
platformArm6vl = "armv6l"
platformArmv7l = "armv7l"
platformAarch64 = "aarch64"
archX8664 = "x86_64"
archArm = "arm"
archArm64 = "arm64"
)
var bashCmd = []string{"gitlab-runner-build"}
type linuxInfo struct{}
func (l *linuxInfo) Create(revision string, cfg Config) (Info, error) {
arch := l.architecture(cfg.Architecture)
if cfg.Flavor == "" {
cfg.Flavor = DefaultFlavor
}
// alpine is a special case: we don't add the flavor to the tag name
// for backwards compatibility purposes. It existed before flavors were
// introduced.
if cfg.Flavor == "alpine" {
cfg.Flavor = ""
}
prefix := ""
if cfg.Flavor != "" {
prefix = cfg.Flavor + "-"
}
shell := cfg.Shell
if shell == "" {
shell = "bash"
}
cmd := bashCmd
// tag := fmt.Sprintf("%s%s-%s", prefix, arch, revision)
tag := fmt.Sprintf("%s%s", prefix, revision)
if shell == shells.SNPwsh {
cmd = getPowerShellCmd(shell)
tag = fmt.Sprintf("%s-%s", tag, shell)
}
return Info{
Architecture: arch,
Name: imageName(cfg.GitLabRegistry),
Tag: tag,
IsSupportingLocalImport: true,
Cmd: cmd,
}, nil
}
func (l *linuxInfo) architecture(arch string) string {
switch arch {
case platformArm6vl, platformArmv7l:
return archArm
case platformAarch64:
return archArm64
case platformAmd64:
return archX8664
}
if arch != "" {
return arch
}
switch runtime.GOARCH {
case platformAmd64:
return archX8664
default:
return runtime.GOARCH
}
}
|