Skip to content
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

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Oct 9, 2019

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.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 9, 2019
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 Miciah force-pushed the add-ServiceUnitKey-and-ServiceAliasConfigKey-types branch from 5bd3ac4 to b535739 Compare October 9, 2019 14:15
@Miciah
Copy link
Contributor Author

Miciah commented Oct 15, 2019

@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.

@ironcladlou
Copy link
Contributor

Oh, sorry, this should have merged long ago.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2019
@openshift-ci-robot
Copy link
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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 98703dc into openshift:master Oct 15, 2019
alexcern added a commit to alexcern/router that referenced this pull request Mar 25, 2020
Following openshift#51 doing it
for other template methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants