Files
warewulf/internal/app/wwctl/container/copy/root.go
Jonathon Anderson a80ba8ee01 Configure nodes.conf path dynamically from config
Removes the use of init() to initialize the variable.

- Closes: #1596
- See also: #1569

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
2024-12-17 11:04:43 -07:00

36 lines
1.0 KiB
Go

package copy
import (
"github.com/spf13/cobra"
"github.com/warewulf/warewulf/internal/pkg/container"
)
var (
baseCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Use: "copy CONTAINER NEW_NAME",
Aliases: []string{"cp"},
Short: "Copy an existing container",
Long: "This command will duplicate an imported container image.",
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
},
}
Build bool
)
func init() {
baseCmd.PersistentFlags().BoolVarP(&Build, "build", "b", false, "Build container after copy")
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}