internal/controller/issuerconfig: Publisher -> KubeConfigInfoPublisher

The new symbol more specifically describes what the controller does.

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler 2020-09-23 07:58:01 -04:00
parent a55e9de4fc
commit 3e45bfc97d
No known key found for this signature in database
GPG Key ID: 27CE0444346F9413
4 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,5 @@
// Copyright 2020 the Pinniped contributors. All Rights Reserved. // Copyright 2020 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// Package discovery contains controller(s) for reconciling CredentialIssuerConfig's. // Package issuerconfig contains controller(s) for reconciling CredentialIssuerConfig's.
package issuerconfig package issuerconfig

View File

@ -25,7 +25,7 @@ const (
clusterInfoConfigMapKey = "kubeconfig" clusterInfoConfigMapKey = "kubeconfig"
) )
type publisherController struct { type kubeConigInfoPublisherController struct {
credentialIssuerConfigNamespaceName string credentialIssuerConfigNamespaceName string
credentialIssuerConfigResourceName string credentialIssuerConfigResourceName string
serverOverride *string serverOverride *string
@ -34,8 +34,10 @@ type publisherController struct {
credentialIssuerConfigInformer configv1alpha1informers.CredentialIssuerConfigInformer credentialIssuerConfigInformer configv1alpha1informers.CredentialIssuerConfigInformer
} }
// TODO rename this NewKubeConfigInfoPublisherController, along with the private type and the source/test files. // NewKubeConfigInfoPublisherController returns a controller that syncs the
func NewPublisherController( // configv1alpha1.CredentialIssuerConfig.Status.KubeConfigInfo field with the cluster-info ConfigMap
// in the kube-public namespace.
func NewKubeConfigInfoPublisherController(
credentialIssuerConfigNamespaceName string, credentialIssuerConfigNamespaceName string,
credentialIssuerConfigResourceName string, credentialIssuerConfigResourceName string,
serverOverride *string, serverOverride *string,
@ -47,7 +49,7 @@ func NewPublisherController(
return controllerlib.New( return controllerlib.New(
controllerlib.Config{ controllerlib.Config{
Name: "publisher-controller", Name: "publisher-controller",
Syncer: &publisherController{ Syncer: &kubeConigInfoPublisherController{
credentialIssuerConfigResourceName: credentialIssuerConfigResourceName, credentialIssuerConfigResourceName: credentialIssuerConfigResourceName,
credentialIssuerConfigNamespaceName: credentialIssuerConfigNamespaceName, credentialIssuerConfigNamespaceName: credentialIssuerConfigNamespaceName,
serverOverride: serverOverride, serverOverride: serverOverride,
@ -69,7 +71,7 @@ func NewPublisherController(
) )
} }
func (c *publisherController) Sync(ctx controllerlib.Context) error { func (c *kubeConigInfoPublisherController) Sync(ctx controllerlib.Context) error {
configMap, err := c.configMapInformer. configMap, err := c.configMapInformer.
Lister(). Lister().
ConfigMaps(ClusterInfoNamespace). ConfigMaps(ClusterInfoNamespace).

View File

@ -43,7 +43,7 @@ func TestInformerFilters(t *testing.T) {
observableWithInformerOption = testutil.NewObservableWithInformerOption() observableWithInformerOption = testutil.NewObservableWithInformerOption()
configMapInformer := kubeinformers.NewSharedInformerFactory(nil, 0).Core().V1().ConfigMaps() configMapInformer := kubeinformers.NewSharedInformerFactory(nil, 0).Core().V1().ConfigMaps()
credentialIssuerConfigInformer := pinnipedinformers.NewSharedInformerFactory(nil, 0).Config().V1alpha1().CredentialIssuerConfigs() credentialIssuerConfigInformer := pinnipedinformers.NewSharedInformerFactory(nil, 0).Config().V1alpha1().CredentialIssuerConfigs()
_ = NewPublisherController( _ = NewKubeConfigInfoPublisherController(
installedInNamespace, installedInNamespace,
credentialIssuerConfigResourceName, credentialIssuerConfigResourceName,
nil, nil,
@ -206,7 +206,7 @@ func TestSync(t *testing.T) {
// nested Before's can keep adding things to the informer caches. // nested Before's can keep adding things to the informer caches.
var startInformersAndController = func() { var startInformersAndController = func() {
// Set this at the last second to allow for injection of server override. // Set this at the last second to allow for injection of server override.
subject = NewPublisherController( subject = NewKubeConfigInfoPublisherController(
installedInNamespace, installedInNamespace,
credentialIssuerConfigResourceName, credentialIssuerConfigResourceName,
serverOverride, serverOverride,

View File

@ -93,7 +93,7 @@ func PrepareControllers(c *Config) (func(ctx context.Context), error) {
controllerManager := controllerlib. controllerManager := controllerlib.
NewManager(). NewManager().
WithController( WithController(
issuerconfig.NewPublisherController( issuerconfig.NewKubeConfigInfoPublisherController(
c.ServerInstallationNamespace, c.ServerInstallationNamespace,
c.NamesConfig.CredentialIssuerConfig, c.NamesConfig.CredentialIssuerConfig,
c.DiscoveryURLOverride, c.DiscoveryURLOverride,