Skip to content

Commit

Permalink
cleanup(cmd): renamed s3 to drivers.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Sep 7, 2023
1 parent 39c8aac commit 6e655bc
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 37 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ Usage:
Available Commands:
completion Generate the autocompletion script for the specified shell
configs Work with local dbg configs
drivers Work with remote drivers bucket
help Help about any command
s3 Work with remote s3 bucket
Flags:
-a, --architecture string architecture to run against. Supported: [amd64,arm64] (default "amd64")
--driver-name string driver name to be used (default "falco")
--driver-version strings driver versions to run against.
--dry-run enable dry-run mode.
-h, --help help for dbg-go
Expand Down Expand Up @@ -114,5 +115,13 @@ Using `goreleaser`, multiple artifacts are attached to each github release; amon
```
</details>

<details>
<summary>Publish locally built drivers for aarch64 for all supported driver versions by test-infra</summary>

```bash
./dbg-go drivers publish --repo-root test-infra --architecture arm64
```
</details>


> **NOTE:** all commands that require s3 write access, need a proper `--aws-profile` to be passed.
6 changes: 3 additions & 3 deletions cmd/build/build.go → cmd/build/build_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/spf13/viper"
)

func NewBuildCmd() *cobra.Command {
func NewBuildConfigsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "build",
Short: "build dbg configs",
RunE: execute,
RunE: executeConfigs,
}
flags := cmd.Flags()
flags.Bool("skip-existing", true, "whether to skip the build of drivers existing on S3")
Expand All @@ -23,7 +23,7 @@ func NewBuildCmd() *cobra.Command {
return cmd
}

func execute(_ *cobra.Command, _ []string) error {
func executeConfigs(_ *cobra.Command, _ []string) error {
options := build.Options{
Options: root.LoadRootOptions(),
SkipExisting: viper.GetBool("skip-existing"),
Expand Down
8 changes: 4 additions & 4 deletions cmd/cleanup/cleanup.go → cmd/cleanup/cleanup_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"github.com/spf13/cobra"
)

func NewCleanupCmd() *cobra.Command {
func NewCleanupConfigsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cleanup",
Short: "Cleanup outdated dbg configs",
RunE: execute,
Short: "Cleanup dbg configs",
RunE: executeConfigs,
}
return cmd
}

func execute(c *cobra.Command, args []string) error {
func executeConfigs(c *cobra.Command, args []string) error {
return cleanup.Run(cleanup.Options{Options: root.LoadRootOptions()}, cleanup.NewFileCleaner())
}
6 changes: 3 additions & 3 deletions cmd/cleanup/cleanup_s3.go → cmd/cleanup/cleanup_drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/spf13/viper"
)

func NewCleanupS3Cmd() *cobra.Command {
func NewCleanupDriversCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cleanup",
Short: "Cleanup desired remote drivers",
RunE: executeS3,
RunE: executeDrivers,
}

flags := cmd.Flags()
Expand All @@ -21,7 +21,7 @@ func NewCleanupS3Cmd() *cobra.Command {
return cmd
}

func executeS3(_ *cobra.Command, _ []string) error {
func executeDrivers(_ *cobra.Command, _ []string) error {
cleaner, err := cleanup.NewS3Cleaner(viper.GetString("aws-profile"))
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions cmd/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var (

func init() {
// Subcommands
configsCmd.AddCommand(generate.NewGenerateCmd())
configsCmd.AddCommand(cleanup.NewCleanupCmd())
configsCmd.AddCommand(validate.NewValidateCmd())
configsCmd.AddCommand(stats.NewStatsCmd())
configsCmd.AddCommand(build.NewBuildCmd())
configsCmd.AddCommand(generate.NewGenerateConfigsCmd())
configsCmd.AddCommand(cleanup.NewCleanupConfigsCmd())
configsCmd.AddCommand(validate.NewValidateConfigsCmd())
configsCmd.AddCommand(stats.NewStatsConfigsCmd())
configsCmd.AddCommand(build.NewBuildConfigsCmd())
}
10 changes: 5 additions & 5 deletions cmd/s3.go → cmd/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (

var (
s3Cmd = &cobra.Command{
Use: "s3",
Short: "Work with remote s3 bucket",
Use: "drivers",
Short: "Work with remote drivers bucket",
}
)

func init() {
// Subcommands
s3Cmd.AddCommand(cleanup.NewCleanupS3Cmd())
s3Cmd.AddCommand(stats.NewStatsS3Cmd())
s3Cmd.AddCommand(publish.NewPublishCmd())
s3Cmd.AddCommand(cleanup.NewCleanupDriversCmd())
s3Cmd.AddCommand(stats.NewStatsDriversCmd())
s3Cmd.AddCommand(publish.NewPublishDriversCmd())
}
6 changes: 3 additions & 3 deletions cmd/generate/generate.go → cmd/generate/generate_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/viper"
)

func NewGenerateCmd() *cobra.Command {
func NewGenerateConfigsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "generate",
Short: "Generate new dbg configs",
Expand All @@ -19,14 +19,14 @@ Instead, when auto mode is disabled, the tool is able to generate a single confi
In this scenario, target-{distro,kernelrelease,kernelversion} CANNOT be regexes but must be exact values.
Also, in non-automatic mode, kernelurls driverkit config key will be constructed using driverkit libraries.
`,
RunE: execute,
RunE: executeConfigs,
}
flags := cmd.Flags()
flags.Bool("auto", false, "automatically generate configs from kernel-crawler output")
return cmd
}

