Improve port label validation and diff testing
This commit is contained in:
parent
91282315d1
commit
af8964e896
|
@ -3507,6 +3507,12 @@ func TestTaskDiff(t *testing.T) {
|
|||
Type: DiffTypeEdited,
|
||||
Name: "Check",
|
||||
Fields: []*FieldDiff{
|
||||
{
|
||||
Type: DiffTypeNone,
|
||||
Name: "AddressMode",
|
||||
Old: "",
|
||||
New: "",
|
||||
},
|
||||
{
|
||||
Type: DiffTypeNone,
|
||||
Name: "Command",
|
||||
|
|
|
@ -3473,10 +3473,14 @@ func validateServices(t *Task) error {
|
|||
knownServices[service.Name+service.PortLabel] = struct{}{}
|
||||
|
||||
if service.PortLabel != "" {
|
||||
if _, err := strconv.Atoi(service.PortLabel); service.AddressMode == "driver" && err == nil {
|
||||
// Numeric ports are valid when AddressMode=driver
|
||||
if service.AddressMode == "driver" {
|
||||
// Numeric port labels are valid for address_mode=driver
|
||||
_, err := strconv.Atoi(service.PortLabel)
|
||||
if err != nil {
|
||||
// Not a numeric port label, add it to list to check
|
||||
servicePorts[service.PortLabel] = append(servicePorts[service.PortLabel], service.Name)
|
||||
}
|
||||
} else {
|
||||
|
||||
servicePorts[service.PortLabel] = append(servicePorts[service.PortLabel], service.Name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue