Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit f95cfc9

Browse files
Merge pull request #1221 from ibuildthecloud/eks-panic
Fix panic when using external auth provider
2 parents f52ceff + 24e6648 commit f95cfc9

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

integration/projectconfig/projectconfig_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestCLIConfig(t *testing.T) {
4343
opt project.Options
4444
kubeconfigEnv string
4545
homeEnv string
46+
noEnv bool
4647
wantProject string
4748
wantNamespace string
4849
wantRestConfigHost string
@@ -130,9 +131,11 @@ func TestCLIConfig(t *testing.T) {
130131
wantNamespace: "projectnamespace",
131132
},
132133
{
133-
name: "No config",
134-
wantError: true,
135-
homeEnv: "garbage",
134+
name: "No config",
135+
wantError: true,
136+
noEnv: true,
137+
kubeconfigEnv: "garbage",
138+
homeEnv: "garbage",
136139
},
137140
{
138141
name: "No config, but user requested project",
@@ -200,8 +203,16 @@ func TestCLIConfig(t *testing.T) {
200203

201204
for _, test := range tests {
202205
t.Run(test.name, func(t *testing.T) {
206+
oldEnv := os.Environ()
203207
oldHome := os.Getenv("HOME")
208+
oldKubeconfig := os.Getenv("KUBECONFIG")
204209
oldRecommendHomeFile := clientcmd.RecommendedHomeFile
210+
if test.noEnv {
211+
for _, env := range oldEnv {
212+
k, _, _ := strings.Cut(env, "=")
213+
os.Setenv(k, "")
214+
}
215+
}
205216
if test.kubeconfigEnv != "" {
206217
os.Setenv("KUBECONFIG", test.kubeconfigEnv)
207218
}
@@ -211,7 +222,11 @@ func TestCLIConfig(t *testing.T) {
211222
}
212223
c, err := testCLIConfig(t, test.opt)
213224
assert.Equal(t, test.wantError, err != nil, "should have error")
214-
os.Setenv("KUBECONFIG", "")
225+
for _, env := range oldEnv {
226+
k, v, _ := strings.Cut(env, "=")
227+
os.Setenv(k, v)
228+
}
229+
os.Setenv("KUBECONFIG", oldKubeconfig)
215230
os.Setenv("HOME", oldHome)
216231
clientcmd.RecommendedHomeFile = oldRecommendHomeFile
217232
if test.wantErr != nil {

pkg/k8schannel/dialer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ func GetHeadersFor(cfg *rest.Config) (http.Header, error) {
6565
return nil, err
6666
}
6767
_, err = rt.RoundTrip(&http.Request{
68-
URL: &url.URL{},
68+
Header: http.Header{},
69+
URL: &url.URL{},
6970
})
7071
return headerCapture.headers, err
7172
}

0 commit comments

Comments
 (0)