Skip to content

Commit 99e8fda

Browse files
authored
Merge pull request #141 from ChannelFinder/better-env
Pass section to env vars
2 parents de671af + fadd859 commit 99e8fda

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

server/compose.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ services:
1313
timeout: 30s
1414
retries: 3
1515
environment:
16-
RECCEIVER_PROCS: cf
17-
RECCEIVER_LOGLEVEL: DEBUG
18-
RECCEIVER_INFOTAGS: archive
19-
RECCEIVER_ALIAS: TRUE
20-
RECCEIVER_RECORDTYPE: TRUE
21-
RECCEIVER_RECORDDESC: TRUE
22-
RECCEIVER_CLEANONSTART: TRUE
23-
RECCEIVER_USERNAME: admin
16+
RECCEIVER_RECCEIVER_PROCS: cf
17+
RECCEIVER_RECCEIVER_LOGLEVEL: DEBUG
18+
RECCEIVER_CF_INFOTAGS: archive
19+
RECCEIVER_CF_ALIAS: TRUE
20+
RECCEIVER_CF_RECORDTYPE: TRUE
21+
RECCEIVER_CF_RECORDDESC: TRUE
22+
RECCEIVER_CF_CLEANONSTART: TRUE
23+
RECCEIVER_CF_USERNAME: admin
24+
RECCEIVER_CF_CFUSERNAME: admin
25+
RECCEIVER_CF_CFPASSWORD: password
26+
RECCEIVER_CF_BASEURL: http://cf:8080/ChannelFinder
27+
RECCEIVER_CF_VERIFYSSL: FALSE
2428
volumes:
2529
- type: bind
2630
source: docker/config/cf.conf

server/demo.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,16 @@
108108

109109
# The env variable to use for the owner field when creating channels in channelfinder
110110
#env_owner_variable = ENGINEER
111+
112+
# ChannelFinderClient configuration
113+
# The URL of the ChannelFinder instance to connect to
114+
#baseUrl = http://localhost:8080/ChannelFinder
115+
116+
# Username to login to ChannelFinder with
117+
#cfUsername = cfstore
118+
119+
# Password to login to ChannelFinder with
120+
#cfPassword = cfstore
121+
122+
# Whether to verify the SSL certificate when connecting to ChannelFinder
123+
#verifySSL = True

server/recceiver/processors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
]
2323

2424

25-
def _env_vars():
26-
prefix = "RECCEIVER_"
25+
def _env_vars(section: str) -> dict[str, str]:
26+
prefix = "RECCEIVER_" + section.upper() + "_"
2727
return {k.removeprefix(prefix).lower(): v for k, v in os.environ.items() if k.startswith(prefix)}
2828

2929

3030
class ConfigAdapter(object):
3131
def __init__(self, conf, section):
3232
self._C, self._S = conf, section
33-
self.env_vars = _env_vars()
33+
self.env_vars = _env_vars(section)
3434

3535
def __len__(self):
3636
return len(self._C.items(self._S, raw=True))
@@ -77,7 +77,7 @@ def __init__(self, cfile=None):
7777
elif not parser.has_section("recceiver"):
7878
parser.add_section("recceiver")
7979

80-
pnames = parser.get("recceiver", "procs", vars=_env_vars()).split(",")
80+
pnames = parser.get("recceiver", "procs", vars=_env_vars("recceiver")).split(",")
8181

8282
plugs = {}
8383

server/recceiver_full.conf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,15 @@ username = cfstore
104104
# The env variable to use for the owner field when creating channels in channelfinder
105105
env_owner_variable = ENGINEER
106106

107-
# The channelFinder client is configuration information is
108-
# stored in /etc/channelfinderapi.conf as described in the client
109-
# Can be configured to be this file, like so:
110-
[DEFAULT]
111-
BaseURL=http://channelfinder.site:8080/ChannelFinder
112-
username=MyUserName
113-
password=MyPassword
107+
# ChannelFinderClient configuration
108+
# The URL of the ChannelFinder instance to connect to
109+
baseUrl = https://channelfinder.example.com/ChannelFinder
110+
111+
# Username to login to ChannelFinder with
112+
cfUsername = recceiver-cfstore
113+
114+
# Password to login to ChannelFinder with
115+
cfPassword = somethingcryptic
116+
117+
# Whether to verify the SSL certificate when connecting to ChannelFinder
118+
verifySSL = True

0 commit comments

Comments
 (0)