Skip to content

Commit

Permalink
cleanup(cmd): require kernelrelease and kernelversion in local command.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP authored and poiana committed Dec 1, 2023
1 parent 2c7d6f0 commit 53a49ea
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions cmd/local.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package cmd

import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"golang.org/x/sys/unix"
"log/slog"
"os"
"os/user"
"runtime"
"strings"
)

type localCmdOptions struct {
Expand Down Expand Up @@ -55,8 +52,6 @@ func NewLocalCmd(rootCommand *RootCmd, rootOpts *RootOptions, rootFlags *pflag.F
// Add root flags, but not the ones unneeded
unusedFlagsSet := map[string]struct{}{
"architecture": {},
"kernelrelease": {},
"kernelversion": {},
"target": {},
"kernelurls": {},
"builderrepo": {},
Expand Down Expand Up @@ -87,19 +82,6 @@ func persistentPreRunFunc(rootCommand *RootCmd, rootOpts *RootOptions) func(c *c
return func(c *cobra.Command, args []string) error {
// Default values
rootOpts.Target = "local"
u := unix.Utsname{}
if err := unix.Uname(&u); err != nil {
slog.Error("failed to retrieve default uname values", "err", err)
// this only affects logs!
rootOpts.KernelRelease = "1.0.0"
rootOpts.KernelVersion = "1"
} else {
rootOpts.KernelRelease = string(bytes.Trim(u.Release[:], "\x00"))
kv := string(bytes.Trim(u.Version[:], "\x00"))
kv = strings.Trim(kv, "#")
kv = strings.Split(kv, " ")[0]
rootOpts.KernelVersion = kv
}
rootOpts.Architecture = runtime.GOARCH
return rootCommand.c.PersistentPreRunE(c, args)
}
Expand Down

0 comments on commit 53a49ea

Please sign in to comment.