Merge pull request #99997 from JornShen/extract_ep_and_epm_share_code_to_pkg

Extracting same code of endpointslice and endpointslicemirror into a new shared EndpointSlice package
This commit is contained in:
Kubernetes Prow Robot
2021-07-05 13:25:38 -07:00
committed by GitHub
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
}