(
existing: &mut NetworkEndpoint,
incoming: &NetworkEndpoint,
warnings: &mut Vec<PolicyMergeWarning>,
)
| 464 | } |
| 465 | |
| 466 | fn merge_endpoint( |
| 467 | existing: &mut NetworkEndpoint, |
| 468 | incoming: &NetworkEndpoint, |
| 469 | warnings: &mut Vec<PolicyMergeWarning>, |
| 470 | ) -> Result<(), PolicyMergeError> { |
| 471 | let host = if existing.host.is_empty() { |
| 472 | incoming.host.clone() |
| 473 | } else { |
| 474 | existing.host.clone() |
| 475 | }; |
| 476 | let port = canonical_ports(existing) |
| 477 | .into_iter() |
| 478 | .next() |
| 479 | .or_else(|| canonical_ports(incoming).into_iter().next()) |
| 480 | .unwrap_or(0); |
| 481 | |
| 482 | if existing.host.is_empty() { |
| 483 | existing.host.clone_from(&incoming.host); |
| 484 | } |
| 485 | if existing.path.is_empty() { |
| 486 | existing.path.clone_from(&incoming.path); |
| 487 | } |
| 488 | |
| 489 | merge_endpoint_ports(existing, incoming); |
| 490 | let existing_protocol = existing.protocol.clone(); |
| 491 | merge_string_field( |
| 492 | &mut existing.protocol, |
| 493 | &incoming.protocol, |
| 494 | PolicyMergeWarning::ExistingProtocolRetained { |
| 495 | host: host.clone(), |
| 496 | port, |
| 497 | existing: existing_protocol, |
| 498 | incoming: incoming.protocol.clone(), |
| 499 | }, |
| 500 | warnings, |
| 501 | ); |
| 502 | let existing_enforcement = existing.enforcement.clone(); |
| 503 | merge_string_field( |
| 504 | &mut existing.enforcement, |
| 505 | &incoming.enforcement, |
| 506 | PolicyMergeWarning::ExistingEnforcementRetained { |
| 507 | host: host.clone(), |
| 508 | port, |
| 509 | existing: existing_enforcement, |
| 510 | incoming: incoming.enforcement.clone(), |
| 511 | }, |
| 512 | warnings, |
| 513 | ); |
| 514 | let existing_tls = existing.tls.clone(); |
| 515 | merge_string_field( |
| 516 | &mut existing.tls, |
| 517 | &incoming.tls, |
| 518 | PolicyMergeWarning::ExistingTlsRetained { |
| 519 | host: host.clone(), |
| 520 | port, |
| 521 | existing: existing_tls, |
| 522 | incoming: incoming.tls.clone(), |
| 523 | }, |
no test coverage detected