Metadata-Version: 2.3
Name: qubership-envgene-linter
Version: 1.0.1
Summary: Qubership EnvGene CLI for instance configuration and template checks in instance and template repositories.
Keywords: envgene,linter,lint,configuration,yaml,quality
Author: Qubership
Maintainer: Qubership
Requires-Python: ~=3.12
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Provides-Extra: dev
Provides-Extra: release
Requires-Dist: Jinja2 (==3.1.6)
Requires-Dist: build (>=1.2) ; extra == "release"
Requires-Dist: click (==8.1.7)
Requires-Dist: pytest (>=8.3) ; extra == "dev"
Requires-Dist: ruamel.yaml (==0.18.17)
Requires-Dist: twine (>=6) ; extra == "release"
Project-URL: Documentation, https://github.com/Netcracker/qubership-envgene/blob/feature/envgene-linter-dev/modules/envgene-linter/README.md
Project-URL: Homepage, https://github.com/Netcracker/qubership-envgene/tree/feature/envgene-linter-dev/modules/envgene-linter
Project-URL: Issues, https://github.com/Netcracker/qubership-envgene/issues
Project-URL: Source, https://github.com/Netcracker/qubership-envgene/tree/feature/envgene-linter-dev/modules/envgene-linter
Description-Content-Type: text/markdown

# EnvGene Linter

