Changed kubectl config view to redact token

Kubernetes-commit: 6fad4ee5e5f5fa6fbf38e88f165b012fa0ae5795
This commit is contained in:
Brian Pursley 2020-03-17 15:13:50 -04:00 committed by Kubernetes Publisher
parent da706024f3
commit d4a54d1ba8
2 changed files with 7 additions and 1 deletions

View File

@ -98,6 +98,9 @@ func ShortenConfig(config *Config) {
if len(authInfo.ClientCertificateData) > 0 {
authInfo.ClientCertificateData = redactedBytes
}
if len(authInfo.Token) > 0 {
authInfo.Token = "REDACTED"
}
config.AuthInfos[key] = authInfo
}
for key, cluster := range config.Clusters {

View File

@ -243,7 +243,7 @@ func Example_minifyAndShorten() {
// LocationOfOrigin: ""
// client-certificate-data: REDACTED
// client-key-data: REDACTED
// token: red-token
// token: REDACTED
}
func TestShortenSuccess(t *testing.T) {
@ -299,4 +299,7 @@ func TestShortenSuccess(t *testing.T) {
if string(mutatingConfig.AuthInfos[changingAuthInfo].ClientKeyData) != redacted {
t.Errorf("expected %v, got %v", redacted, string(mutatingConfig.AuthInfos[changingAuthInfo].ClientKeyData))
}
if mutatingConfig.AuthInfos[changingAuthInfo].Token != "REDACTED" {
t.Errorf("expected REDACTED, got %v", mutatingConfig.AuthInfos[changingAuthInfo].Token)
}
}