Skip to content

Commit c6e3648

Browse files
committed
import auth plugins, consolidate main & rootcmd
Signed-off-by: Ahmet Alp Balkan <[email protected]>
1 parent a2ead15 commit c6e3648

File tree

4 files changed

+20
-49
lines changed

4 files changed

+20
-49
lines changed

cmd/kubectl-tree/client.go

-17
This file was deleted.

cmd/kubectl-tree/main.go

-29
This file was deleted.

cmd/kubectl-tree/rootcmd.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ import (
2020
"github.com/spf13/cobra"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/cli-runtime/pkg/genericclioptions"
23+
"k8s.io/client-go/dynamic"
2324
"os"
2425
"strings"
26+
27+
_ "k8s.io/client-go/plugin/pkg/client/auth" // combined authprovider import
2528
)
2629

2730
var cf *genericclioptions.ConfigFlags
@@ -37,16 +40,16 @@ var rootCmd = &cobra.Command{
3740
RunE: run,
3841
}
3942

40-
func run(cmd *cobra.Command, args []string) error {
43+
func run(_ *cobra.Command, args []string) error {
4144
restConfig, err := cf.ToRESTConfig()
4245
if err != nil {
4346
return err
4447
}
4548
restConfig.QPS = 1000
4649
restConfig.Burst = 1000
47-
dyn, err := dynamicClient(restConfig)
50+
dyn, err := dynamic.NewForConfig(restConfig)
4851
if err != nil {
49-
return err
52+
return fmt.Errorf("failed to construct dynamic client: %w", err)
5053
}
5154
dc, err := cf.ToDiscoveryClient()
5255
if err != nil {
@@ -92,3 +95,12 @@ func run(cmd *cobra.Command, args []string) error {
9295
treeView(os.Stderr, objs, *obj)
9396
return nil
9497
}
98+
99+
func main() {
100+
cf = genericclioptions.NewConfigFlags(true)
101+
cf.AddFlags(rootCmd.Flags())
102+
if err := rootCmd.Execute(); err != nil {
103+
os.Exit(1)
104+
}
105+
}
106+

go.sum

+5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo=
55
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
66
cloud.google.com/go v0.43.0 h1:banaiRPAM8kUVYneOSkhgcDsLzEvL25FinuiSZaH/2w=
77
cloud.google.com/go v0.43.0/go.mod h1:BOSR3VbTLkk6FDC/TcffxP4NF/FFBGA5ku+jvKOP7pg=
8+
github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs=
89
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
10+
github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU=
911
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
12+
github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM=
1013
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
1114
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
15+
github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0=
1216
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
1317
github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY=
1418
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
@@ -97,6 +101,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
97101
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
98102
github.com/googleapis/gnostic v0.3.0 h1:CcQijm0XKekKjP/YCz28LXVSpgguuB+nCxaSjCe09y0=
99103
github.com/googleapis/gnostic v0.3.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
104+
github.com/gophercloud/gophercloud v0.1.0 h1:P/nh25+rzXouhytV2pUHBb65fnds26Ghl8/391+sT5o=
100105
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
101106
github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY=
102107
github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo=

0 commit comments

Comments
 (0)