Change enable-snippet to allow-snippet-annotation (#7670)
Signed-off-by: Ricardo Pchevuzinske Katz <rkatz@vmware.com>
This commit is contained in:
parent
8e7727eb65
commit
4fc57dcc49
12 changed files with 30 additions and 28 deletions
|
|
@ -93,9 +93,9 @@ const (
|
|||
type Configuration struct {
|
||||
defaults.Backend `json:",squash"`
|
||||
|
||||
// EnableSnippetDirectives enable users to add their own snippets via ingress annotation.
|
||||
// AllowSnippetAnnotations enable users to add their own snippets via ingress annotation.
|
||||
// If disabled, only snippets added via ConfigMap are added to ingress.
|
||||
EnableSnippetDirectives bool `json:"enable-snippet-directives"`
|
||||
AllowSnippetAnnotations bool `json:"allow-snippet-annotations"`
|
||||
|
||||
// Sets the name of the configmap that contains the headers to pass to the client
|
||||
AddHeaders string `json:"add-headers,omitempty"`
|
||||
|
|
@ -761,7 +761,8 @@ func NewDefault() Configuration {
|
|||
defGlobalExternalAuth := GlobalExternalAuth{"", "", "", "", "", append(defResponseHeaders, ""), "", "", "", []string{}, map[string]string{}}
|
||||
|
||||
cfg := Configuration{
|
||||
EnableSnippetDirectives: true,
|
||||
|
||||
AllowSnippetAnnotations: true,
|
||||
AllowBackendServerHeader: false,
|
||||
AccessLogPath: "/var/log/nginx/access.log",
|
||||
AccessLogParams: "",
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
|
|||
}
|
||||
}
|
||||
|
||||
if !cfg.EnableSnippetDirectives && strings.HasSuffix(key, "-snippet") {
|
||||
if !cfg.AllowSnippetAnnotations && strings.HasSuffix(key, "-snippet") {
|
||||
return fmt.Errorf("%s annotation cannot be used. Snippet directives are disabled by the Ingress administrator", key)
|
||||
}
|
||||
|
||||
|
|
@ -550,7 +550,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
|||
ingKey := k8s.MetaNamespaceKey(ing)
|
||||
anns := ing.ParsedAnnotations
|
||||
|
||||
if !n.store.GetBackendConfiguration().EnableSnippetDirectives {
|
||||
if !n.store.GetBackendConfiguration().AllowSnippetAnnotations {
|
||||
dropSnippetDirectives(anns, ingKey)
|
||||
}
|
||||
|
||||
|
|
@ -830,7 +830,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
ingKey := k8s.MetaNamespaceKey(ing)
|
||||
anns := ing.ParsedAnnotations
|
||||
|
||||
if !n.store.GetBackendConfiguration().EnableSnippetDirectives {
|
||||
if !n.store.GetBackendConfiguration().AllowSnippetAnnotations {
|
||||
dropSnippetDirectives(anns, ingKey)
|
||||
}
|
||||
|
||||
|
|
@ -1124,7 +1124,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
ingKey := k8s.MetaNamespaceKey(ing)
|
||||
anns := ing.ParsedAnnotations
|
||||
|
||||
if !n.store.GetBackendConfiguration().EnableSnippetDirectives {
|
||||
if !n.store.GetBackendConfiguration().AllowSnippetAnnotations {
|
||||
dropSnippetDirectives(anns, ingKey)
|
||||
}
|
||||
|
||||
|
|
@ -1204,7 +1204,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
ingKey := k8s.MetaNamespaceKey(ing)
|
||||
anns := ing.ParsedAnnotations
|
||||
|
||||
if !n.store.GetBackendConfiguration().EnableSnippetDirectives {
|
||||
if !n.store.GetBackendConfiguration().AllowSnippetAnnotations {
|
||||
dropSnippetDirectives(anns, ingKey)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ func TestCheckIngress(t *testing.T) {
|
|||
nginx.store = fakeIngressStore{
|
||||
ingresses: []*ingress.Ingress{},
|
||||
configuration: ngx_config.Configuration{
|
||||
EnableSnippetDirectives: false,
|
||||
AllowSnippetAnnotations: false,
|
||||
},
|
||||
}
|
||||
nginx.command = testNginxTestCommand{
|
||||
|
|
@ -2309,7 +2309,7 @@ func TestGetBackendServers(t *testing.T) {
|
|||
SelfLink: fmt.Sprintf("/api/v1/namespaces/%s/configmaps/config", ns),
|
||||
},
|
||||
Data: map[string]string{
|
||||
"enable-snippet-directives": "false",
|
||||
"allow-snippet-annotations": "false",
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue