-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ServiceUnitKey and ServiceAliasConfigKey types #51
Add ServiceUnitKey and ServiceAliasConfigKey types #51
Conversation
Define and use the ServiceUnitKey and ServiceAliasConfigKey types for key values of maps of ServiceUnit values and of ServiceAliasConfig values, respectively, in order to make code dealing with such maps clearer and reduce risk of mixing key values. * pkg/router/template/configmanager/haproxy/backend.go (Backend): Use ServiceAliasConfigKey for the name. (buildHAProxyBackends, newBackend, Name, ApplyChanges): Adapt to use the new ServiceAliasConfigKey type. * pkg/router/template/configmanager/haproxy/blueprint_plugin_test.go (fakeConfigManager): Use ServiceAliasConfigKey for the blueprints map. (newFakeConfigManager, FindBlueprint, Register, AddRoute, RemoveRoute) (ReplaceRouteEndpoints, RemoveRouteEndpoints, routeKey): * pkg/router/template/configmanager/haproxy/client.go (FindBackend): * pkg/router/template/configmanager/haproxy/client_test.go (TestClientCommit, TestClientBackends): Adapt to use the ServiceAliasConfigKey type. * pkg/router/template/configmanager/haproxy/manager.go (configEntryMap): Use the ServiceAliasConfigKey type for the map's values. (routeBackendEntry): Use the ServiceAliasConfigKey type for backendName and the poolRouteBackendName, backendEntries, and poolUsage maps' keys. (NewHAProxyConfigManager, Register, AddRoute, RemoveRoute) (ReplaceRouteEndpoints, RemoveRouteEndpoints, findFreeBackendPoolSlot) (reset, BackendName, BuildMapAssociations, routeBackendName) (applyMapAssociations): * pkg/router/template/configmanager/haproxy/map.go (Add, addEntry): * pkg/router/template/configmanager/haproxy/map_test.go (TestHAProxyMapAdd): Adapt to use the ServiceAliasConfigKey type. * pkg/router/template/fake.go (NewFakeTemplateRouter): Adapt to use ServiceUnitKey and ServiceAliasConfigKey. * pkg/router/template/plugin.go (RouterInterface, endpointsKey) (endpointsKeyFromParts, getPartsFromEndpointsKey): Adapt to use ServiceUnitKey. * pkg/router/template/plugin_test.go (TestRouter, newTestRouter) (CreateServiceUnit, FindServiceUnit, AddEndpoints, DeleteEndpoints) (calculateServiceWeights, FilterNamespaces, getKey, TestHandleEndpoints) (TestHandleTCPEndpoints, TestHandleRouteExtendedValidation) (TestHandleRoute, TestNamespaceScopingFromEmpty): * pkg/router/template/router.go (templateRouter, templateData) (newTemplateRouter, readState, FilterNamespaces, CreateServiceUnit) (createServiceUnitInternal, findMatchingServiceUnit, FindServiceUnit) (DeleteServiceUnit, addServiceAliasAssociation) (removeServiceAliasAssociation, dynamicallyAddRoute) (dynamicallyRemoveRoute, dynamicallyReplaceEndpoints, DeleteEndpoints) (routeKey, routeKeyFromParts, getPartsFromRouteKey) (createServiceAliasConfig, numberOfEndpoints, AddEndpoints) (getServiceUnits, getActiveEndpoints, calculateServiceWeights): * pkg/router/template/router_test.go (TestCreateServiceUnit) (TestDeleteServiceUnit, TestAddEndpoints, TestAddEndpointDuplicates) (TestDeleteEndpoints, TestCreateServiceAliasConfig, TestAddRoute) (TestFilterNamespaces): * pkg/router/template/template_helper.go (generateHAProxyCertConfigMap) (getHTTPAliasesGroupedByHost, generateHAProxyMap): * pkg/router/template/template_helper_test.go (buildTestTemplateState) (TestGenerateHAProxyCertConfigMap, TestGenerateHAProxyMap) (TestGetHTTPAliasesGroupedByHost): Adapt to use ServiceAliasConfigKey and ServiceUnitKey. * pkg/router/template/types.go (ServiceUnit): Use ServiceAliasConfigKey for the ServiceAliasAssociations map. (ServiceUnitKey): New type. (ServiceAliasConfig): Use ServiceUnitKey for the ServiceUnits and ServiceUnitNames maps. (ServiceAliasConfigKey): New type. (ConfigManager): Adapt to use ServiceAliasConfigKey.
5bd3ac4
to
b535739
Compare
@ironcladlou, do you have any objections to this change? One of my motivations for making this change is that it will be easier to make logging consistent in a subsequent PR if the values that we are logging have specific types. |
Oh, sorry, this should have merged long ago. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ironcladlou, Miciah The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Following openshift#51 doing it for other template methods
Define and use the
ServiceUnitKey
andServiceAliasConfigKey
types for key values of maps ofServiceUnit
values and ofServiceAliasConfig
values, respectively, in order to make code dealing with such maps clearer and reduce risk of mixing key values.pkg/router/template/configmanager/haproxy/backend.go
(Backend
): UseServiceAliasConfigKey
for the name.(
buildHAProxyBackends
,newBackend
,Name
,ApplyChanges
): Adapt to use the newServiceAliasConfigKey
type.pkg/router/template/configmanager/haproxy/blueprint_plugin_test.go
(fakeConfigManager
): UseServiceAliasConfigKey
for theblueprints
map.(
newFakeConfigManager
,FindBlueprint
,Register
,AddRoute
,RemoveRoute
,ReplaceRouteEndpoints
,RemoveRouteEndpoints
,routeKey
):pkg/router/template/configmanager/haproxy/client.go
(FindBackend
):pkg/router/template/configmanager/haproxy/client_test.go
(TestClientCommit
,TestClientBackends
): Adapt to use theServiceAliasConfigKey
type.pkg/router/template/configmanager/haproxy/manager.go
(configEntryMap
): Use theServiceAliasConfigKey
type for the map's values.(
routeBackendEntry
): Use theServiceAliasConfigKey
type forbackendName
and thepoolRouteBackendName
,backendEntries
, andpoolUsage
maps' keys.(
NewHAProxyConfigManager
,Register
,AddRoute
,RemoveRoute
,ReplaceRouteEndpoints
,RemoveRouteEndpoints
,findFreeBackendPoolSlot
,reset
,BackendName
,BuildMapAssociations
,routeBackendName
,applyMapAssociations
):pkg/router/template/configmanager/haproxy/map.go
(Add
,addEntry
):pkg/router/template/configmanager/haproxy/map_test.go
(TestHAProxyMapAdd
): Adapt to use theServiceAliasConfigKey
type.pkg/router/template/fake.go
(NewFakeTemplateRouter
): Adapt to useServiceUnitKey
andServiceAliasConfigKey
.pkg/router/template/plugin.go
(RouterInterface
,endpointsKey
,endpointsKeyFromParts
,getPartsFromEndpointsKey
): Adapt to useServiceUnitKey
.pkg/router/template/plugin_test.go
(TestRouter
,newTestRouter
,CreateServiceUnit
,FindServiceUnit
,AddEndpoints
,DeleteEndpoints
,calculateServiceWeights
,FilterNamespaces
,getKey
,TestHandleEndpoints
,TestHandleTCPEndpoints
,TestHandleRouteExtendedValidation
,TestHandleRoute
,TestNamespaceScopingFromEmpty
):pkg/router/template/router.go
(templateRouter
,templateData
,newTemplateRouter
,readState
,FilterNamespaces
,CreateServiceUnit
,createServiceUnitInternal
,findMatchingServiceUnit
,FindServiceUnit
,DeleteServiceUnit
,addServiceAliasAssociation
,removeServiceAliasAssociation
,dynamicallyAddRoute
,dynamicallyRemoveRoute
,dynamicallyReplaceEndpoints
,DeleteEndpoints
,routeKey
,routeKeyFromParts
,getPartsFromRouteKey
,createServiceAliasConfig
,numberOfEndpoints
,AddEndpoints
,getServiceUnits
,getActiveEndpoints
,calculateServiceWeights
):pkg/router/template/router_test.go
(TestCreateServiceUnit
,TestDeleteServiceUnit
,TestAddEndpoints
,TestAddEndpointDuplicates
,TestDeleteEndpoints
,TestCreateServiceAliasConfig
,TestAddRoute
,TestFilterNamespaces
):pkg/router/template/template_helper.go
(generateHAProxyCertConfigMap
,getHTTPAliasesGroupedByHost
,generateHAProxyMap
):pkg/router/template/template_helper_test.go
(buildTestTemplateState
,TestGenerateHAProxyCertConfigMap
,TestGenerateHAProxyMap
,TestGetHTTPAliasesGroupedByHost
): Adapt to useServiceAliasConfigKey
andServiceUnitKey
.pkg/router/template/types.go
(ServiceUnit
): UseServiceAliasConfigKey
for theServiceAliasAssociations
map.(
ServiceUnitKey
): New type.(
ServiceAliasConfig
): UseServiceUnitKey
for theServiceUnits
andServiceUnitNames
maps.(
ServiceAliasConfigKey
): New type.(
ConfigManager
): Adapt to useServiceAliasConfigKey
.