Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
23996b25
Unverified
Commit
23996b25
authored
Aug 01, 2018
by
Ibrahim AshShohail
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change TRUNCATED to DATA+OMITTED in kubectl config view
Signed-off-by:
Ibrahim AshShohail
<
me@ibrasho.com
>
parent
99133f51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
helpers.go
staging/src/k8s.io/client-go/tools/clientcmd/api/helpers.go
+7
-2
helpers_test.go
.../src/k8s.io/client-go/tools/clientcmd/api/helpers_test.go
+4
-3
No files found.
staging/src/k8s.io/client-go/tools/clientcmd/api/helpers.go
View file @
23996b25
...
@@ -29,6 +29,8 @@ import (
...
@@ -29,6 +29,8 @@ import (
func
init
()
{
func
init
()
{
sDec
,
_
:=
base64
.
StdEncoding
.
DecodeString
(
"REDACTED+"
)
sDec
,
_
:=
base64
.
StdEncoding
.
DecodeString
(
"REDACTED+"
)
redactedBytes
=
[]
byte
(
string
(
sDec
))
redactedBytes
=
[]
byte
(
string
(
sDec
))
sDec
,
_
=
base64
.
StdEncoding
.
DecodeString
(
"DATA+OMITTED"
)
dataOmittedBytes
=
[]
byte
(
string
(
sDec
))
}
}
// IsConfigEmpty returns true if the config is empty.
// IsConfigEmpty returns true if the config is empty.
...
@@ -79,7 +81,10 @@ func MinifyConfig(config *Config) error {
...
@@ -79,7 +81,10 @@ func MinifyConfig(config *Config) error {
return
nil
return
nil
}
}
var
redactedBytes
[]
byte
var
(
redactedBytes
[]
byte
dataOmittedBytes
[]
byte
)
// Flatten redacts raw data entries from the config object for a human-readable view.
// Flatten redacts raw data entries from the config object for a human-readable view.
func
ShortenConfig
(
config
*
Config
)
{
func
ShortenConfig
(
config
*
Config
)
{
...
@@ -97,7 +102,7 @@ func ShortenConfig(config *Config) {
...
@@ -97,7 +102,7 @@ func ShortenConfig(config *Config) {
}
}
for
key
,
cluster
:=
range
config
.
Clusters
{
for
key
,
cluster
:=
range
config
.
Clusters
{
if
len
(
cluster
.
CertificateAuthorityData
)
>
0
{
if
len
(
cluster
.
CertificateAuthorityData
)
>
0
{
cluster
.
CertificateAuthorityData
=
redac
tedBytes
cluster
.
CertificateAuthorityData
=
dataOmit
tedBytes
}
}
config
.
Clusters
[
key
]
=
cluster
config
.
Clusters
[
key
]
=
cluster
}
}
...
...
staging/src/k8s.io/client-go/tools/clientcmd/api/helpers_test.go
View file @
23996b25
...
@@ -229,7 +229,7 @@ func Example_minifyAndShorten() {
...
@@ -229,7 +229,7 @@ func Example_minifyAndShorten() {
// clusters:
// clusters:
// cow-cluster:
// cow-cluster:
// LocationOfOrigin: ""
// LocationOfOrigin: ""
// certificate-authority-data:
REDAC
TED
// certificate-authority-data:
DATA+OMIT
TED
// server: http://cow.org:8080
// server: http://cow.org:8080
// contexts:
// contexts:
// federal-context:
// federal-context:
...
@@ -276,14 +276,15 @@ func TestShortenSuccess(t *testing.T) {
...
@@ -276,14 +276,15 @@ func TestShortenSuccess(t *testing.T) {
}
}
redacted
:=
string
(
redactedBytes
)
redacted
:=
string
(
redactedBytes
)
dataOmitted
:=
string
(
dataOmittedBytes
)
if
len
(
mutatingConfig
.
Clusters
)
!=
2
{
if
len
(
mutatingConfig
.
Clusters
)
!=
2
{
t
.
Errorf
(
"unexpected clusters: %v"
,
mutatingConfig
.
Clusters
)
t
.
Errorf
(
"unexpected clusters: %v"
,
mutatingConfig
.
Clusters
)
}
}
if
!
reflect
.
DeepEqual
(
startingConfig
.
Clusters
[
unchangingCluster
],
mutatingConfig
.
Clusters
[
unchangingCluster
])
{
if
!
reflect
.
DeepEqual
(
startingConfig
.
Clusters
[
unchangingCluster
],
mutatingConfig
.
Clusters
[
unchangingCluster
])
{
t
.
Errorf
(
"expected %v, got %v"
,
startingConfig
.
Clusters
[
unchangingCluster
],
mutatingConfig
.
Clusters
[
unchangingCluster
])
t
.
Errorf
(
"expected %v, got %v"
,
startingConfig
.
Clusters
[
unchangingCluster
],
mutatingConfig
.
Clusters
[
unchangingCluster
])
}
}
if
string
(
mutatingConfig
.
Clusters
[
changingCluster
]
.
CertificateAuthorityData
)
!=
redac
ted
{
if
string
(
mutatingConfig
.
Clusters
[
changingCluster
]
.
CertificateAuthorityData
)
!=
dataOmit
ted
{
t
.
Errorf
(
"expected %v, got %v"
,
redac
ted
,
string
(
mutatingConfig
.
Clusters
[
changingCluster
]
.
CertificateAuthorityData
))
t
.
Errorf
(
"expected %v, got %v"
,
dataOmit
ted
,
string
(
mutatingConfig
.
Clusters
[
changingCluster
]
.
CertificateAuthorityData
))
}
}
if
len
(
mutatingConfig
.
AuthInfos
)
!=
2
{
if
len
(
mutatingConfig
.
AuthInfos
)
!=
2
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment