Skip to content

Commit

Permalink
refactor(storage): add frontend arg after storage
Browse files Browse the repository at this point in the history
Align with API structure and prepare to introducing backend Nvme

Signed-off-by: Artsiom Koltun <artsiom.koltun@intel.com>
  • Loading branch information
artek-koltun committed Jan 19, 2024
1 parent a4adbe2 commit 742ee44
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
46 changes: 42 additions & 4 deletions cmd/storage/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@ package frontend

import "github.com/spf13/cobra"

func NewCreateNvmeCommand() *cobra.Command {
// NewCreateCommand creates a new command to create frontend resources
func NewCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "frontend",
Aliases: []string{"f"},
Short: "Creates frontend resource",
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
err := c.Help()
cobra.CheckErr(err)
},
}

cmd.AddCommand(newCreateNvmeCommand())
cmd.AddCommand(newCreateVirtioCommand())

return cmd
}

func newCreateNvmeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "nvme",
Aliases: []string{"n"},
Expand All @@ -25,7 +44,7 @@ func NewCreateNvmeCommand() *cobra.Command {
return cmd
}

func NewCreateVirtioCommand() *cobra.Command {
func newCreateVirtioCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "virtio",
Aliases: []string{"v"},
Expand All @@ -42,7 +61,26 @@ func NewCreateVirtioCommand() *cobra.Command {
return cmd
}

func NewDeleteNvmeCommand() *cobra.Command {
// NewDeleteCommand creates a new command to delete frontend resources
func NewDeleteCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "frontend",
Aliases: []string{"f"},
Short: "Deletes frontend resource",
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
err := c.Help()
cobra.CheckErr(err)
},
}

cmd.AddCommand(newDeleteNvmeCommand())
cmd.AddCommand(newDeleteVirtioCommand())

return cmd
}

func newDeleteNvmeCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "nvme",
Aliases: []string{"n"},
Expand All @@ -61,7 +99,7 @@ func NewDeleteNvmeCommand() *cobra.Command {
return cmd
}

func NewDeleteVirtioCommand() *cobra.Command {
func newDeleteVirtioCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "virtio",
Aliases: []string{"v"},
Expand Down
6 changes: 2 additions & 4 deletions cmd/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ func newStorageCreateCommand() *cobra.Command {
},
}

cmd.AddCommand(frontend.NewCreateNvmeCommand())
cmd.AddCommand(frontend.NewCreateVirtioCommand())
cmd.AddCommand(frontend.NewCreateCommand())

return cmd
}
Expand All @@ -66,8 +65,7 @@ func newStorageDeleteCommand() *cobra.Command {
},
}

cmd.AddCommand(frontend.NewDeleteNvmeCommand())
cmd.AddCommand(frontend.NewDeleteVirtioCommand())
cmd.AddCommand(frontend.NewDeleteCommand())

return cmd
}

0 comments on commit 742ee44

Please sign in to comment.