/
kubeconfig.go
37 lines (33 loc) · 1.09 KB
/
kubeconfig.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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// nolint: dupl,golint
package cmd
import (
"github.com/autonomy/talos/internal/app/osctl/internal/client"
"github.com/autonomy/talos/internal/app/osctl/internal/helpers"
"github.com/autonomy/talos/internal/pkg/constants"
"github.com/spf13/cobra"
)
// kubeconfigCmd represents the kubeconfig command
var kubeconfigCmd = &cobra.Command{
Use: "kubeconfig",
Short: "Download the admin.conf from the node",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
creds, err := client.NewDefaultClientCredentials(talosconfig)
if err != nil {
helpers.Fatalf("error getting client credentials: %s", err)
}
c, err := client.NewClient(constants.OsdPort, creds)
if err != nil {
helpers.Fatalf("error constructing client: %s", err)
}
if err := c.Kubeconfig(); err != nil {
helpers.Fatalf("error fetching kubeconfig: %s", err)
}
},
}
func init() {
rootCmd.AddCommand(kubeconfigCmd)
}