Add ServiceUnitKey and ServiceAliasConfigKey types - #51
Merged
openshift-merge-robot merged 1 commit intoOct 15, 2019
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.
Miciah
force-pushed
the
add-ServiceUnitKey-and-ServiceAliasConfigKey-types
branch
from
October 9, 2019 14:15
5bd3ac4 to
b535739
Compare
Contributor
Author
|
@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. |
Contributor
|
Oh, sorry, this should have merged long ago. /lgtm |
Contributor
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
alexcern
added a commit
to alexcern/router
that referenced
this pull request
Mar 25, 2020
Following openshift#51 doing it for other template methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Define and use the
ServiceUnitKeyandServiceAliasConfigKeytypes for key values of maps ofServiceUnitvalues and ofServiceAliasConfigvalues, 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): UseServiceAliasConfigKeyfor the name.(
buildHAProxyBackends,newBackend,Name,ApplyChanges): Adapt to use the newServiceAliasConfigKeytype.pkg/router/template/configmanager/haproxy/blueprint_plugin_test.go(fakeConfigManager): UseServiceAliasConfigKeyfor theblueprintsmap.(
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 theServiceAliasConfigKeytype.pkg/router/template/configmanager/haproxy/manager.go(configEntryMap): Use theServiceAliasConfigKeytype for the map's values.(
routeBackendEntry): Use theServiceAliasConfigKeytype forbackendNameand thepoolRouteBackendName,backendEntries, andpoolUsagemaps' 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 theServiceAliasConfigKeytype.pkg/router/template/fake.go(NewFakeTemplateRouter): Adapt to useServiceUnitKeyandServiceAliasConfigKey.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 useServiceAliasConfigKeyandServiceUnitKey.pkg/router/template/types.go(ServiceUnit): UseServiceAliasConfigKeyfor theServiceAliasAssociationsmap.(
ServiceUnitKey): New type.(
ServiceAliasConfig): UseServiceUnitKeyfor theServiceUnitsandServiceUnitNamesmaps.(
ServiceAliasConfigKey): New type.(
ConfigManager): Adapt to useServiceAliasConfigKey.