From d1d9131c2d735fca1d6a1314f854880205c013e3 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Wed, 6 Dec 2023 11:05:06 +0100 Subject: [PATCH] chore(cmd,pkg): use a constant for `auto` driver type. Signed-off-by: Federico Di Pierro --- cmd/driver/driver_linux.go | 2 +- pkg/driver/type/type.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/driver/driver_linux.go b/cmd/driver/driver_linux.go index 5d0d3a90..f056a79a 100644 --- a/cmd/driver/driver_linux.go +++ b/cmd/driver/driver_linux.go @@ -120,7 +120,7 @@ func NewDriverCmd(ctx context.Context, opt *options.Common) *cobra.Command { } } - if driverTypes.String() != "auto" { + if driverTypes.String() != drivertype.TypeAuto { var err error // Ok driver type was enforced by the user driver.Type, err = drivertype.Parse(driverTypes.String()) diff --git a/pkg/driver/type/type.go b/pkg/driver/type/type.go index 0febd788..dcebf6fb 100644 --- a/pkg/driver/type/type.go +++ b/pkg/driver/type/type.go @@ -25,6 +25,9 @@ import ( "github.com/falcosecurity/falcoctl/pkg/output" ) +// TypeAuto enables a smart automatic driver selection logic instead of using a fixed driver type. +const TypeAuto = "auto" + var driverTypes = map[string]DriverType{} // DriverType is the interface that wraps driver types. @@ -46,7 +49,7 @@ func GetTypes() []string { } // auto is a sentinel value to enable automatic driver selection logic, // but it is not mapped to any DriverType - driverTypesSlice = append(driverTypesSlice, "auto") + driverTypesSlice = append(driverTypesSlice, TypeAuto) return driverTypesSlice }