Merge pull request #26237 from duglin/UseConstant

Automatic merge from submit-queue

Use `CreatedByAnnotation` constant

A nit but didn't want the strings to get out of sync.

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
k8s-merge-robot 2016-07-01 16:55:39 -07:00 committed by GitHub
commit 739e3dd1b1
6 changed files with 13 additions and 13 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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,

View File

@ -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"
@ -240,7 +239,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
}

View File

@ -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{

View File

@ -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)