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
f6c9ab43
Commit
f6c9ab43
authored
Jan 04, 2017
by
Michael Fraenkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if key is a valid after prefix is prepended
- Allow invalid keys to become valid by requiring a prefix
parent
cb783497
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+3
-4
kubelet_pods_test.go
pkg/kubelet/kubelet_pods_test.go
+29
-1
No files found.
pkg/kubelet/kubelet_pods.go
View file @
f6c9ab43
...
...
@@ -437,13 +437,12 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *v1.Pod, container *v1.Container
configMaps
[
name
]
=
configMap
}
for
k
,
v
:=
range
configMap
.
Data
{
if
errMsgs
:=
utilvalidation
.
IsCIdentifier
(
k
);
len
(
errMsgs
)
!=
0
{
return
result
,
fmt
.
Errorf
(
"Invalid environment variable name, %v, from configmap %v/%v: %s"
,
k
,
pod
.
Namespace
,
name
,
errMsgs
[
0
])
}
if
len
(
envFrom
.
Prefix
)
>
0
{
k
=
envFrom
.
Prefix
+
k
}
if
errMsgs
:=
utilvalidation
.
IsCIdentifier
(
k
);
len
(
errMsgs
)
!=
0
{
return
result
,
fmt
.
Errorf
(
"Invalid environment variable name, %v, from configmap %v/%v: %s"
,
k
,
pod
.
Namespace
,
name
,
errMsgs
[
0
])
}
// Accesses apiserver+Pods.
// So, the master may set service env vars, or kubelet may. In case both are doing
// it, we delete the key from the kubelet-generated ones so we don't have duplicate
...
...
pkg/kubelet/kubelet_pods_test.go
View file @
f6c9ab43
...
...
@@ -728,11 +728,39 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Name
:
"test-configmap"
,
},
Data
:
map
[
string
]
string
{
"
-
1234"
:
"abc"
,
"1234"
:
"abc"
,
},
},
expectedError
:
true
,
},
{
name
:
"configmap_invalid_keys_valid"
,
ns
:
"test"
,
container
:
&
v1
.
Container
{
EnvFrom
:
[]
v1
.
EnvFromSource
{
{
Prefix
:
"p_"
,
ConfigMapRef
:
&
v1
.
ConfigMapEnvSource
{
LocalObjectReference
:
v1
.
LocalObjectReference
{
Name
:
"test-config-map"
}},
},
},
},
masterServiceNs
:
""
,
configMap
:
&
v1
.
ConfigMap
{
ObjectMeta
:
v1
.
ObjectMeta
{
Namespace
:
"test1"
,
Name
:
"test-configmap"
,
},
Data
:
map
[
string
]
string
{
"1234"
:
"abc"
,
},
},
expectedEnvs
:
[]
kubecontainer
.
EnvVar
{
{
Name
:
"p_1234"
,
Value
:
"abc"
,
},
},
},
}
for
_
,
tc
:=
range
testCases
{
...
...
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