check if labels are nil before adding labels
This commit is contained in:
parent
bba1640913
commit
5a3c69d1f5
@ -16,7 +16,7 @@ func SetRecipeLabel(compose *composetypes.Config, stackName string, recipe strin
|
||||
if service.Name == "app" {
|
||||
log.Debugf("set recipe label 'coop-cloud.%s.recipe' to %s for %s", stackName, recipe, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.recipe", stackName)
|
||||
service.Deploy.Labels[labelKey] = recipe
|
||||
AddLabel(service, labelKey, recipe)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool) {
|
||||
if service.Name == "app" {
|
||||
log.Debugf("set label 'coop-cloud.%s.chaos' to %v for %s", stackName, chaos, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.chaos", stackName)
|
||||
service.Deploy.Labels[labelKey] = strconv.FormatBool(chaos)
|
||||
AddLabel(service, labelKey, strconv.FormatBool(chaos))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ func SetChaosVersionLabel(compose *composetypes.Config, stackName string, chaosV
|
||||
if service.Name == "app" {
|
||||
log.Debugf("set label 'coop-cloud.%s.chaos-version' to %v for %s", stackName, chaosVersion, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.chaos-version", stackName)
|
||||
service.Deploy.Labels[labelKey] = chaosVersion
|
||||
AddLabel(service, labelKey, chaosVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@ func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv envfi
|
||||
}
|
||||
log.Debugf("set label 'coop-cloud.%s.autoupdate' to %s for %s", stackName, enable_auto_update, stackName)
|
||||
labelKey := fmt.Sprintf("coop-cloud.%s.autoupdate", stackName)
|
||||
service.Deploy.Labels[labelKey] = enable_auto_update
|
||||
AddLabel(service, labelKey, enable_auto_update)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,3 +86,10 @@ func GetTimeoutFromLabel(compose *composetypes.Config, stackName string) (int, e
|
||||
}
|
||||
return timeout, err
|
||||
}
|
||||
|
||||
func AddLabel(service composetypes.ServiceConfig, labelKey string, value string) {
|
||||
if service.Deploy.Labels == nil {
|
||||
service.Deploy.Labels = composetypes.Labels{}
|
||||
}
|
||||
service.Deploy.Labels[labelKey] = value
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user