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
0b8e25cd
Commit
0b8e25cd
authored
Apr 25, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assign label to pod when exec 'kubectl run' command with flags "--expose=true"…
Assign label to pod when exec 'kubectl run' command with flags "--expose=true" and "--restart=Never"
parent
82cde218
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
run.go
pkg/kubectl/run.go
+8
-8
run_test.go
pkg/kubectl/run_test.go
+8
-4
No files found.
pkg/kubectl/run.go
View file @
0b8e25cd
...
...
@@ -76,7 +76,7 @@ func (DeploymentV1Beta1) Generate(genericParams map[string]interface{}) (runtime
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
true
,
name
)
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -165,7 +165,7 @@ func (DeploymentAppsV1Beta1) Generate(genericParams map[string]interface{}) (run
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
true
,
name
)
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -210,7 +210,7 @@ func (DeploymentAppsV1Beta1) Generate(genericParams map[string]interface{}) (run
}
// getLabels returns map of labels.
func
getLabels
(
params
map
[
string
]
string
,
defaultRunLabel
bool
,
name
string
)
(
map
[
string
]
string
,
error
)
{
func
getLabels
(
params
map
[
string
]
string
,
name
string
)
(
map
[
string
]
string
,
error
)
{
labelString
,
found
:=
params
[
"labels"
]
var
labels
map
[
string
]
string
var
err
error
...
...
@@ -219,7 +219,7 @@ func getLabels(params map[string]string, defaultRunLabel bool, name string) (map
if
err
!=
nil
{
return
nil
,
err
}
}
else
if
defaultRunLabel
{
}
else
{
labels
=
map
[
string
]
string
{
"run"
:
name
,
}
...
...
@@ -330,7 +330,7 @@ func (JobV1) Generate(genericParams map[string]interface{}) (runtime.Object, err
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
true
,
name
)
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -424,7 +424,7 @@ func (CronJobV2Alpha1) Generate(genericParams map[string]interface{}) (runtime.O
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
true
,
name
)
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -637,7 +637,7 @@ func (BasicReplicationController) Generate(genericParams map[string]interface{})
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
true
,
name
)
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -785,7 +785,7 @@ func (BasicPod) Generate(genericParams map[string]interface{}) (runtime.Object,
return
nil
,
err
}
labels
,
err
:=
getLabels
(
params
,
false
,
name
)
labels
,
err
:=
getLabels
(
params
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/kubectl/run_test.go
View file @
0b8e25cd
...
...
@@ -417,7 +417,8 @@ func TestGeneratePod(t *testing.T) {
},
expected
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"run"
:
"foo"
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
...
...
@@ -451,7 +452,8 @@ func TestGeneratePod(t *testing.T) {
},
expected
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"run"
:
"foo"
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
...
...
@@ -484,7 +486,8 @@ func TestGeneratePod(t *testing.T) {
},
expected
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"run"
:
"foo"
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
...
...
@@ -513,7 +516,8 @@ func TestGeneratePod(t *testing.T) {
},
expected
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"run"
:
"foo"
},
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
...
...
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