The `TransporPort` type is comparable; it doesn't have fields that
require special handling. It's defined as;
// TransportPort represents a local Layer 4 endpoint
type TransportPort struct {
Proto Protocol
Port uint16
}
where `Protocol` is an int (with a stringer interface);
type Protocol uint8
So we can remove the `Equal` method, and simplify places where it's
compared.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -158,15 +158,9 @@ func compareConnConfig(a, b *connectivityConfiguration) bool {
|
| 158 | 158 |
if a == nil || b == nil {
|
| 159 | 159 |
return false |
| 160 | 160 |
} |
| 161 |
- if len(a.ExposedPorts) != len(b.ExposedPorts) || |
|
| 162 |
- len(a.PortBindings) != len(b.PortBindings) {
|
|
| 161 |
+ if !slices.Equal(a.ExposedPorts, b.ExposedPorts) {
|
|
| 163 | 162 |
return false |
| 164 | 163 |
} |
| 165 |
- for i := 0; i < len(a.ExposedPorts); i++ {
|
|
| 166 |
- if !a.ExposedPorts[i].Equal(&b.ExposedPorts[i]) {
|
|
| 167 |
- return false |
|
| 168 |
- } |
|
| 169 |
- } |
|
| 170 | 164 |
for i := 0; i < len(a.PortBindings); i++ {
|
| 171 | 165 |
if !comparePortBinding(&a.PortBindings[i].PortBinding, &b.PortBindings[i].PortBinding) {
|
| 172 | 166 |
return false |
| ... | ... |
@@ -43,23 +43,6 @@ type TransportPort struct {
|
| 43 | 43 |
Port uint16 |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
-// Equal checks if this instance of TransportPort is equal to the passed one |
|
| 47 |
-func (t *TransportPort) Equal(o *TransportPort) bool {
|
|
| 48 |
- if t == o {
|
|
| 49 |
- return true |
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- if o == nil {
|
|
| 53 |
- return false |
|
| 54 |
- } |
|
| 55 |
- |
|
| 56 |
- if t.Proto != o.Proto || t.Port != o.Port {
|
|
| 57 |
- return false |
|
| 58 |
- } |
|
| 59 |
- |
|
| 60 |
- return true |
|
| 61 |
-} |
|
| 62 |
- |
|
| 63 | 46 |
// String returns the TransportPort structure in string form |
| 64 | 47 |
func (t *TransportPort) String() string {
|
| 65 | 48 |
return fmt.Sprintf("%s/%d", t.Proto.String(), t.Port)
|