Add support for configmap of headers to be sent to external auth service
This commit is contained in:
parent
cb2889b87b
commit
786a3b6862
10 changed files with 186 additions and 27 deletions
|
|
@ -261,6 +261,10 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
|
|||
}
|
||||
|
||||
func (f *Framework) getNginxConfigMap() (*v1.ConfigMap, error) {
|
||||
return f.getConfigMap("nginx-configuration")
|
||||
}
|
||||
|
||||
func (f *Framework) getConfigMap(name string) (*v1.ConfigMap, error) {
|
||||
if f.KubeClientSet == nil {
|
||||
return nil, fmt.Errorf("KubeClientSet not initialized")
|
||||
}
|
||||
|
|
@ -268,7 +272,7 @@ func (f *Framework) getNginxConfigMap() (*v1.ConfigMap, error) {
|
|||
config, err := f.KubeClientSet.
|
||||
CoreV1().
|
||||
ConfigMaps(f.Namespace).
|
||||
Get("nginx-configuration", metav1.GetOptions{})
|
||||
Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -291,9 +295,11 @@ func (f *Framework) GetNginxConfigMapData() (map[string]string, error) {
|
|||
|
||||
// SetNginxConfigMapData sets ingress-nginx's nginx-configuration configMap data
|
||||
func (f *Framework) SetNginxConfigMapData(cmData map[string]string) {
|
||||
// Needs to do a Get and Set, Update will not take just the Data field
|
||||
// or a configMap that is not the very last revision
|
||||
config, err := f.getNginxConfigMap()
|
||||
f.SetConfigMapData("nginx-configuration", cmData)
|
||||
}
|
||||
|
||||
func (f *Framework) SetConfigMapData(name string, cmData map[string]string) {
|
||||
config, err := f.getConfigMap(name)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(config).NotTo(BeNil(), "expected a configmap but none returned")
|
||||
|
||||
|
|
@ -308,6 +314,17 @@ func (f *Framework) SetNginxConfigMapData(cmData map[string]string) {
|
|||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
||||
func (f *Framework) CreateConfigMap(name string, data map[string]string) {
|
||||
_, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(&v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: f.Namespace,
|
||||
},
|
||||
Data: data,
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred(), "failed to create configMap")
|
||||
}
|
||||
|
||||
// UpdateNginxConfigMapData updates single field in ingress-nginx's nginx-configuration map data
|
||||
func (f *Framework) UpdateNginxConfigMapData(key string, value string) {
|
||||
config, err := f.GetNginxConfigMapData()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue