@@ -54,6 +54,7 @@ func (p ByPodName) Less(i, j int) bool { return p[i].podName < p[j].podName }
54
54
func (p ByPodName ) Swap (i , j int ) { p [i ], p [j ] = p [j ], p [i ] }
55
55
56
56
func main () {
57
+ kubeconfigEnv := os .Getenv ("KUBECONFIG" )
57
58
kubeconfig := flag .String ("kubeconfig" , "" , "Path to the kubeconfig file" )
58
59
container := flag .String ("c" , "" , "Container to execute the command against" )
59
60
labelSelector := flag .String ("l" , "" , "Label selector to filter pods" )
@@ -81,6 +82,11 @@ func main() {
81
82
fmt .Println ("Error: command to execute is required" )
82
83
os .Exit (1 )
83
84
}
85
+ fmt .Printf ("before kubeconfig: %v" , * kubeconfig )
86
+ if kubeconfig == nil || len (* kubeconfig ) == 0 && len (kubeconfigEnv ) > 0 {
87
+ kubeconfig = & kubeconfigEnv
88
+ }
89
+ fmt .Printf ("after kubeconfig: %v" , * kubeconfig )
84
90
85
91
config , err := clientcmd .BuildConfigFromFlags ("" , * kubeconfig )
86
92
if err != nil {
@@ -90,6 +96,7 @@ func main() {
90
96
}
91
97
}
92
98
99
+ fmt .Println ("hi" )
93
100
clientset , err := kubernetes .NewForConfig (config )
94
101
if err != nil {
95
102
panic (err )
@@ -102,6 +109,7 @@ func main() {
102
109
panic (err )
103
110
}
104
111
112
+ fmt .Println ("hi" )
105
113
var wg sync.WaitGroup
106
114
resultsChan := make (chan PodResult , len (pods .Items ))
107
115
@@ -121,6 +129,7 @@ func main() {
121
129
results = append (results , result )
122
130
}
123
131
132
+ fmt .Println ("hi" )
124
133
sort .Sort (ByPodName (results ))
125
134
126
135
for _ , result := range results {
0 commit comments