Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(pkg): dropped kernel crawler distro type. #36

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pkg/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ func autogenerateConfigs(opts Options) error {
slog.Debug("unmarshaled json")
var errGrp errgroup.Group

for kcDistro, f := range fullJson {
for distro, f := range fullJson {
kernelEntries := f

dkDistro := root.ToDriverkitDistro(root.KernelCrawlerDistro(kcDistro))

// Skip unneeded kernel entries
// optimization for target-distro: skip entire key
// instead of skipping objects one by one.
if !opts.DistroFilter(dkDistro.String()) {
if !opts.DistroFilter(distro) {
continue
}

Expand Down
42 changes: 15 additions & 27 deletions pkg/root/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,27 @@ import (
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
)

type KernelCrawlerDistro string

var (
SupportedDistroSlice []string
// SupportedDistros keeps the list of distros supported by test-infra.
// We don't want to generate configs for unsupported distros after all.
// Please add new supported build-new-drivers structures here,
// Please add new supported distros here,
// so that the utility starts building configs for them.
// Keys must have the same name used by driverkit targets.
// Values must have the same name used by kernel-crawler json keys.
SupportedDistros = map[builder.Type]KernelCrawlerDistro{
builder.TargetTypeAlma: "AlmaLinux",
builder.TargetTypeAmazonLinux: "AmazonLinux",
builder.TargetTypeAmazonLinux2: "AmazonLinux2",
builder.TargetTypeAmazonLinux2022: "AmazonLinux2022",
builder.TargetTypeAmazonLinux2023: "AmazonLinux2023",
builder.TargetTypeBottlerocket: "BottleRocket",
builder.TargetTypeCentos: "CentOS",
builder.TargetTypeDebian: "Debian",
builder.TargetTypeFedora: "Fedora",
builder.TargetTypeMinikube: "Minikube",
builder.TargetTypePhoton: "PhotonOS",
builder.TargetTypeTalos: "Talos",
builder.TargetTypeUbuntu: "Ubuntu",
SupportedDistros = map[builder.Type]struct{}{
builder.TargetTypeAlma: {},
builder.TargetTypeAmazonLinux: {},
builder.TargetTypeAmazonLinux2: {},
builder.TargetTypeAmazonLinux2022: {},
builder.TargetTypeAmazonLinux2023: {},
builder.TargetTypeBottlerocket: {},
builder.TargetTypeCentos: {},
builder.TargetTypeDebian: {},
builder.TargetTypeFedora: {},
builder.TargetTypeMinikube: {},
builder.TargetTypePhoton: {},
builder.TargetTypeTalos: {},
builder.TargetTypeUbuntu: {},
}
)

Expand All @@ -54,12 +51,3 @@ func init() {
}
sort.Strings(SupportedDistroSlice)
}

func ToDriverkitDistro(distro KernelCrawlerDistro) builder.Type {
for key, val := range SupportedDistros {
if val == distro {
return key
}
}
return builder.Type("")
}
Loading