github.com/hernad/nomad@v1.6.112/nomad/structs/connect.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package structs 5 6 // ConsulConfigEntries represents Consul ConfigEntry definitions from a job for 7 // a single Consul namespace. 8 type ConsulConfigEntries struct { 9 Ingress map[string]*ConsulIngressConfigEntry 10 Terminating map[string]*ConsulTerminatingConfigEntry 11 } 12 13 // ConfigEntries accumulates the Consul Configuration Entries defined in task groups 14 // of j, organized by Consul namespace. 15 func (j *Job) ConfigEntries() map[string]*ConsulConfigEntries { 16 collection := make(map[string]*ConsulConfigEntries) 17 18 for _, tg := range j.TaskGroups { 19 20 // accumulate config entries by namespace 21 ns := tg.Consul.GetNamespace() 22 if _, exists := collection[ns]; !exists { 23 collection[ns] = &ConsulConfigEntries{ 24 Ingress: make(map[string]*ConsulIngressConfigEntry), 25 Terminating: make(map[string]*ConsulTerminatingConfigEntry), 26 } 27 } 28 29 for _, service := range tg.Services { 30 if service.Connect.IsGateway() { 31 gateway := service.Connect.Gateway 32 if ig := gateway.Ingress; ig != nil { 33 collection[ns].Ingress[service.Name] = ig 34 } else if term := gateway.Terminating; term != nil { 35 collection[ns].Terminating[service.Name] = term 36 } 37 } 38 } 39 } 40 41 return collection 42 }