Skip to content

Commit

Permalink
chore(internal,pkg): fixup some linting issues.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Nov 3, 2023
1 parent 61f5e7a commit 51aa6c2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ func Driverer() (Driver, error) {
}, nil
}

// SelectDriver stores a driver as selected in config file.
func SelectDriver(driverType, configFile string) error {
if err := UpdateConfigFile(DriverSelectedKey, driverType, configFile); err != nil {
return fmt.Errorf("unable to update selected driver in the config file %q: %w", configFile, err)
Expand Down
14 changes: 7 additions & 7 deletions pkg/driver/distro/amzn.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ type amzn struct {
*generic
}

func (a *amzn) init(printer *output.Printer, id string, cfg *ini.File) error {
func (a *amzn) init(printer *output.Printer, _ string, cfg *ini.File) error {
idKey := cfg.Section("").Key("VERSION_ID")
if idKey == nil {
// OS-release without `VERSION_ID` (can it happen?)
return fmt.Errorf("no VERSION_ID present for amzn")
}
// overwrite id
newId := ""
newID := ""
switch idKey.String() {
case "2":
newId = "amazonlinux2"
newID = "amazonlinux2"
case "2022":
newId = "amazonlinux2022"
newID = "amazonlinux2022"
case "2023":
newId = "amazonlinux2023"
newID = "amazonlinux2023"
default:
newId = "amazonlinux"
newID = "amazonlinux"
}
return a.generic.init(printer, newId, cfg)
return a.generic.init(printer, newID, cfg)
}
5 changes: 5 additions & 0 deletions pkg/driver/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import (

var distros = map[string]Distro{}

// ErrUnsupported is the error returned when the target distro is not supported.
var ErrUnsupported = fmt.Errorf("failed to determine distro")

// Distro is the common interface used by distro-specific implementations.
// Most of the distro-specific only partially override the default `generic` implementation.
type Distro interface {
init(printer *output.Printer, id string, cfg *ini.File) error // private
GetTargetID(i driverkernel.Info) string
Expand All @@ -27,6 +30,8 @@ type checker interface {
check(hostRoot string) bool // private
}

// DiscoverDistro tries to fetch the correct Distro by looking at /etc/os-release or
// by cycling on all supported distros and checking them one by one.
func DiscoverDistro(printer *output.Printer, hostRoot string) (Distro, error) {
distro, err := getOSReleaseDistro(printer, hostRoot)
if err == nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/driver/kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

Check failure on line 6 in pkg/driver/kernel/kernel.go

View workflow job for this annotation

GitHub Actions / Lint golang files

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/falcosecurity/falcoctl) (gci)
)

// Info is the struct that holds all the kernel related information that are needed.
type Info struct {
Architecture string
KernelRelease string
Expand Down
2 changes: 2 additions & 0 deletions pkg/driver/type/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import "fmt"

var driverTypes = map[string]DriverType{}

// DriverType is the interface that wraps driver types.
type DriverType interface {
String() string
Prepare() error
Extension() string
HasArtifacts() bool
}

// Parse parses a driver type string and returns the corresponding DriverType object or an error.
func Parse(driverType string) (DriverType, error) {
if dType, ok := driverTypes[driverType]; ok {
return dType, nil
Expand Down

0 comments on commit 51aa6c2

Please sign in to comment.