- [Install](#install)
- [Run a check](#run-a-check)
- [Run selected rules](#run-selected-rules)
- [Open the report](#open-the-report)
- [Troubleshooting](#troubleshooting)

EnvGene Linter checks EnvGene instance and template repositories and saves findings in HTML and JSON reports.
Template-only repositories are checked by TPL-1, TPL-4, and TPL-6. Other implemented checks require instance inputs.
The command does not modify configuration files.

## Install

You need Python 3.12 or newer with pip.
The Python command can be named `python` or `python3`, depending on your installation.
Check which command is available with `python --version` or `python3 --version`.
Use one of the following commands with Python 3.12 or newer to install or update the tool:

```bash
python -m pip install --upgrade qubership-envgene-linter
```

Or, if your Python command is `python3`:

```bash
python3 -m pip install --upgrade qubership-envgene-linter
```

On Windows, you can also use `py -m pip` if the Python launcher is installed.
You do not need to download the source repository or build the package.

## Run a check

Open a terminal in your repository root: the directory containing `environments/`, `templates/`, or both.
Run:

```bash
envgene-linter check
```

To check a repository without changing directories, pass its path or `-i`:

```bash
envgene-linter check /path/to/instance-repository
envgene-linter check -i /path/to/instance-repository
```

Use either the positional path or `-i`, not both. Without either, the command checks the current directory.
Add `--console` to also print findings in the terminal. Both report files are still written.

To compare PLACE-12 candidates with local template sources, pass `-t` as well.
The path can be the template repository root or its `templates/` directory.

```bash
envgene-linter check -i /path/to/instance-repository -t /path/to/template-repository
```

The long options are `--instance-repo` and `--template-repo`.
Template context does not render Jinja, download artifacts, or run a separate template check.

## Run selected rules

Without `-r`, every enabled rule runs.
Pass `-r` or `--rule` to run only the rules you name.
Repeat the option or separate IDs with commas. A repeated ID runs once.
Use the rule key, such as `INT-2` or `PLACE-1`.
A key that is not a rule ID is rejected, and the command exits with code 2 before it writes a report.

```bash
envgene-linter check -r INT-2
envgene-linter check -r PLACE-1,PLACE-2
envgene-linter check -r PLACE-1 -r PLACE-2
```

A named rule runs even when its build flag is off. `NAME-1`, `NAME-3`, and `NAME-4` are off in this build.
Naming one of them runs it for that command and does not change the build flags.
The report lists only the rules from that command.

## Open the report

When the check finishes, the terminal shows both report locations, for example:

```text
HTML report saved here: /path/to/instance-repository/envgene-linter-report.html
JSON report saved here: /path/to/instance-repository/envgene-linter-report.json
```

Open the HTML file in your browser. Each finding shows the affected file, the issue, and a suggested action.
When several parameters share the same files, they appear in one finding.
The issue names every parameter, and each file appears once.
Use the JSON file for automated processing. It is an array of findings with `rule_id`, `rule_title`, `files`, `issue`, `action`, and `fix_suggestion`.
An empty result is `[]`.

Every successful check replaces both reports. Their filenames are added to the repository's `.gitignore`.
Exit code `0` means the check completed, including runs with findings.
Exit code `2` means the command or its arguments could not be completed.

## Troubleshooting

- If pip reports `externally-managed-environment`, install in a Python virtual environment.
  A virtual environment is optional for the linter, but some systems require one for pip installations.
- If the terminal cannot find `envgene-linter`, check that your Python scripts directory is on `PATH`.
  If you installed in a virtual environment, activate that environment first.
- If neither `environments/` nor `templates/` is found, run the command from the repository root.
- For template-only repositories, HTML and console output mark unsupported checks as `Not applicable`. JSON omits them.
  TPL-1, TPL-4, and TPL-6 still run unless you pass `-r` or their build flags are off.

Findings are for review. The command does not edit the repository.

# EnvGene Linter changelog

- [1.0.1](#101)
- [1.0.0](#100)
- [0.0.9](#009)
- [0.0.8](#008)
- [0.0.7](#007)
- [0.0.6](#006)
- [0.0.5](#005)
- [0.0.4](#004)
- [0.0.3](#003)
- [0.0.2](#002)
- [0.0.1](#001)

## 1.0.1

- Turn PLACE-1 off by default. The rule stays in the package.
  A check without `-r` omits its findings and its report section.
  `envgene-linter check -r PLACE-1` still runs it for that command.
- Show Fix and Review counts on each collapsed HTML rule heading.
  Finding cards stay inside the section.
- Run checks and list reports in this order: PLACE-4, PLACE-12, PLACE-6, PLACE-8, PLACE-10,
  then the remaining rules in their previous order.
- No configuration migration is required. The command does not modify configuration files.

## 1.0.0

- Add `-r` / `--rule` to run one or more rules. Repeat the option or separate IDs with commas.
  A named rule runs even when its build flag is off. Without `-r`, every enabled rule still runs.
  The report lists only the rules from that command.
- Group findings that share the same files, scope, and action. The finding names every parameter,
  and each file appears once. A PLACE-2 finding still treats each named key as its own removal.
- Keep a PLACE-1 move to a repository ParameterSet as Review while PLACE-12 also names that key.
  Decide whether the value belongs in the template before the repository move.
- Read PLACE-4 contract keys from the Cloud Passport schema shipped with the package.
- No configuration migration is required. The command does not modify configuration files.

## 0.0.9

- Add PLACE-12, enabled by default, to review repeated ParameterSet values in environments using the same
  literal template name and artifact name before the first colon, within one cluster or across clusters.
  Compare different versions of one artifact together and retain complete references in source evidence.
  Require distinct authored source entries. A value is shared when at least `N - floor(N/4)` participants
  agree. Name the other environments and leave their instance values in place. Two or three environments
  still require full agreement.
  Keep candidates as Review, exclude uncertain or unsuitable values, and show contributing source locations.
  Group compatible values into one YAML recommendation per selected ParameterSet source combination and scope.
  Show the environment count in findings without the cluster count.
  Add `--template-repo` and `-t` for local source comparisons, readable proposed filenames, and scoped
  descriptor attachments. Add `-i` / `--instance-repo` for an explicit checked instance path.
  Retain positional commands and reject simultaneous positional and explicit instance paths.
  Identify both repository roots in PLACE-12 recommendations when local template context is supplied.
  Explain the target descriptor entry, ParameterSet list, and append order in both reports.
  Show absolute template files to create or edit, descriptor entry positions, and exact YAML paths for changes.
  Keep anchored or inherited descriptor entries as Review when their local edit position cannot be established.
  Propose complete ParameterSet relocation with its original name and existing bindings only when every
  participant agrees and the entire file is eligible.
  Preserve actual values, YAML types, indentation, and every source position in HTML and JSON reports.
  Show portable recipes without `-t`, including actual ParameterSet YAML, logical attachment targets,
  and append-only reference instructions without guessed destination paths.
  Merge into uniquely named existing template ParameterSets, reuse equal values, and retain conflicts in instance.
  Preserve reference order without duplicates and omit the generic recommendation footer.
  Name each instance file once and list the YAML paths to remove. Files that share a path set use one list.
  Resolve supported ParameterSet reference expressions from each environment's local data.
  Continue recipes for unconditional lists followed by unrelated Jinja, and explain blocked proposals with
  source locations.
  Keep PLACE-12 comparisons for environments whose inputs were read when another selected file or environment
  definition cannot be parsed. A comparable group stays silent when one of its own environments has an
  unavailable input. PLACE-1 promotion remains withheld for incomplete merge inputs.
  No configuration migration is required. PLACE-12 does not modify files.

## 0.0.8

- Exclude generated instance objects and pipeline outputs from configuration findings and incomplete-check entries.
   Retain generated Credential catalogs and Cloud Credential references as context for authored inputs.

## 0.0.7

- Check explicit `inventory.cloudPassport` references in INT-2. Report definitely missing local targets as Fix
  and dynamic, unreadable, unsafe, or uncertain lookups as Review. Allow optional passport absence.
- Check only selected Cloud Passport paths in PLACE-3. Ignore unused aliases while retaining findings for
  selected misplaced paths that share a physical file.
- Continue independent checks after recoverable YAML, JSON, and Jinja read or parser failures and write fresh reports.
  Export affected checks as located Review entries in JSON. Keep incomplete merge inputs from confirming
  PLACE-1 promotion or PLACE-2 removal.
- Check connected nested YAML and JSON ParameterSets consistently across reference resolution, content rules,
  and Effective Set merging. Preserve relative-path replacement and generator application order.
  Keep unavailable replacements and incomplete scans from restoring shadowed inputs.
- Include nested YAML and JSON ParameterSets in INT-4's authored candidate and reference analysis.
- Preserve YAML value types in PLACE-1 and PLACE-2 comparisons, including nested collections.
  Treat booleans, integers, floating-point numbers, and numeric strings as distinct values.
- Confirm PLACE-2 removals against every known local selected consumer before reporting Fix.
  Keep necessary overrides silent and report incomplete or unsupported merge contexts as Review.
  Distinguish global, application, nested, and literal dotted source entries.
- Stop reporting `.j2` files based on their directory in TPL-1. Ignore YAML comments while retaining checks
  for Jinja in active values, including quoted strings and block scalars.
- Report literal `data.username` values in `usernamePassword` Credentials as Warning / Fix in SEC-5.
  Ignore exact `envgeneNullValue` placeholders. Unknown expressions and Fernet values remain Review.
- Limit rendered profile reference checks in INT-2 to `profile.name`. Ignore `baseline` and `override_name`.
- Allow same-named ParameterSet fragments across scopes without INT-3 findings.
- Report Shared Template Variable location mismatches as Review in PLACE-10, with generator lookup guidance.
- Suppress NAME-8 passport and companion naming findings when a cluster context contains multiple ordinary passports.
- Clarify SEC-4 Review guidance for intentionally separate user/password Credential IDs.
- Recognize protected EnvGene environment lookups in TPL-4 for YAML templates and guaranteed context fields
  in ordinary environment template descriptor scalars.
- Resolve selected Artifact Definition registry Credentials against the root catalog, including active V2
  authentication configurations. Keep anonymous and inactive configurations out of reference evidence.
- Show skipped checks in HTML and export skipped Jinja checks as located Review entries in JSON,
  so incomplete template checks cannot appear as clean reports.
- Allow all syntactically valid `raw` blocks in TPL-6, regardless of whether they contain Helm syntax.
- Allow all built-in and custom filters in TPL-6, including filter chains and filter blocks.
- Review unsupported or unconfirmed Ansible compatibility after modeling the applicable EnvGene renderer.
  Check legacy lookup forms, filter availability and arguments, and changes to literal raw or string content.
  Include potential legacy expressions in configuration YAML. Exclude root GSF/CI description templates.

## 0.0.6

- Add TPL-4, enabled by default, to review potentially optional Jinja references without recognized presence protection,
  such as `default` or an appropriate `is defined` check. Report candidates as Review without claiming that rendering fails.
- Add TPL-6, enabled by default, to report prohibited Jinja constructs as Fix and uncertain template logic as Review.
  Allow recognizable Helm passthrough in `raw` blocks and review other raw blocks.
  Both new rules check `.j2` files under `templates/` and supported descriptor fields in instance and template repositories.
- Generate `envgene-linter-report.json` alongside HTML on every check, with one object per finding and all related file locations.
  Include `rule_id`, `rule_title`, `files`, `issue`, `action`, and `fix_suggestion`. Write `[]` when there are no findings.
  Add the JSON report filename to `.gitignore` automatically.
- Print separate `HTML report saved here:` and `JSON report saved here:` messages with absolute report paths.

## 0.0.5

- Hide disabled rules in HTML and console reports. If every rule is disabled, show `No rules enabled`.
- Support template repositories containing `templates/` without requiring `environments/`.
  TPL-1 runs on these repositories. Other checks are not yet supported for template-only repositories.
- Add TPL-1, enabled by default, to check YAML and `.j2` placement under `templates/`, `environments/`, and `configuration/`.
  Allow generator-rendered descriptor fields and EnvGene macros. Report misplaced templates and EnvGene Jinja as Fix,
  and ambiguous Helm or application placeholders as Review. No automatic conversion or renaming is performed.
- Add VAL-4, enabled by default, to review JSON collections and YAML block collections encoded as strings
  in connected ParameterSets, including application parameters and nested values.
  Findings recommend native YAML after checking the consumer contract. No automatic conversion is performed.

## 0.0.4

- Add INT-3 to report used reference names defined at multiple environment, cluster, or repository scopes.
  Checks cover ParameterSets, shared Credential files, Resource Profile Overrides, and Shared Template Variables.
- Add INT-4 to flag authored entities for which no references were found in available local sources.
  Findings recommend Review and explain uncertainty, including external templates and rendered references.
  The rule does not establish that removal is safe or delete entities automatically.
- Add NAME-8 to check that selected default Cloud Passports use the filename stem `passport`
  and their selected companion Credential files use `passport-creds`.
  The `passport-infra` file and its companion are excluded.
- Enable INT-3, INT-4, and NAME-8 by default.
- Remove the Type row and its colored chips from HTML findings.
  Cards retain File, Issue, Action, and Fix suggestion. Console severity remains unchanged.
- Show the repository's root folder name below the HTML report heading and in the browser tab title.
  Escape special characters and show the name even when there are no findings.

## 0.0.3

No functional changes from `0.0.2`.

## 0.0.2

- Allow `envgene-linter check` without a repository argument to check the current directory.
  Explicit repository paths remain supported.
- Create or update `envgene-linter-report.html` by default and print its absolute path.
- Add `--console` to also print findings in the terminal. Errors and parsing diagnostics remain visible by default.
- Remove `--html`. HTML reports are generated automatically, including when `--console` is used.

To migrate from `0.0.1`, remove `--html` from existing commands.
Add `--console` to commands that need findings on stdout, including shell redirection and CI log collection.
Each successful check now writes the report and adds it to the checked repository's `.gitignore` if needed.
The report location must be writable. Findings still return exit code `0`, and operational errors return `2`.

## 0.0.1

- Initial PyPI release of `qubership-envgene-linter`.
- Check local instance repositories for placement, naming, secret handling, and reference integrity.
- Print findings in the terminal, with optional HTML output through `--html`.
- Support rule switches configured when the package is built.

