This repository was archived by the owner on Aug 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ # THIS FILE WAS COPIED FROM MAIN STACKHEAD PROJECT.
2+ # It is only required for running smoke tests.
3+ # Do not make changes to this file in any way!
4+ class FilterModule (object ):
5+ """
6+ Jinja2 filters for container related stuff
7+ """
8+
9+ def filters (self ):
10+ return {
11+ 'containerPorts' : self .container_ports
12+ }
13+
14+ def container_ports (self , containerapp__expose , project_name ):
15+ containerapp__expose .sort (key = lambda x : x ['service' ])
16+ output = []
17+
18+ processed = []
19+ previous_service = ""
20+ index = 0
21+ for nginx_expose in containerapp__expose :
22+ service_name = nginx_expose ['service' ]
23+ internal_port = nginx_expose ['internal_port' ]
24+ identifier = service_name + '-' + str (internal_port )
25+ if service_name is None or nginx_expose ['external_port' ] == 443 or identifier in processed :
26+ continue
27+ if previous_service != service_name :
28+ index = 0
29+ output .append ({
30+ 'index' : len (output ),
31+ 'service' : service_name ,
32+ 'internal_port' : internal_port ,
33+ 'tfstring' : "${docker_container.stackhead-" + project_name + "-" + service_name + ".ports[" + str (index ) + "].external}"
34+ })
35+ previous_service = service_name
36+ index += 1
37+ processed .append (identifier )
38+
39+ return output
You can’t perform that action at this time.
0 commit comments