forked from elastic/ansible-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: avoid mutable default arguments in custom filter plugins #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d092b49
fix: avoid mutable default arguments in custom filter plugins
hex-botas[bot] 869dd8e
docs: add AGENTS.md with context-aware PR title requirements
LukoJy3D 32bce73
fix: normalise filter defaults only when the argument is None
LukoJy3D 8f06115
docs: keep AGENTS.md free of private infrastructure details
LukoJy3D File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # AGENTS.md -- ansible-elasticsearch | ||
|
|
||
| This file is the vendor-neutral agent brief (Cursor, Claude Code, DEX, and similar). | ||
| There is no `CLAUDE.md`. Read it before opening a pull request. | ||
|
|
||
| ## What this repo is | ||
|
|
||
| Hostinger fork of [elastic/ansible-elasticsearch](https://github.com/elastic/ansible-elasticsearch). | ||
| It is the Ansible role that installs and configures Elasticsearch nodes for Hostinger's | ||
| observability clusters (INT / KUL / BOS). | ||
|
|
||
| Consumed from [ansible-infra](https://github.com/hostinger/ansible-infra) as the | ||
| `community.elasticsearch` role (git source, version-pinned). Cluster bootstrap, | ||
| inventory, and node sizing live in ansible-infra — this repo is the role only. | ||
| Owner: `@hostinger/observability`. | ||
|
|
||
| ## Layout | ||
|
|
||
| ```text | ||
| defaults/main.yml Role defaults (version, paths, API, SSL, X-Pack) | ||
| tasks/ Install, config, plugins, SSL, X-Pack/security | ||
| templates/ elasticsearch.yml, jvm.options, repo, security files | ||
| filter_plugins/custom.py Jinja filters used by tasks and templates | ||
| handlers/main.yml Restart/reload | ||
| molecule/ Integration scenarios: default, security, custom-config | ||
| tests/ Unit tests for filter_plugins (pytest) | ||
| ``` | ||
|
|
||
| Most work happens in `tasks/`, `templates/`, `defaults/main.yml`, and | ||
| `filter_plugins/custom.py`. | ||
|
|
||
| ## Pull request titles | ||
|
|
||
| The GitHub PR title is the primary signal for humans, release-drafter, and coding | ||
| agents. It must describe the actual change so someone can understand the PR | ||
| without opening the diff. | ||
|
|
||
| Use [Conventional Commits](https://www.conventionalcommits.org): | ||
|
|
||
| ```text | ||
| type: imperative summary | ||
| type(scope): imperative summary | ||
| ``` | ||
|
|
||
| Allowed types: `feat`, `fix`, `chore`, `refactor`, `docs`, `test`, `ci`, `perf`. | ||
|
|
||
| **Required** | ||
|
|
||
| - Name the behaviour, file, or subsystem that changed (filters, SSL, molecule, FQCN, …). | ||
| - Match the title to the commits and the diff. If the work is a bug fix, the type is `fix:`, not `chore:` or `refactor:`. | ||
| - Keep it specific enough that an agent can decide whether the PR is relevant without reading the body. | ||
|
|
||
| **Forbidden** — these titles are not context-aware and must not be used: | ||
|
|
||
| - `Daily code improvement (YYYY-MM-DD)` | ||
| - `Weekly code improvement (YYYY-MM-DD)` | ||
| - `Daily code improvement` | ||
| - Generic hex/DEX labels, dated batch names, or “misc fixes” | ||
|
|
||
| | Bad | Good | | ||
| | --- | --- | | ||
| | `Daily code improvement (2026-09-08)` | `fix: avoid mutable default arguments in custom filter plugins` | | ||
| | `Weekly code improvement (2026-05-29)` | `refactor: extract shared reserved-entry predicate in custom filters` | | ||
| | `hex improvements` | `chore: qualify remaining module invocations with FQCNs` | | ||
|
|
||
| If a scheduled agent run produces several unrelated fixes, open **one PR per | ||
| change** (or at least one PR per concern), each with its own context-aware title. | ||
| Do not bundle them under a dated catch-all. | ||
|
|
||
| The PR title and the subject of the main commit should say the same thing. | ||
|
|
||
| ## Commits | ||
|
|
||
| - Conventional Commits, imperative mood (`avoid`, `extract`, `qualify` — not `avoided` / `extracting`). | ||
| - Do not commit secrets, license files, or `.env`. | ||
|
|
||
| ## Tests | ||
|
|
||
| - Filter changes: add or extend `tests/test_custom_filters.py` and run | ||
| `python3 -m pytest tests -q`. | ||
| - Role behaviour: Molecule scenarios `default`, `security`, `custom-config` | ||
| (`molecule test -s <scenario>`). CI runs Molecule on pull requests. | ||
| - Do not “fix” a filter by changing its default handling without a test that | ||
| pins omitted arguments and the previously untested call paths. | ||
|
|
||
| ## Coupled changes | ||
|
|
||
| - New Jinja filter → register it in `FilterModule.filters()`, unit-test it, and | ||
| use it from a task or template. | ||
| - `es_config` / template change → check `templates/elasticsearch.yml.j2` and any | ||
| `es_config_*` override variables. | ||
| - Security user/role filters (`filter_reserved`, `extract_role_users`) → tasks | ||
| under `tasks/xpack/security/`. Call sites are positional Jinja pipes; keep | ||
| parameter names consistent across sibling filters. | ||
| - Role version bump is **not** this repo: ansible-infra pins | ||
| `community.elasticsearch` in `collections/requirements.yml`. | ||
|
|
||
| ## Anti-patterns | ||
|
|
||
| - Do **not** use mutable default arguments (`values=[]`, `users={}`) in | ||
| `filter_plugins/`. Default to `None` and assign with `if x is None:` (not | ||
| `x = x or []`, which treats empty strings as missing). | ||
| - Do **not** edit rendered config on Elasticsearch hosts; change templates here. | ||
| - Do **not** add narrating comments that restate the next line. | ||
| - Do **not** retitle a specific change as a dated “daily/weekly improvement”. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.