Skip to content

Commit

Permalink
Correct behavior of EXTENDS (#1516)
Browse files Browse the repository at this point in the history
Ensure that local config keys overwrite inherited config keys rather
than the other way around.
  • Loading branch information
Kurt-von-Laven committed Oct 30, 2022
1 parent 5af941b commit 3e61d93
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l

- Replace `set-output` usage with `GITHUB_OUTPUT`
- New MegaLinter plugin: [mustache](https://github.com/one-acre-fund/mega-linter-plugin-logstash): Plugin to validate [Logstash](https://www.elastic.co/guide/en/logstash/current/configuration.html) pipeline definition files using [mustache](https://github.com/breml/logstash-config), by [Yann Jouanique](https://github.com/Yann-J)

- Correct behavior of `EXTENDS` ([#1516](https://github.com/oxsecurity/megalinter/issues/1516))
- Add the SPELL_*_FILE_EXTENSIONS parameter for each SPELL type linter. If set, it will use this value to filter instead of the default behavior which is to parse the files of all other linters executed ([#1997](https://github.com/oxsecurity/megalinter/issues/1997)).


- Linter versions upgrades
- [djlint](https://djlint.com/) from 1.19.2 to **1.0.3** on 2022-10-24
- [eslint-plugin-jsonc](https://ota-meshi.github.io/eslint-plugin-jsonc/) from 2.4.0 to **2.5.0** on 2022-10-24
Expand Down
5 changes: 4 additions & 1 deletion megalinter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def init_config(workspace=None):
)
# manage EXTENDS in configuration
if "EXTENDS" in runtime_config:
combined_config = {}
extends = runtime_config["EXTENDS"]
if isinstance(extends, str):
extends = extends.split(",")
Expand All @@ -80,8 +81,10 @@ def init_config(workspace=None):
r.status_code == 200
), f"Unable to retrieve EXTENDS config file {config_file_name}"
extends_config_data = yaml.safe_load(r.content)
runtime_config.update(extends_config_data)
combined_config.update(extends_config_data)
CONFIG_SOURCE += f"\n[config] - extends from: {extends_item}"
combined_config.update(runtime_config)
runtime_config = combined_config
# Print & set config in cache
print(f"[config] {CONFIG_SOURCE}")
set_config(runtime_config)
Expand Down
2 changes: 1 addition & 1 deletion megalinter/tests/test_megalinter/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_remote_config_extends_success(self):
remote_config = self.test_folder + "base.mega-linter.yml"
os.environ["MEGALINTER_CONFIG"] = remote_config
config.init_config()
self.assertEqual("(extension1)", config.get("FILTER_REGEX_INCLUDE"))
self.assertEqual("(base)", config.get("FILTER_REGEX_INCLUDE"))
self.assertEqual("(extension2)", config.get("FILTER_REGEX_EXCLUDE"))
self.assertEqual("true", config.get("SHOW_ELAPSED_TIME"))

Expand Down

0 comments on commit 3e61d93

Please sign in to comment.