Skip to content

Commit

Permalink
cleanup(pkg): dropped kernel crawler distro type.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Oct 23, 2023
1 parent 2e8fcee commit a1be5a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
6 changes: 2 additions & 4 deletions pkg/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,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("")
}

0 comments on commit a1be5a3

Please sign in to comment.