feat: ensure networks do not conflict

This commit is contained in:
Jose Diaz-Gonzalez committed 2020-02-08 22:15:37 -05:00
1 parent c8537bff48
commit ca3a306b30
1 file changed
+23 -1
+23 -1
View File
@@ -174,9 +174,31 @@ func CommandSet(appName string, property string, value string) {
"host": true, "host": true,
"bridge": true, "bridge": true,
} }
if attachProperites[property] && invalidNetworks[value] { if attachProperites[property] {
if invalidNetworks[value] {
common.LogFail("Invalid network name specified for attach") common.LogFail("Invalid network name specified for attach")
} }
if isConflictingPropertyValue(property, value) {
common.LogFail("Network name already associated with this app")
}
}
common.CommandPropertySet("network", appName, property, value, DefaultProperties) common.CommandPropertySet("network", appName, property, value, DefaultProperties)
} }
func isConflictingPropertyValue(property string, value string) bool {
if value == "" {
return false
}
otherProperty := "attach-post-create"
if property == otherProperty {
otherProperty = "attach-post-deploy"
}
defaultValue := GetDefaultValue(otherProperty)
otherValue := common.PropertyGetDefault("network", appName, otherProperty, defaultValue)
return value == otherValue
}