move deployment PodTemplate to be not a pointer

This commit is contained in:
Mike Danese
2015-10-26 16:20:43 -07:00
parent d5e680afbb
commit b0a41108af
13 changed files with 38 additions and 35 deletions

View File

@@ -49,7 +49,8 @@ func GetOldRCs(deployment extensions.Deployment, c client.Interface) ([]*api.Rep
rcLabelsSelector := labels.SelectorFromSet(rc.Spec.Selector)
if rcLabelsSelector.Matches(podLabelsSelector) {
// Filter out RC that has the same pod template spec as the deployment - that is the new RC.
if api.Semantic.DeepEqual(rc.Spec.Template, GetNewRCTemplate(deployment)) {
newRCTemplate := GetNewRCTemplate(deployment)
if api.Semantic.DeepEqual(rc.Spec.Template, &newRCTemplate) {
continue
}
oldRCs[rc.ObjectMeta.Name] = rc
@@ -74,7 +75,7 @@ func GetNewRC(deployment extensions.Deployment, c client.Interface) (*api.Replic
newRCTemplate := GetNewRCTemplate(deployment)
for _, rc := range rcList.Items {
if api.Semantic.DeepEqual(rc.Spec.Template, newRCTemplate) {
if api.Semantic.DeepEqual(rc.Spec.Template, &newRCTemplate) {
// This is the new RC.
return &rc, nil
}
@@ -84,9 +85,9 @@ func GetNewRC(deployment extensions.Deployment, c client.Interface) (*api.Replic
}
// Returns the desired PodTemplateSpec for the new RC corresponding to the given RC.
func GetNewRCTemplate(deployment extensions.Deployment) *api.PodTemplateSpec {
func GetNewRCTemplate(deployment extensions.Deployment) api.PodTemplateSpec {
// newRC will have the same template as in deployment spec, plus a unique label in some cases.
newRCTemplate := &api.PodTemplateSpec{
newRCTemplate := api.PodTemplateSpec{
ObjectMeta: deployment.Spec.Template.ObjectMeta,
Spec: deployment.Spec.Template.Spec,
}
@@ -113,7 +114,7 @@ func CloneAndAddLabel(labels map[string]string, labelKey string, labelValue uint
return newLabels
}
func GetPodTemplateSpecHash(template *api.PodTemplateSpec) uint32 {
func GetPodTemplateSpecHash(template api.PodTemplateSpec) uint32 {
podTemplateSpecHasher := adler32.New()
util.DeepHashObject(podTemplateSpecHasher, template)
return podTemplateSpecHasher.Sum32()