extract same code of es and esm to pkg

migrate files:
endpointset.go
endpointslice_tracker.go
endpointslice_tracker_test.go
errors.go
This commit is contained in:
jornshen
2021-04-19 17:37:39 +08:00
parent 425e33bd50
commit 6c63ef147c
19 changed files with 127 additions and 814 deletions

View File

@@ -258,3 +258,16 @@ func cloneAndRemoveKeys(a map[string]string, keys ...string) map[string]string {
}
return newMap
}
// managedByChanged returns true if one of the provided EndpointSlices is
// managed by the EndpointSlice controller while the other is not.
func managedByChanged(endpointSlice1, endpointSlice2 *discovery.EndpointSlice) bool {
return managedByController(endpointSlice1) != managedByController(endpointSlice2)
}
// managedByController returns true if the controller of the provided
// EndpointSlices is the EndpointSlice controller.
func managedByController(endpointSlice *discovery.EndpointSlice) bool {
managedBy, _ := endpointSlice.Labels[discovery.LabelManagedBy]
return managedBy == controllerName
}