forked from siderolabs/talos
/
dmesg.go
43 lines (39 loc) · 785 Bytes
/
dmesg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd
import (
"fmt"
"os"
"github.com/autonomy/dianemo/src/initramfs/cmd/osctl/pkg/client"
"github.com/spf13/cobra"
)
// dmesgCmd represents the dmesg command
var dmesgCmd = &cobra.Command{
Use: "dmesg",
Short: "Retrieve kernel logs",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 {
if err := cmd.Usage(); err != nil {
// TODO: How should we handle this?
os.Exit(1)
}
os.Exit(1)
}
creds, err := client.NewDefaultClientCredentials()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
c, err := client.NewClient(port, creds)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := c.Dmesg(); err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}
func init() {
rootCmd.AddCommand(dmesgCmd)
}