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
93033275
Commit
93033275
authored
May 24, 2016
by
Doug Davis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `CreatedByAnnotation` contant
A nit but didn't want the strings to get out of sync. Signed-off-by:
Doug Davis
<
dug@us.ibm.com
>
parent
02de0092
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
13 deletions
+13
-13
helpers.go
pkg/api/helpers.go
+4
-0
controller_utils.go
pkg/controller/controller_utils.go
+1
-3
annotate_test.go
pkg/kubectl/cmd/annotate_test.go
+2
-2
drain.go
pkg/kubectl/cmd/drain.go
+1
-2
drain_test.go
pkg/kubectl/cmd/drain_test.go
+4
-5
describe.go
pkg/kubectl/describe.go
+1
-1
No files found.
pkg/api/helpers.go
View file @
93033275
...
...
@@ -424,6 +424,10 @@ const (
// SeccompContainerAnnotationKeyPrefix represents the key of a seccomp profile applied
// to one container of a pod.
SeccompContainerAnnotationKeyPrefix
string
=
"container.seccomp.security.alpha.kubernetes.io/"
// CreatedByAnnotation represents the key used to store the spec(json)
// used to create the resource.
CreatedByAnnotation
=
"kubernetes.io/created-by"
)
// GetAffinityFromPod gets the json serialized affinity data from Pod.Annotations
...
...
pkg/controller/controller_utils.go
View file @
93033275
...
...
@@ -40,8 +40,6 @@ import (
)
const
(
CreatedByAnnotation
=
"kubernetes.io/created-by"
// If a watch drops a delete event for a pod, it'll take this long
// before a dormant controller waiting for those packets is woken up anyway. It is
// specifically targeted at the case where some problem prevents an update
...
...
@@ -392,7 +390,7 @@ func getPodsAnnotationSet(template *api.PodTemplateSpec, object runtime.Object)
if
err
!=
nil
{
return
desiredAnnotations
,
fmt
.
Errorf
(
"unable to serialize controller reference: %v"
,
err
)
}
desiredAnnotations
[
CreatedByAnnotation
]
=
string
(
createdByRefJson
)
desiredAnnotations
[
api
.
CreatedByAnnotation
]
=
string
(
createdByRefJson
)
return
desiredAnnotations
,
nil
}
...
...
pkg/kubectl/cmd/annotate_test.go
View file @
93033275
...
...
@@ -116,8 +116,8 @@ func TestParseAnnotations(t *testing.T) {
expectErr
:
false
,
},
{
annotations
:
[]
string
{
"url="
+
testURL
,
"kubernetes.io/created-by
="
+
testJSON
},
expected
:
map
[
string
]
string
{
"url"
:
testURL
,
"kubernetes.io/created-by"
:
testJSON
},
annotations
:
[]
string
{
"url="
+
testURL
,
api
.
CreatedByAnnotation
+
"
="
+
testJSON
},
expected
:
map
[
string
]
string
{
"url"
:
testURL
,
api
.
CreatedByAnnotation
:
testJSON
},
expectedRemove
:
[]
string
{},
scenario
:
"add annotations with special characters"
,
expectErr
:
false
,
...
...
pkg/kubectl/cmd/drain.go
View file @
93033275
...
...
@@ -29,7 +29,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/fields"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
...
...
@@ -238,7 +237,7 @@ func (o *DrainOptions) getController(sr *api.SerializedReference) (interface{},
}
func
(
o
*
DrainOptions
)
getPodCreator
(
pod
api
.
Pod
)
(
*
api
.
SerializedReference
,
error
)
{
creatorRef
,
found
:=
pod
.
ObjectMeta
.
Annotations
[
controller
.
CreatedByAnnotation
]
creatorRef
,
found
:=
pod
.
ObjectMeta
.
Annotations
[
api
.
CreatedByAnnotation
]
if
!
found
{
return
nil
,
nil
}
...
...
pkg/kubectl/cmd/drain_test.go
View file @
93033275
...
...
@@ -36,7 +36,6 @@ import (
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/conversion"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/runtime"
...
...
@@ -219,7 +218,7 @@ func TestDrain(t *testing.T) {
}
rc_anno
:=
make
(
map
[
string
]
string
)
rc_anno
[
controller
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
rc
)
rc_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
rc
)
rc_pod
:=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
@@ -247,7 +246,7 @@ func TestDrain(t *testing.T) {
}
ds_anno
:=
make
(
map
[
string
]
string
)
ds_anno
[
controller
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
ds
)
ds_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
ds
)
ds_pod
:=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
@@ -280,7 +279,7 @@ func TestDrain(t *testing.T) {
Namespace
:
"default"
,
CreationTimestamp
:
unversioned
.
Time
{
Time
:
time
.
Now
()},
Labels
:
labels
,
Annotations
:
map
[
string
]
string
{
controller
.
CreatedByAnnotation
:
refJson
(
t
,
&
job
)},
Annotations
:
map
[
string
]
string
{
api
.
CreatedByAnnotation
:
refJson
(
t
,
&
job
)},
},
}
...
...
@@ -298,7 +297,7 @@ func TestDrain(t *testing.T) {
}
rs_anno
:=
make
(
map
[
string
]
string
)
rs_anno
[
controller
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
rs
)
rs_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
rs
)
rs_pod
:=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
pkg/kubectl/describe.go
View file @
93033275
...
...
@@ -549,7 +549,7 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
}
func
printControllers
(
annotation
map
[
string
]
string
)
string
{
value
,
ok
:=
annotation
[
"kubernetes.io/created-by"
]
value
,
ok
:=
annotation
[
api
.
CreatedByAnnotation
]
if
ok
{
var
r
api
.
SerializedReference
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
r
)
...
...
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