dynamic nouns for 'wwwctl container'

This commit is contained in:
Christian Goll
2021-09-24 10:50:54 +02:00
parent c097c15b13
commit 8010cd2435
3 changed files with 32 additions and 5 deletions

View File

@@ -1,6 +1,9 @@
package build
import "github.com/spf13/cobra"
import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
@@ -9,6 +12,13 @@ var (
Long: "This command will build a bootable VNFS image from an imported container image.",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
list, _ := container.ListSources()
return list, cobra.ShellCompDirectiveNoFileComp
},
}
BuildForce bool
BuildAll bool

View File

@@ -1,6 +1,9 @@
package delete
import "github.com/spf13/cobra"
import (
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
@@ -8,7 +11,13 @@ var (
Short: "Delete an imported container",
Long: "This command will delete a container that has been imported into Warewulf.",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
list, _ := container.ListSources()
return list, cobra.ShellCompDirectiveNoFileComp
},
}
)

View File

@@ -2,6 +2,7 @@ package exec
import (
"github.com/hpcng/warewulf/internal/app/wwctl/container/exec/child"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/spf13/cobra"
)
@@ -12,8 +13,15 @@ var (
Long: "This command will allow you to run any command inside of a given\n" +
"warewulf container. This is commonly used with an interactive shell such as /bin/bash\n" +
"to run a virtual environment within the container.",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(2),
RunE: CobraRunE,
Args: cobra.MinimumNArgs(2),
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
list, _ := container.ListSources()
return list, cobra.ShellCompDirectiveNoFileComp
},
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
}
binds []string