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