diff options
author | Scott Dodson <sdodson@redhat.com> | 2017-11-27 21:41:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-27 21:41:29 -0500 |
commit | 79dc1695565d4782eb92323118950e6da38ae89e (patch) | |
tree | 22a0f749ab960f9de5b3c68773c1adb84dced83e /roles/openshift_facts | |
parent | c5de3391772fa41f0af79f7d40ced016454d86ea (diff) | |
parent | 01bf8747778f3fed9554d864bc854df7b523b6bf (diff) | |
download | openshift-79dc1695565d4782eb92323118950e6da38ae89e.tar.gz openshift-79dc1695565d4782eb92323118950e6da38ae89e.tar.bz2 openshift-79dc1695565d4782eb92323118950e6da38ae89e.tar.xz openshift-79dc1695565d4782eb92323118950e6da38ae89e.zip |
Merge pull request #6272 from abutcher/fix-env-facts
Fix openshift_env fact creation within openshift_facts.
Diffstat (limited to 'roles/openshift_facts')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index f94e0e097..3c121877a 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -2253,14 +2253,27 @@ class OpenShiftFacts(object): oo_env_facts = dict() current_level = oo_env_facts keys = self.split_openshift_env_fact_keys(fact, openshift_env_structures)[1:] + if len(keys) > 0 and keys[0] != self.role: continue - for key in keys: - if key == keys[-1]: - current_level[key] = value - elif key not in current_level: - current_level[key] = dict() - current_level = current_level[key] + + # Build a dictionary from the split fact keys. + # After this loop oo_env_facts is the resultant dictionary. + # For example: + # fact = "openshift_metrics_install_metrics" + # value = 'true' + # keys = ['metrics', 'install', 'metrics'] + # result = {'metrics': {'install': {'metrics': 'true'}}} + for i, _ in enumerate(keys): + # This is the last key. Set the value. + if i == (len(keys) - 1): + current_level[keys[i]] = value + # This is a key other than the last key. Set as + # dictionary and continue. + else: + current_level[keys[i]] = dict() + current_level = current_level[keys[i]] + facts_to_set = merge_facts(orig=facts_to_set, new=oo_env_facts, additive_facts_to_overwrite=[], |