Move wwctl kernel list to wwctl container kernels
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
committed by
Christian Goll
parent
098c288ce2
commit
6f4d33b19e
@@ -3,6 +3,7 @@ package completions
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/warewulf/warewulf/internal/pkg/container"
|
||||
"github.com/warewulf/warewulf/internal/pkg/hostlist"
|
||||
"github.com/warewulf/warewulf/internal/pkg/kernel"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
@@ -46,3 +47,8 @@ func ProfileKernelVersion(cmd *cobra.Command, args []string, toComplete string)
|
||||
}
|
||||
return kernelVersions, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func Containers(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
sources, _ := container.ListSources()
|
||||
return sources, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package list
|
||||
package kernels
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
@@ -28,9 +28,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
sources, err := container.ListSources()
|
||||
if err != nil {
|
||||
return err
|
||||
var sources []string
|
||||
if len(args) == 0 {
|
||||
if sources_, err := container.ListSources(); err == nil {
|
||||
sources = sources_
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
sources = args
|
||||
}
|
||||
|
||||
t := table.New(cmd.OutOrStdout())
|
||||
@@ -1,4 +1,4 @@
|
||||
package list
|
||||
package kernels
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -52,6 +52,32 @@ container2 /boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64 5.14.0-284.
|
||||
container2 /boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64 5.14.0-362.24.1 false 0
|
||||
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64 5.14.0-427.31.1 true 0
|
||||
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.31.1 false 0
|
||||
`,
|
||||
},
|
||||
"single container": {
|
||||
files: map[string][]string{
|
||||
"container1": []string{
|
||||
"/boot/vmlinuz-5.14.0-427.18.1.el9_4.x86_64",
|
||||
"/boot/vmlinuz-5.14.0-427.24.1.el9_4.x86_64",
|
||||
"/boot/vmlinuz-4.14.0-427.18.1.el8_4.x86_64",
|
||||
},
|
||||
"container2": []string{
|
||||
"/boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0",
|
||||
"/boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64",
|
||||
"/boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug",
|
||||
"/boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64",
|
||||
"/boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64",
|
||||
},
|
||||
},
|
||||
args: []string{"container2"},
|
||||
stdout: `
|
||||
Container Kernel Version Preferred Nodes
|
||||
--------- ------ ------- --------- -----
|
||||
container2 /boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0 -- false 0
|
||||
container2 /boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64 5.14.0-284.30.1 false 0
|
||||
container2 /boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64 5.14.0-362.24.1 false 0
|
||||
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64 5.14.0-427.31.1 true 0
|
||||
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.31.1 false 0
|
||||
`,
|
||||
},
|
||||
}
|
||||
@@ -1,22 +1,23 @@
|
||||
package list
|
||||
package kernels
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/completions"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "list [OPTIONS]",
|
||||
Short: "List available kernels",
|
||||
Use: "kernels [OPTIONS]",
|
||||
Short: "List available container kernels",
|
||||
Long: "This command lists the kernels that are available in the imported containers.",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.ExactArgs(0),
|
||||
Aliases: []string{"ls"},
|
||||
Aliases: []string{"kernel"},
|
||||
ValidArgsFunction: completions.Containers,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/delete"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/exec"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/imprt"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/kernels"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/list"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/rename"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container/shell"
|
||||
@@ -35,6 +36,7 @@ func init() {
|
||||
baseCmd.AddCommand(syncuser.GetCommand())
|
||||
baseCmd.AddCommand(copy.GetCommand())
|
||||
baseCmd.AddCommand(rename.GetCommand())
|
||||
baseCmd.AddCommand(kernels.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package kernel
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/kernel/list"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "kernel COMMAND [OPTIONS]",
|
||||
Short: "Kernel Management",
|
||||
Long: "This command manages kernels available to Warewulf",
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(list.GetCommand())
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/configure"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/container"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/genconf"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/kernel"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/node"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/overlay"
|
||||
"github.com/warewulf/warewulf/internal/app/wwctl/power"
|
||||
@@ -52,7 +51,6 @@ func init() {
|
||||
rootCmd.AddCommand(overlay.GetCommand())
|
||||
rootCmd.AddCommand(container.GetCommand())
|
||||
rootCmd.AddCommand(node.GetCommand())
|
||||
rootCmd.AddCommand(kernel.GetCommand())
|
||||
rootCmd.AddCommand(power.GetCommand())
|
||||
rootCmd.AddCommand(profile.GetCommand())
|
||||
rootCmd.AddCommand(configure.GetCommand())
|
||||
|
||||
Reference in New Issue
Block a user