Skip to content

Commit

Permalink
WIP Load new configuration defaults for RPM sub-components of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mmathesius committed Apr 9, 2021
1 parent db5ccd8 commit de747d7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/distrobaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,29 @@ def load_config(crepo):
"Configuration error: defaults.%s missing.", dk
)
return None
# parse defaults for module sub-components
for dk in ("rpms",):
n["defaults"]["modules"][dk] = dict()
for dkk in ("source", "destination"):
if (
dk in cnf["defaults"]["modules"]
and dkk in cnf["defaults"]["modules"][dk]
):
n["defaults"]["modules"][dk][dkk] = cnf["defaults"][
"modules"
][dk][dkk]
else:
logger.warning(
"Configuration warning: defaults.modules.%s.%s "
"not defined, using value from defaults.%s.%s",
dk,
dkk,
dk,
dkk,
)
n["defaults"]["modules"][dk][dkk] = str(
n["defaults"][dk][dkk]
)
else:
logger.error("Configuration error: defaults missing.")
return None
Expand Down Expand Up @@ -406,6 +429,23 @@ def load_config(crepo):
nc[k][p]["cache"][ck] = str(
cnf[k][p]["cache"][ck]
)
if k == "modules":
# parse overrides for module sub-components
for ck in ("rpms",):
nc[k][p][ck] = dict()
nc[k][p][ck]["source"] = n["defaults"][k][ck][
"source"
] % {
"component": cname,
"stream": sname,
}
nc[k][p][ck]["destination"] = n["defaults"][k][ck][
"destination"
] % {
"component": cname,
"stream": sname,
}
# TODO: finish parsing/formatting/storing overrides
logger.info(
"Found %d configured component(s) in the %s namespace.",
len(nc[k]),
Expand Down
7 changes: 7 additions & 0 deletions tests/data/config/distrobaker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ configuration:
modules:
source: "%(component)s.git#%(stream)s"
destination: "%(component)s.git#%(stream)s-fluff-42.0.0-alpha"
rpms:
source: "%(component)s.git"
destination: "%(component)s.git#stream-%(name)-%(stream)s"
cache:
source: "%(component)s"
destination: "%(component)s"
Expand All @@ -64,3 +67,7 @@ components:
modules:
testmodule:master:
destination: testmodule#stream-master-fluff-42.0.0-alpha-experimental
rpms:
componentrpm:
source: componentsource.git#sourcebranch
destination: coomponentrpm.git#fluff-42.0.0-alpha-experimental
8 changes: 8 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def test_load_config(self):
# make sure what was loaded matches get_config()
self.assertEqual(cfg, distrobaker.get_config())

# verify modular RPM component defaults were loaded
self.assertEqual(
cfg["main"]["defaults"]["modules"]["rpms"],
{
"source": "%(component)s.git",
"destination": "%(component)s.git#stream-%(name)-%(stream)s",
},
)
# verify some derived values are present in the configuration
# with the expected values
self.assertEqual(
Expand Down

0 comments on commit de747d7

Please sign in to comment.