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:
parent
e884cef1ef
commit
ca80d87dcf
@ -25,7 +25,7 @@ data:
|
|||||||
#@yaml/text-templated-strings
|
#@yaml/text-templated-strings
|
||||||
placeholder-name.yaml: |
|
placeholder-name.yaml: |
|
||||||
discovery:
|
discovery:
|
||||||
url: (@= data.values.discovery_url @)
|
url: (@= data.values.discovery_url or "null" @)
|
||||||
webhook:
|
webhook:
|
||||||
url: (@= data.values.webhook_url @)
|
url: (@= data.values.webhook_url @)
|
||||||
caBundle: (@= data.values.webhook_ca_bundle @)
|
caBundle: (@= data.values.webhook_ca_bundle @)
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
|
func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
|
||||||
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
|
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
|
||||||
discoveryURL := library.Getenv(t, "PLACEHOLDER_NAME_DISCOVERY_URL")
|
|
||||||
|
|
||||||
client := library.NewPlaceholderNameClientset(t)
|
client := library.NewPlaceholderNameClientset(t)
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
config := library.NewClientConfig(t)
|
config := library.NewClientConfig(t)
|
||||||
expectedLDCSpec := expectedLDCSpec(config, discoveryURL)
|
expectedLDCSpec := expectedLDCSpec(config)
|
||||||
configList, err := client.
|
configList, err := client.
|
||||||
CrdsV1alpha1().
|
CrdsV1alpha1().
|
||||||
LoginDiscoveryConfigs(namespaceName).
|
LoginDiscoveryConfigs(namespaceName).
|
||||||
@ -41,7 +40,6 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
|
|||||||
|
|
||||||
func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
||||||
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
|
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
|
||||||
discoveryURL := library.Getenv(t, "PLACEHOLDER_NAME_DISCOVERY_URL")
|
|
||||||
|
|
||||||
client := library.NewPlaceholderNameClientset(t)
|
client := library.NewPlaceholderNameClientset(t)
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
config := library.NewClientConfig(t)
|
config := library.NewClientConfig(t)
|
||||||
expectedLDCSpec := expectedLDCSpec(config, discoveryURL)
|
expectedLDCSpec := expectedLDCSpec(config)
|
||||||
|
|
||||||
var actualLDC *crdsplaceholderv1alpha1.LoginDiscoveryConfig
|
var actualLDC *crdsplaceholderv1alpha1.LoginDiscoveryConfig
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
@ -72,9 +70,9 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
|||||||
require.Equal(t, expectedLDCSpec, &actualLDC.Spec)
|
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{
|
return &crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
|
||||||
Server: discoveryURL,
|
Server: config.Host,
|
||||||
CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData),
|
CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user