Skip to content

Commit

Permalink
apps: copy all template ObjectMeta fields to avoid config trigger tri…
Browse files Browse the repository at this point in the history
…ggering
  • Loading branch information
mfojtik committed Oct 5, 2017
1 parent 78b3c01 commit 5d0e6ad
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions pkg/apps/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,20 +512,18 @@ func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) (
selector[deployapi.DeploymentConfigLabel] = config.Name
selector[deployapi.DeploymentLabel] = deploymentName

podLabels := make(labels.Set)
for k, v := range config.Spec.Template.Labels {
podLabels[k] = v
templateObjectMeta := config.Spec.Template.ObjectMeta
if templateObjectMeta.Labels == nil {
templateObjectMeta.Labels = map[string]string{}
}
podLabels[deployapi.DeploymentConfigLabel] = config.Name
podLabels[deployapi.DeploymentLabel] = deploymentName

podAnnotations := make(labels.Set)
for k, v := range config.Spec.Template.Annotations {
podAnnotations[k] = v
if templateObjectMeta.Annotations == nil {
templateObjectMeta.Annotations = map[string]string{}
}
podAnnotations[deployapi.DeploymentAnnotation] = deploymentName
podAnnotations[deployapi.DeploymentConfigAnnotation] = config.Name
podAnnotations[deployapi.DeploymentVersionAnnotation] = strconv.FormatInt(config.Status.LatestVersion, 10)
templateObjectMeta.Labels[deployapi.DeploymentConfigLabel] = config.Name
templateObjectMeta.Labels[deployapi.DeploymentLabel] = deploymentName
templateObjectMeta.Annotations[deployapi.DeploymentAnnotation] = deploymentName
templateObjectMeta.Annotations[deployapi.DeploymentConfigAnnotation] = config.Name
templateObjectMeta.Annotations[deployapi.DeploymentVersionAnnotation] = strconv.FormatInt(config.Status.LatestVersion, 10)

controllerRef := NewControllerRef(config)
zero := int32(0)
Expand All @@ -551,11 +549,8 @@ func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) (
Selector: selector,
MinReadySeconds: config.Spec.MinReadySeconds,
Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: podLabels,
Annotations: podAnnotations,
},
Spec: podSpec,
ObjectMeta: templateObjectMeta,
Spec: podSpec,
},
},
}
Expand Down

0 comments on commit 5d0e6ad

Please sign in to comment.