Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 22 additions & 26 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func rollingUpgradeDeployments(cm *api.ConfigMap, c *client.Client) error {
}
}
if matches {
updateContainers(containers, annotationValue, configMapVersion)
updateContainers(containers, configMapVersion, configMapName)

// update the deployment
_, err := c.Deployments(ns).Update(&d)
Expand Down Expand Up @@ -202,7 +202,7 @@ func rollingUpgradeDeploymentsConfigs(cm *api.ConfigMap, oc *oclient.Client) err
}
}
if matches {
if updateContainers(containers, annotationValue, configMapVersion) {
if updateContainers(containers, configMapVersion, configMapName) {
// update the deployment
_, err := oc.DeploymentConfigs(ns).Update(&d)
if err != nil {
Expand All @@ -229,35 +229,31 @@ func convertConfigMapToToken(cm *api.ConfigMap) string {
return text
}

func updateContainers(containers []api.Container, annotationValue, configMapVersion string) bool {
func updateContainers(containers []api.Container, configMapVersion string, cmNameToUpdate string) bool {
// we can have multiple configmaps to update
answer := false
configmaps := strings.Split(annotationValue, ",")
for _, cmNameToUpdate := range configmaps {
configmapEnvar := "FABRIC8_" + convertToEnvVarName(cmNameToUpdate) + "_CONFIGMAP"

for i := range containers {
envs := containers[i].Env
matched := false
for j := range envs {
if envs[j].Name == configmapEnvar {
matched = true
if envs[j].Value != configMapVersion {
glog.Infof("Updating %s to %s", configmapEnvar, configMapVersion)
envs[j].Value = configMapVersion
answer = true
}
configmapEnvar := "FABRIC8_" + convertToEnvVarName(cmNameToUpdate) + "_CONFIGMAP"
for i := range containers {
envs := containers[i].Env
matched := false
for j := range envs {
if envs[j].Name == configmapEnvar {
matched = true
if envs[j].Value != configMapVersion {
glog.Infof("Updating %s to %s", configmapEnvar, configMapVersion)
envs[j].Value = configMapVersion
answer = true
}
}
// if no existing env var exists lets create one
if !matched {
e := api.EnvVar{
Name: configmapEnvar,
Value: configMapVersion,
}
containers[i].Env = append(containers[i].Env, e)
answer = true
}
// if no existing env var exists lets create one
if !matched {
e := api.EnvVar{
Name: configmapEnvar,
Value: configMapVersion,
}
containers[i].Env = append(containers[i].Env, e)
answer = true
}
}
return answer
Expand Down