func execute(c *cobra.Command, args []string) error {
func executeConfigs(c *cobra.Command, args []string) error {
options := generate.Options{
Options: root.LoadRootOptions(),
Auto: viper.GetBool("auto"),
Expand Down
6 changes: 3 additions & 3 deletions cmd/publish/publish.go → cmd/publish/publish_drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"github.com/spf13/viper"
)

func NewPublishCmd() *cobra.Command {
func NewPublishDriversCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "publish",
Short: "publish local drivers to remote bucket",
RunE: execute,
RunE: executeDrivers,
}
flags := cmd.Flags()
flags.String("aws-profile", "", "aws-profile to be used. Mandatory.")
Expand All @@ -20,7 +20,7 @@ func NewPublishCmd() *cobra.Command {
return cmd
}

func execute(_ *cobra.Command, _ []string) error {
func executeDrivers(_ *cobra.Command, _ []string) error {
options := publish.Options{
Options: root.LoadRootOptions(),
AwsProfile: viper.GetString("aws-profile"),
Expand Down
8 changes: 4 additions & 4 deletions cmd/stats/stats.go → cmd/stats/stats_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"github.com/spf13/cobra"
)

func NewStatsCmd() *cobra.Command {
func NewStatsConfigsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "stats",
Short: "Fetch stats about configs",
RunE: execute,
Short: "Fetch stats about dbg configs",
RunE: executeConfigs,
}
return cmd
}

func execute(_ *cobra.Command, _ []string) error {
func executeConfigs(_ *cobra.Command, _ []string) error {
return stats.Run(stats.Options{Options: root.LoadRootOptions()}, stats.NewFileStatter())
}
6 changes: 3 additions & 3 deletions cmd/stats/stats_s3.go → cmd/stats/stats_drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"github.com/spf13/cobra"
)

func NewStatsS3Cmd() *cobra.Command {
func NewStatsDriversCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "stats",
Short: "Fetch stats about remote drivers",
RunE: executeS3,
RunE: executeDrivers,
}
return cmd
}

func executeS3(_ *cobra.Command, _ []string) error {
func executeDrivers(_ *cobra.Command, _ []string) error {
statter, err := stats.NewS3Statter()
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/validate/validate.go → cmd/validate/validate_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"github.com/spf13/cobra"
)

func NewValidateCmd() *cobra.Command {
func NewValidateConfigsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "validate",
Short: "Validate dbg configs",
RunE: execute,
RunE: executeConfigs,
}
return cmd
}

func execute(c *cobra.Command, args []string) error {
func executeConfigs(c *cobra.Command, args []string) error {
options := validate.Options{
Options: root.LoadRootOptions(),
}
Expand Down

0 comments on commit 6e655bc

Please sign in to comment.