From edcc3dfc8153520d47116410f1235352f2f1acc0 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Fri, 25 Aug 2017 22:39:30 -0300 Subject: [PATCH] Make Ingress annotations available in template --- controllers/nginx/pkg/template/template.go | 12 +++++++----- .../nginx/rootfs/etc/nginx/template/nginx.tmpl | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/controllers/nginx/pkg/template/template.go b/controllers/nginx/pkg/template/template.go index 327c430f4..b9ff076d3 100644 --- a/controllers/nginx/pkg/template/template.go +++ b/controllers/nginx/pkg/template/template.go @@ -592,9 +592,10 @@ func isValidClientBodyBufferSize(input interface{}) bool { } type ingressInformation struct { - Namespace string - Rule string - Service string + Namespace string + Rule string + Service string + Annotations map[string]string } func getIngressInformation(i, p interface{}) *ingressInformation { @@ -616,8 +617,9 @@ func getIngressInformation(i, p interface{}) *ingressInformation { } info := &ingressInformation{ - Namespace: ing.GetNamespace(), - Rule: ing.GetName(), + Namespace: ing.GetNamespace(), + Rule: ing.GetName(), + Annotations: ing.Annotations, } if ing.Spec.Backend != nil { diff --git a/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl b/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl index 607217e64..bfac4706a 100644 --- a/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl +++ b/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl @@ -668,6 +668,7 @@ stream { set $proxy_upstream_name "{{ buildUpstreamName $server.Hostname $all.Backends $location }}"; {{ $ing := (getIngressInformation $location.Ingress $path) }} + {{/* $ing.Metadata contains the Ingress metadata */}} set $namespace "{{ $ing.Namespace }}"; set $ingress_name "{{ $ing.Rule }}"; set $service_name "{{ $ing.Service }}";