Skip to content

Commit

Permalink
chore(cmd/driver): add preview to all driver related commands.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Dec 1, 2023
1 parent 15aa180 commit 432ce28
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
5 changes: 3 additions & 2 deletions cmd/driver/cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ func NewDriverCleanupCmd(ctx context.Context, opt *options.Common) *cobra.Comman
cmd := &cobra.Command{
Use: "cleanup [flags]",
DisableFlagsInUseLine: true,
Short: "Cleanup a driver",
Long: "Cleans a driver up, eg for kmod, by removing it from dkms.",
Short: "[Preview] Cleanup a driver",
Long: `[Preview] Cleans a driver up, eg for kmod, by removing it from dkms.
** This command is in preview and under development. **`,
RunE: func(cmd *cobra.Command, args []string) error {
return o.RunDriverCleanup(ctx)
},
Expand Down
5 changes: 3 additions & 2 deletions cmd/driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ import (

const (
configMapEngineKindKey = "engine.kind"
longConfig = `Configure a driver for future usages with other driver subcommands.
longConfig = `[Preview] Configure a driver for future usages with other driver subcommands.
It will also update local Falco configuration or k8s configmap depending on the environment where it is running, to let Falco use chosen driver.
Only supports deployments of Falco that use a driver engine, ie: one between kmod, ebpf and modern-ebpf.
If engine.kind key is set to a non-driver driven engine, Falco configuration won't be touched.
** This command is in preview and under development. **
`
)

Expand All @@ -72,7 +73,7 @@ func NewDriverConfigCmd(ctx context.Context, opt *options.Common) *cobra.Command
cmd := &cobra.Command{
Use: "config [flags]",
DisableFlagsInUseLine: true,
Short: "Configure a driver",
Short: "[Preview] Configure a driver",
Long: longConfig,
RunE: func(cmd *cobra.Command, args []string) error {
return o.RunDriverConfig(ctx, cmd)
Expand Down
28 changes: 26 additions & 2 deletions cmd/driver/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,31 @@ import (
"github.com/falcosecurity/falcoctl/cmd"
)

var driverConfigHelp = `Configure a driver for future usages with other driver subcommands.`
var driverConfigHelp = `[Preview] Configure a driver for future usages with other driver subcommands.
It will also update local Falco configuration or k8s configmap depending on the environment where it is running, to let Falco use chosen driver.
Only supports deployments of Falco that use a driver engine, ie: one between kmod, ebpf and modern-ebpf.
If engine.kind key is set to a non-driver driven engine, Falco configuration won't be touched.
** This command is in preview and under development. **
Usage:
falcoctl driver config [flags]
Flags:
-h, --help help for config
--host-root string Driver host root to be configured. (default "/")
--kubeconfig string Kubernetes config.
--name string Driver name to be configured. (default "falco")
--namespace string Kubernetes namespace.
--repo strings Driver repo to be configured. (default [https://download.falco.org/driver])
--type string Driver type to be configured (auto, ebpf, kmod, modern_ebpf) (default "kmod")
--update-falco Whether to update Falco config/configmap. (default true)
--version string Driver version to be configured.
Global Flags:
--config string config file to be used for falcoctl (default "/etc/falcoctl/falcoctl.yaml")
--log-format string Set formatting for logs (color, text, json) (default "color")
--log-level string Set level for logs (info, warn, debug, trace) (default "info")
`

var addAssertFailedBehavior = func(specificError string) {
It("check that fails and the usage is not printed", func() {
Expand Down Expand Up @@ -58,7 +82,7 @@ var _ = Describe("config", func() {
})

It("should match the saved one", func() {
Expect(output).Should(gbytes.Say(driverConfigHelp))
Expect(output).Should(gbytes.Say(regexp.QuoteMeta(driverConfigHelp)))
})
})

Expand Down
5 changes: 3 additions & 2 deletions cmd/driver/driver_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ func NewDriverCmd(ctx context.Context, opt *commonoptions.Common) *cobra.Command
cmd := &cobra.Command{
Use: "driver",
DisableFlagsInUseLine: true,
Short: "Interact with falcosecurity driver",
Long: "Interact with falcosecurity driver",
Short: "[Preview] Interact with falcosecurity driver",
Long: `[Preview] Interact with falcosecurity driver.
** This command is in preview and under development. **`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
opt.Initialize()
return config.Load(opt.ConfigFile)
Expand Down
5 changes: 3 additions & 2 deletions cmd/driver/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ func NewDriverInstallCmd(ctx context.Context, opt *options.Common) *cobra.Comman
cmd := &cobra.Command{
Use: "install [flags]",
DisableFlagsInUseLine: true,
Short: "Install previously configured driver",
Long: "Install previously configured driver, either downloading it or attempting a build",
Short: "[Preview] Install previously configured driver",
Long: `[Preview] Install previously configured driver, either downloading it or attempting a build.
** This command is in preview and under development. **`,
RunE: func(cmd *cobra.Command, args []string) error {
driver, err := config.Driverer()
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/driver/printenv/printenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ func NewDriverPrintenvCmd(ctx context.Context, opt *options.Common) *cobra.Comma
cmd := &cobra.Command{
Use: "printenv [flags]",
DisableFlagsInUseLine: true,
Short: "Print env vars",
Long: "Print variables used by driver as env vars.",
Short: "[Preview] Print env vars",
Long: `[Preview] Print variables used by driver as env vars.
** This command is in preview and under development. **`,
RunE: func(cmd *cobra.Command, args []string) error {
return o.RunDriverPrintenv(ctx)
},
Expand Down

0 comments on commit 432ce28

Please sign in to comment.