refactor: use the same name as in config
This commit is contained in:
parent
6385ce92e3
commit
d551cc8fc4
@ -26,8 +26,8 @@ type kernel struct {
|
||||
Patch []int
|
||||
}
|
||||
|
||||
// KernelMask defines the kernel
|
||||
type KernelMask struct {
|
||||
// Target defines the kernel
|
||||
type Target struct {
|
||||
Distro distro.Distro
|
||||
|
||||
ReleaseMask string
|
||||
@ -37,7 +37,7 @@ type KernelMask struct {
|
||||
}
|
||||
|
||||
// DockerName is returns stable name for docker container
|
||||
func (km KernelMask) DockerName() string {
|
||||
func (km Target) DockerName() string {
|
||||
distro := strings.ToLower(km.Distro.ID.String())
|
||||
release := strings.Replace(km.Distro.Release, ".", "__", -1)
|
||||
return fmt.Sprintf("out_of_tree_%s_%s", distro, release)
|
||||
@ -135,7 +135,7 @@ type Artifact struct {
|
||||
Type ArtifactType
|
||||
TestFiles []FileTransfer
|
||||
SourcePath string
|
||||
Targets []KernelMask
|
||||
Targets []Target
|
||||
|
||||
Script string
|
||||
|
||||
@ -167,7 +167,7 @@ type Artifact struct {
|
||||
Preload []PreloadModule
|
||||
}
|
||||
|
||||
func (ka Artifact) checkSupport(ki KernelInfo, km KernelMask) (
|
||||
func (ka Artifact) checkSupport(ki KernelInfo, km Target) (
|
||||
supported bool, err error) {
|
||||
|
||||
if ki.Distro.ID != km.Distro.ID {
|
||||
|
@ -18,7 +18,7 @@ func TestMarshalUnmarshal(t *testing.T) {
|
||||
Type: KernelModule,
|
||||
}
|
||||
artifactCfg.Targets = append(artifactCfg.Targets,
|
||||
KernelMask{distro.Distro{
|
||||
Target{distro.Distro{
|
||||
ID: distro.Ubuntu,
|
||||
Release: "18.04",
|
||||
}, ".*", kernel{}})
|
||||
|
@ -68,7 +68,7 @@ func Images() (diis []Image, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func ImagePath(sk config.KernelMask) string {
|
||||
func ImagePath(sk config.Target) string {
|
||||
return config.Dir("containers", sk.Distro.ID.String(), sk.Distro.Release)
|
||||
}
|
||||
|
||||
|
2
debug.go
2
debug.go
@ -229,7 +229,7 @@ func firstSupported(kcfg config.KernelConfig, ka config.Artifact,
|
||||
return
|
||||
}
|
||||
|
||||
ka.Targets = []config.KernelMask{km}
|
||||
ka.Targets = []config.Target{km}
|
||||
|
||||
for _, ki = range kcfg.Kernels {
|
||||
var supported bool
|
||||
|
@ -8,11 +8,11 @@ import (
|
||||
"code.dumpstack.io/tools/out-of-tree/config"
|
||||
)
|
||||
|
||||
func Envs(km config.KernelMask) (envs []string) {
|
||||
func Envs(km config.Target) (envs []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func Runs(km config.KernelMask) (commands []string) {
|
||||
func Runs(km config.Target) (commands []string) {
|
||||
cmdf := func(f string, s ...interface{}) {
|
||||
commands = append(commands, fmt.Sprintf(f, s...))
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ func kernelRelease(deb string) (r Release, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Match(km config.KernelMask) (pkgs []string, err error) {
|
||||
func Match(km config.Target) (pkgs []string, err error) {
|
||||
kernels, err := GetKernels()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("get kernels")
|
||||
@ -143,12 +143,12 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Envs(km config.KernelMask) (envs []string) {
|
||||
func Envs(km config.Target) (envs []string) {
|
||||
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
|
||||
return
|
||||
}
|
||||
|
||||
func ContainerImage(km config.KernelMask) (image string) {
|
||||
func ContainerImage(km config.Target) (image string) {
|
||||
image += "debian:"
|
||||
|
||||
switch releaseFromString(km.Distro.Release) {
|
||||
@ -196,7 +196,7 @@ func repositories(release Release) (repos []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func Runs(km config.KernelMask) (commands []string) {
|
||||
func Runs(km config.Target) (commands []string) {
|
||||
release := releaseFromString(km.Distro.Release)
|
||||
|
||||
cmdf := func(f string, s ...interface{}) {
|
||||
@ -306,7 +306,7 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
|
||||
return
|
||||
}
|
||||
|
||||
func Volumes(km config.KernelMask, pkgname string) (volumes container.Volumes) {
|
||||
func Volumes(km config.Target, pkgname string) (volumes container.Volumes) {
|
||||
pkgdir := filepath.Join("volumes", km.DockerName(), pkgname)
|
||||
|
||||
volumes.LibModules = config.Dir(pkgdir, "/lib/modules")
|
||||
@ -316,7 +316,7 @@ func Volumes(km config.KernelMask, pkgname string) (volumes container.Volumes) {
|
||||
return
|
||||
}
|
||||
|
||||
func Install(km config.KernelMask, pkgname string, headers bool) (cmds []string, err error) {
|
||||
func Install(km config.Target, pkgname string, headers bool) (cmds []string, err error) {
|
||||
dk, err := getCachedKernel(pkgname + ".deb")
|
||||
if err != nil {
|
||||
return
|
||||
@ -352,7 +352,7 @@ func Install(km config.KernelMask, pkgname string, headers bool) (cmds []string,
|
||||
return
|
||||
}
|
||||
|
||||
func Cleanup(km config.KernelMask, pkgname string) {
|
||||
func Cleanup(km config.Target, pkgname string) {
|
||||
pkgdir := config.Dir(filepath.Join("volumes", km.DockerName(), pkgname))
|
||||
|
||||
log.Debug().Msgf("cleanup %s", pkgdir)
|
||||
|
@ -24,7 +24,7 @@ func TestMatch(t *testing.T) {
|
||||
|
||||
config.Directory = tmp
|
||||
|
||||
km := config.KernelMask{
|
||||
km := config.Target{
|
||||
ReleaseMask: "3.2.0-4",
|
||||
Distro: distro.Distro{Release: "7"},
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ import (
|
||||
"code.dumpstack.io/tools/out-of-tree/container"
|
||||
)
|
||||
|
||||
func Envs(km config.KernelMask) (envs []string) {
|
||||
func Envs(km config.Target) (envs []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func Runs(km config.KernelMask) (commands []string) {
|
||||
func Runs(km config.Target) (commands []string) {
|
||||
cmdf := func(f string, s ...interface{}) {
|
||||
commands = append(commands, fmt.Sprintf(f, s...))
|
||||
}
|
||||
@ -40,7 +40,7 @@ func Runs(km config.KernelMask) (commands []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func Match(km config.KernelMask) (pkgs []string, err error) {
|
||||
func Match(km config.Target) (pkgs []string, err error) {
|
||||
// FIXME timeout should be in global out-of-tree config
|
||||
c, err := container.New(km.DockerName(), time.Hour)
|
||||
if err != nil {
|
||||
@ -76,7 +76,7 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Install(km config.KernelMask, pkgname string, headers bool) (commands []string, err error) {
|
||||
func Install(km config.Target, pkgname string, headers bool) (commands []string, err error) {
|
||||
var headerspkg string
|
||||
if headers {
|
||||
if strings.Contains(pkgname, "uek") {
|
||||
@ -113,6 +113,6 @@ func Install(km config.KernelMask, pkgname string, headers bool) (commands []str
|
||||
return
|
||||
}
|
||||
|
||||
func Cleanup(km config.KernelMask, pkgname string) {
|
||||
func Cleanup(km config.Target, pkgname string) {
|
||||
return
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ import (
|
||||
"code.dumpstack.io/tools/out-of-tree/container"
|
||||
)
|
||||
|
||||
func Envs(km config.KernelMask) (envs []string) {
|
||||
func Envs(km config.Target) (envs []string) {
|
||||
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
|
||||
return
|
||||
}
|
||||
|
||||
func Runs(km config.KernelMask) (commands []string) {
|
||||
func Runs(km config.Target) (commands []string) {
|
||||
cmdf := func(f string, s ...interface{}) {
|
||||
commands = append(commands, fmt.Sprintf(f, s...))
|
||||
}
|
||||
@ -53,7 +53,7 @@ func Runs(km config.KernelMask) (commands []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func Match(km config.KernelMask) (pkgs []string, err error) {
|
||||
func Match(km config.Target) (pkgs []string, err error) {
|
||||
// FIXME timeout should be in global out-of-tree config
|
||||
c, err := container.New(km.DockerName(), time.Hour)
|
||||
if err != nil {
|
||||
@ -83,7 +83,7 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Install(km config.KernelMask, pkgname string, headers bool) (commands []string, err error) {
|
||||
func Install(km config.Target, pkgname string, headers bool) (commands []string, err error) {
|
||||
|
||||
var headerspkg string
|
||||
if headers {
|
||||
@ -99,6 +99,6 @@ func Install(km config.KernelMask, pkgname string, headers bool) (commands []str
|
||||
return
|
||||
}
|
||||
|
||||
func Cleanup(km config.KernelMask, pkgname string) {
|
||||
func Cleanup(km config.Target, pkgname string) {
|
||||
return
|
||||
}
|
||||
|
4
gen.go
4
gen.go
@ -32,11 +32,11 @@ func genConfig(at config.ArtifactType) (err error) {
|
||||
Name: "Put name here",
|
||||
Type: at,
|
||||
}
|
||||
a.Targets = append(a.Targets, config.KernelMask{
|
||||
a.Targets = append(a.Targets, config.Target{
|
||||
Distro: distro.Distro{ID: distro.Ubuntu, Release: "18.04"},
|
||||
ReleaseMask: ".*",
|
||||
})
|
||||
a.Targets = append(a.Targets, config.KernelMask{
|
||||
a.Targets = append(a.Targets, config.Target{
|
||||
Distro: distro.Distro{ID: distro.Debian, Release: "8"},
|
||||
ReleaseMask: ".*",
|
||||
})
|
||||
|
@ -64,7 +64,7 @@ func (cmd *KernelListRemoteCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error
|
||||
return
|
||||
}
|
||||
|
||||
km := config.KernelMask{
|
||||
km := config.Target{
|
||||
Distro: distro.Distro{ID: distroType, Release: cmd.Ver},
|
||||
ReleaseMask: ".*",
|
||||
}
|
||||
@ -149,7 +149,7 @@ func (cmd *KernelGenallCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
||||
shutdown := false
|
||||
kernel.SetSigintHandler(&shutdown)
|
||||
|
||||
km := config.KernelMask{
|
||||
km := config.Target{
|
||||
Distro: distro.Distro{ID: distroType, Release: cmd.Ver},
|
||||
ReleaseMask: ".*",
|
||||
}
|
||||
@ -186,7 +186,7 @@ func (cmd *KernelInstallCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
|
||||
shutdown := false
|
||||
kernel.SetSigintHandler(&shutdown)
|
||||
|
||||
km := config.KernelMask{
|
||||
km := config.Target{
|
||||
Distro: distro.Distro{ID: distroType, Release: cmd.Ver},
|
||||
ReleaseMask: cmd.Kernel,
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
"code.dumpstack.io/tools/out-of-tree/fs"
|
||||
)
|
||||
|
||||
func MatchPackages(km config.KernelMask) (pkgs []string, err error) {
|
||||
func MatchPackages(km config.Target) (pkgs []string, err error) {
|
||||
// TODO interface for kernels match
|
||||
switch km.Distro.ID {
|
||||
case distro.Ubuntu:
|
||||
@ -65,7 +65,7 @@ func vsyscallAvailable() (available bool, err error) {
|
||||
}
|
||||
|
||||
func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
|
||||
sk config.KernelMask, forceUpdate bool) (err error) {
|
||||
sk config.Target, forceUpdate bool) (err error) {
|
||||
|
||||
imagePath := container.ImagePath(sk)
|
||||
dockerPath := imagePath + "/Dockerfile"
|
||||
@ -175,7 +175,7 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
|
||||
return
|
||||
}
|
||||
|
||||
func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (err error) {
|
||||
func installKernel(sk config.Target, pkgname string, force, headers bool) (err error) {
|
||||
slog := log.With().
|
||||
Str("distro_type", sk.Distro.ID.String()).
|
||||
Str("distro_release", sk.Distro.Release).
|
||||
@ -510,7 +510,7 @@ func SetSigintHandler(variable *bool) {
|
||||
}
|
||||
|
||||
// FIXME too many parameters
|
||||
func GenerateKernels(km config.KernelMask, registry string,
|
||||
func GenerateKernels(km config.Target, registry string,
|
||||
commands []config.DockerCommand, max, retries int64,
|
||||
download, force, headers, shuffle, update bool,
|
||||
shutdown *bool) (err error) {
|
||||
|
@ -47,7 +47,7 @@ func genHostKernels(download bool) (kcfg config.KernelConfig, err error) {
|
||||
|
||||
// only for compatibility, docker is not really used
|
||||
dii := container.Image{
|
||||
Name: config.KernelMask{
|
||||
Name: config.Target{
|
||||
Distro: distro.Distro{
|
||||
ID: distroType,
|
||||
Release: si.OS.Version,
|
||||
|
12
pew.go
12
pew.go
@ -95,13 +95,13 @@ func (cmd *PewCmd) Run(g *Globals) (err error) {
|
||||
}
|
||||
|
||||
if cmd.Kernel != "" {
|
||||
var km config.KernelMask
|
||||
var km config.Target
|
||||
km, err = kernelMask(cmd.Kernel)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ka.Targets = []config.KernelMask{km}
|
||||
ka.Targets = []config.Target{km}
|
||||
}
|
||||
|
||||
if cmd.Guess {
|
||||
@ -831,7 +831,7 @@ func (cmd PewCmd) performCI(ka config.Artifact) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func kernelMask(kernel string) (km config.KernelMask, err error) {
|
||||
func kernelMask(kernel string) (km config.Target, err error) {
|
||||
parts := strings.Split(kernel, ":")
|
||||
if len(parts) != 2 {
|
||||
err = errors.New("Kernel is not 'distroType:regex'")
|
||||
@ -843,13 +843,13 @@ func kernelMask(kernel string) (km config.KernelMask, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
km = config.KernelMask{Distro: distro.Distro{ID: dt}, ReleaseMask: parts[1]}
|
||||
km = config.Target{Distro: distro.Distro{ID: dt}, ReleaseMask: parts[1]}
|
||||
return
|
||||
}
|
||||
|
||||
func genAllKernels() (sk []config.KernelMask, err error) {
|
||||
func genAllKernels() (sk []config.Target, err error) {
|
||||
for _, id := range distro.IDs {
|
||||
sk = append(sk, config.KernelMask{
|
||||
sk = append(sk, config.Target{
|
||||
Distro: distro.Distro{ID: id},
|
||||
ReleaseMask: ".*",
|
||||
})
|
||||
|
@ -101,11 +101,11 @@ func buildPreload(workPath, tmp string, ki config.KernelInfo,
|
||||
|
||||
ka.SourcePath = workPath
|
||||
|
||||
km := config.KernelMask{
|
||||
km := config.Target{
|
||||
Distro: ki.Distro,
|
||||
ReleaseMask: ki.KernelRelease,
|
||||
}
|
||||
ka.Targets = []config.KernelMask{km}
|
||||
ka.Targets = []config.Target{km}
|
||||
|
||||
if ka.Docker.Timeout.Duration != 0 {
|
||||
dockerTimeout = ka.Docker.Timeout.Duration
|
||||
|
Loading…
Reference in New Issue
Block a user