Skip to content

Commit

Permalink
Make Ingress annotations available in template
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Aug 26, 2017
1 parent 6d0243a commit edcc3df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions controllers/nginx/pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}";
Expand Down

0 comments on commit edcc3df

Please sign in to comment.