-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(config): Fix kubeconfig loading when exec auth command contains s…
…paces Signed-off-by: Sun Seng David TAN <[email protected]>
- Loading branch information
Showing
9 changed files
with
208 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
kubernetes-client-api/src/test/resources/test-kubeconfig-exec-args-with-spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v1 | ||
kind: Config | ||
clusters: | ||
- cluster: | ||
server: https://wherever | ||
name: test | ||
contexts: | ||
- context: | ||
cluster: test | ||
user: test | ||
name: test | ||
current-context: test | ||
users: | ||
- name: test | ||
user: | ||
exec: | ||
apiVersion: client.authentication.k8s.io/v1alpha1 | ||
args: | ||
- "w o r l d" | ||
command: "./token-generator" | ||
env: | ||
- name: PART1 | ||
value: hello |
23 changes: 23 additions & 0 deletions
23
kubernetes-client-api/src/test/resources/test-kubeconfig-exec-args-with-spaces-windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v1 | ||
kind: Config | ||
clusters: | ||
- cluster: | ||
server: https://wherever | ||
name: test | ||
contexts: | ||
- context: | ||
cluster: test | ||
user: test | ||
name: test | ||
current-context: test | ||
users: | ||
- name: test | ||
user: | ||
exec: | ||
apiVersion: client.authentication.k8s.io/v1alpha1 | ||
args: | ||
- "w o r l d" | ||
command: ".\\token-generator-win.bat" | ||
env: | ||
- name: PART1 | ||
value: hello |
23 changes: 23 additions & 0 deletions
23
kubernetes-client-api/src/test/resources/test-kubeconfig-exec-with-spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v1 | ||
kind: Config | ||
clusters: | ||
- cluster: | ||
server: https://wherever | ||
name: test | ||
contexts: | ||
- context: | ||
cluster: test | ||
user: test | ||
name: test | ||
current-context: test | ||
users: | ||
- name: test | ||
user: | ||
exec: | ||
apiVersion: client.authentication.k8s.io/v1alpha1 | ||
args: | ||
- world | ||
command: "./token-generator with spaces" | ||
env: | ||
- name: PART1 | ||
value: hello |
23 changes: 23 additions & 0 deletions
23
kubernetes-client-api/src/test/resources/test-kubeconfig-exec-with-spaces-windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v1 | ||
kind: Config | ||
clusters: | ||
- cluster: | ||
server: https://wherever | ||
name: test | ||
contexts: | ||
- context: | ||
cluster: test | ||
user: test | ||
name: test | ||
current-context: test | ||
users: | ||
- name: test | ||
user: | ||
exec: | ||
apiVersion: client.authentication.k8s.io/v1alpha1 | ||
args: | ||
- world | ||
command: ".\\token-generator-win with spaces.bat" | ||
env: | ||
- name: PART1 | ||
value: hello |
12 changes: 12 additions & 0 deletions
12
kubernetes-client-api/src/test/resources/token-generator with spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
token=`echo $PART1 $1 | tr '[a-z]' '[A-Z]'` | ||
cat <<EOF | ||
{ | ||
"kind": "ExecCredential", | ||
"apiVersion": "client.authentication.k8s.io/v1alpha1", | ||
"spec": {}, | ||
"status": { | ||
"token": "$token" | ||
} | ||
} | ||
EOF |
37 changes: 37 additions & 0 deletions
37
kubernetes-client-api/src/test/resources/token-generator-win with spaces.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@REM | ||
@REM Copyright (C) 2015 Red Hat, Inc. | ||
@REM | ||
@REM Licensed under the Apache License, Version 2.0 (the "License"); | ||
@REM you may not use this file except in compliance with the License. | ||
@REM You may obtain a copy of the License at | ||
@REM | ||
@REM http://www.apache.org/licenses/LICENSE-2.0 | ||
@REM | ||
@REM Unless required by applicable law or agreed to in writing, software | ||
@REM distributed under the License is distributed on an "AS IS" BASIS, | ||
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
@REM See the License for the specific language governing permissions and | ||
@REM limitations under the License. | ||
@REM | ||
|
||
@echo off | ||
IF [%1]==[] ( | ||
SET token=%PART1% | ||
) ELSE ( | ||
SET token=%PART1% %~1 | ||
) | ||
|
||
CALL :upper token | ||
|
||
echo { | ||
echo "kind": "ExecCredential", | ||
echo "apiVersion": "client.authentication.k8s.io/v1alpha1", | ||
echo "spec": {}, | ||
echo "status": { | ||
echo "token": "%token%" | ||
echo } | ||
echo } | ||
GOTO :EOF | ||
|
||
:upper | ||
FOR %%a IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO CALL SET "%1=%%%1:%%a=%%a%%%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters