From ca80d87dcfe34fa96dc9154c037e2e8846b713eb Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Mon, 3 Aug 2020 14:36:08 -0400 Subject: [PATCH] Use rest.Config for discovery URL instead of env var - Why? Because the discovery URL is already there in the kubeconfig; let's not make our lives more complicated by passing it in via an env var. - Also allow for ytt callers to not specify data.values.discovery_url - there are going to be a non-trivial number of installers of placeholder-name that want to use the server URL found in the cluster-info ConfigMap. Signed-off-by: Andrew Keesler --- deploy/deployment.yaml | 2 +- test/integration/logindiscoveryconfig_test.go | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml index 543b8db3..35024701 100644 --- a/deploy/deployment.yaml +++ b/deploy/deployment.yaml @@ -25,7 +25,7 @@ data: #@yaml/text-templated-strings placeholder-name.yaml: | discovery: - url: (@= data.values.discovery_url @) + url: (@= data.values.discovery_url or "null" @) webhook: url: (@= data.values.webhook_url @) caBundle: (@= data.values.webhook_ca_bundle @) diff --git a/test/integration/logindiscoveryconfig_test.go b/test/integration/logindiscoveryconfig_test.go index bac62b17..5a5cc169 100644 --- a/test/integration/logindiscoveryconfig_test.go +++ b/test/integration/logindiscoveryconfig_test.go @@ -21,7 +21,6 @@ import ( func TestSuccessfulLoginDiscoveryConfig(t *testing.T) { namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE") - discoveryURL := library.Getenv(t, "PLACEHOLDER_NAME_DISCOVERY_URL") client := library.NewPlaceholderNameClientset(t) @@ -29,7 +28,7 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) { defer cancel() config := library.NewClientConfig(t) - expectedLDCSpec := expectedLDCSpec(config, discoveryURL) + expectedLDCSpec := expectedLDCSpec(config) configList, err := client. CrdsV1alpha1(). LoginDiscoveryConfigs(namespaceName). @@ -41,7 +40,6 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) { func TestReconcilingLoginDiscoveryConfig(t *testing.T) { namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE") - discoveryURL := library.Getenv(t, "PLACEHOLDER_NAME_DISCOVERY_URL") client := library.NewPlaceholderNameClientset(t) @@ -55,7 +53,7 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) { require.NoError(t, err) config := library.NewClientConfig(t) - expectedLDCSpec := expectedLDCSpec(config, discoveryURL) + expectedLDCSpec := expectedLDCSpec(config) var actualLDC *crdsplaceholderv1alpha1.LoginDiscoveryConfig for i := 0; i < 10; i++ { @@ -72,9 +70,9 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) { require.Equal(t, expectedLDCSpec, &actualLDC.Spec) } -func expectedLDCSpec(config *rest.Config, discoveryURL string) *crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec { +func expectedLDCSpec(config *rest.Config) *crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec { return &crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{ - Server: discoveryURL, + Server: config.Host, CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData), } }