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 <akeesler@vmware.com>
This commit is contained in:
Ryan Richard 2020-08-03 14:36:08 -04:00 committed by Andrew Keesler
parent e884cef1ef
commit ca80d87dcf
No known key found for this signature in database
GPG Key ID: 27CE0444346F9413
2 changed files with 5 additions and 7 deletions

View File

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

View File

@ -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),
}
}