mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-18 22:14:22 +00:00
Allow override of discovery URL via ConfigMap
Signed-off-by: Andrew Keesler <akeesler@vmware.com> - Seems like the next step is to allow override of the CA bundle; I didn't do that here for simplicity of the commit, but seems like it is the right thing to do in the future.
This commit is contained in:
+11
-1
@@ -7,7 +7,8 @@ package api
|
||||
|
||||
// Config contains knobs to setup an instance of placeholder-name.
|
||||
type Config struct {
|
||||
WebhookConfig WebhookConfigSpec `json:"webhook"`
|
||||
WebhookConfig WebhookConfigSpec `json:"webhook"`
|
||||
DiscoveryConfig DiscoveryConfigSpec `json:"discovery"`
|
||||
}
|
||||
|
||||
// WebhookConfig contains configuration knobs specific to placeholder-name's use
|
||||
@@ -21,3 +22,12 @@ type WebhookConfigSpec struct {
|
||||
// to validate TLS connections to the WebhookURL.
|
||||
CABundle []byte `json:"caBundle"`
|
||||
}
|
||||
|
||||
// DiscoveryConfigSpec contains configuration knobs specific to
|
||||
// placeholder-name's publishing of discovery information. These values can be
|
||||
// viewed as overrides, i.e., if these are set, then placeholder-name will
|
||||
// publish these values in its discovery document instead of the ones it finds.
|
||||
type DiscoveryConfigSpec struct {
|
||||
// URL contains the URL at which placeholder-name can be contacted.
|
||||
URL *string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
@@ -14,14 +14,50 @@ import (
|
||||
)
|
||||
|
||||
func TestFromPath(t *testing.T) {
|
||||
expect := require.New(t)
|
||||
|
||||
config, err := FromPath("testdata/happy.yaml")
|
||||
expect.NoError(err)
|
||||
expect.Equal(config, &api.Config{
|
||||
WebhookConfig: api.WebhookConfigSpec{
|
||||
URL: "https://tuna.com/fish?marlin",
|
||||
CABundle: []byte("-----BEGIN CERTIFICATE-----..."),
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
wantConfig *api.Config
|
||||
}{
|
||||
{
|
||||
name: "Happy",
|
||||
path: "testdata/happy.yaml",
|
||||
wantConfig: &api.Config{
|
||||
DiscoveryConfig: api.DiscoveryConfigSpec{
|
||||
URL: stringPtr("https://some.discovery/url"),
|
||||
},
|
||||
WebhookConfig: api.WebhookConfigSpec{
|
||||
URL: "https://tuna.com/fish?marlin",
|
||||
CABundle: []byte("-----BEGIN CERTIFICATE-----..."),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
{
|
||||
name: "NoDiscovery",
|
||||
path: "testdata/no-discovery.yaml",
|
||||
wantConfig: &api.Config{
|
||||
DiscoveryConfig: api.DiscoveryConfigSpec{
|
||||
URL: nil,
|
||||
},
|
||||
WebhookConfig: api.WebhookConfigSpec{
|
||||
URL: "https://tuna.com/fish?marlin",
|
||||
CABundle: []byte("-----BEGIN CERTIFICATE-----..."),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
config, err := FromPath(test.path)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, test.wantConfig, config)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func stringPtr(s string) *string {
|
||||
sPtr := new(string)
|
||||
*sPtr = s
|
||||
return sPtr
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -1,4 +1,6 @@
|
||||
---
|
||||
discovery:
|
||||
url: https://some.discovery/url
|
||||
webhook:
|
||||
url: https://tuna.com/fish?marlin
|
||||
caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tLi4u
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
webhook:
|
||||
url: https://tuna.com/fish?marlin
|
||||
caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tLi4u
|
||||
|
||||
Reference in New Issue
Block a user