datasecops-cli 0.7.0b10__tar.gz → 0.7.0b12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/CHANGELOG.md +40 -2
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/PKG-INFO +15 -2
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/README.md +14 -1
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/docs/git-operations.md +2 -0
- datasecops_cli-0.7.0b12/docs/squash-merge-into-test-review.md +172 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/pyproject.toml +1 -1
- datasecops_cli-0.7.0b12/src/datasecops_cli/__init__.py +1 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/main.py +52 -16
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/configuration.py +2 -55
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/development.py +20 -24
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/git_operations.py +61 -34
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/models/project_config.py +21 -1
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dbt_project_generator.py +18 -13
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/download_service.py +10 -4
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/git_service.py +58 -45
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/pipeline_env.py +42 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/snowflake_service.py +5 -1
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/server.py +14 -1
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/diagram.py +11 -9
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_dcm_model.py +4 -3
- datasecops_cli-0.7.0b12/tests/test_git_operations_menu.py +58 -0
- datasecops_cli-0.7.0b12/tests/test_git_service.py +130 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_main.py +96 -1
- datasecops_cli-0.7.0b12/tests/test_mcp_branching_rules.py +74 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_models.py +25 -0
- datasecops_cli-0.7.0b10/src/datasecops_cli/__init__.py +0 -1
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/.github/workflows/auto-tag.yml +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/.github/workflows/publish-cli.yml +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/.github/workflows/test.yml +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/.gitignore +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/AGENTS.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/DEVELOPMENT.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/LICENSE +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/docs/dcm.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/docs/getting-started.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/docs/legacy.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/docs/legacy_plan_of_action.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/docs/mcp-server.md +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/mcp-servers.json +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/scripts/vendor_model.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/setup.ps1 +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/setup.sh +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/config.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/dcm_operations.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/downloads.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/models/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/models/git_helpers.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/bootstrap_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dbt_runner.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_orchestrator.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_pipelines.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_registry.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/directory_scaffolder.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/linting_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/model_commands.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/skill_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/upstream_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/display.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/file_utils.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/mcp.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/yaml_utils.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/__main__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/connection.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/convert.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/expand.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/extract.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/render.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/schema.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/scope.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/scripts.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/starter.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/templates/macros/role.sql +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/templates/macros/role_guard.sql +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/templates/macros/warehouse.sql +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_model/validate.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/__init__.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_config.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_dbt_project_generator_profiles.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_dbt_runner.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_dcm_orchestrator.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_dcm_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_download_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_file_utils.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_linting_service.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_mcp_lint_tools.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_model_commands.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_pipeline_env.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_version.py +0 -0
- {datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/tests/test_yaml_utils.py +0 -0
|
@@ -4,6 +4,46 @@ All notable changes to the DataSecOps CLI are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **`download packages` ignored upstream package exclusion for downstream projects with no packages of their own** — `download_dbt_packages()`'s upstream-exclusion filter was nested inside `if profile.dbt_packages:`, so a downstream project relying entirely on an upstream project (empty `dbt_packages`) skipped filtering altogether and got the full, unfiltered package list instead of excluding what the upstream project already provides. The same bug existed in the unused `generate_packages_yml()`. Both now compute the enabled set independently of whether `dbt_packages` is empty, then subtract upstream packages regardless.
|
|
10
|
+
- **Configurable branch names (PR review follow-ups):**
|
|
11
|
+
- Legacy `main`/`test`/`prod` branches could leak through as selectable deploy/reset targets when a project configured different trunk/integration/production names but its `deployment_branches`/`environments` still carried the old literal names. `_deploy()` and `_reset_branch_from_main()` now always exclude the legacy defaults in addition to the configured names.
|
|
12
|
+
- A blank or `null` `trunk_branch`/`integration_branch`/`production_branch` in the native app's `SOURCE_CONTROL` config previously produced invalid branch refs (e.g. `origin/`) or aborted config loading entirely; `SourceControl` now falls back to the documented default for any blank/null value.
|
|
13
|
+
- `get_test_file_conflicts()`/`get_test_commits()` parsed a squash-merge commit's source branch by stripping `" into {current integration_branch}"` from its message — after renaming `integration_branch`, historical commits (which still say `" into {old name}"`) were misparsed, could be misclassified as stale, and silently force-removed from the integration branch. Parsing now splits on the last `" into "` separator, independent of the currently configured name.
|
|
14
|
+
- The MCP server's `get_branching_rules` omitted `trunk_branch`/`integration_branch`/`production_branch`; it now includes them (falling back to defaults for blank/null values).
|
|
15
|
+
- Git Operations menu labels and confirmations (`rebase`, `squash to test`, `remove from test`, `deploy to prod`, `reset branch`, and their confirmation/error text) now use the configured branch names instead of hardcoded `main`/`test`.
|
|
16
|
+
|
|
17
|
+
## [0.7.0b12] - 2026-11-02
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Git deploy/trunk/integration branch names are configurable** — `SourceControl` gains `trunk_branch` (default `"main"`), `integration_branch` (default `"test"`), and `production_branch` (default `"prod"`), read from the native app's `SOURCE_CONTROL` framework config. `GitService` and the Git Operations menu (deploy, deploy to prod, squash to test, remove from test, reset branch, cleanup, delete branch) now use these settings instead of hardcoded `"main"`/`"test"`/`"prod"` literals. Existing projects keep working unchanged since the defaults match the old hardcoded values.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **Lint menu merges find/fix pairs into single prompts** — the "find modified"/"fix modified" and "find all"/"fix all" option pairs are now one "modified" (or "changed" on dbt2, replacing the old separate "changed" option) and one "all" option each, asking "Also auto-fix the issues found?" instead of needing two separate menu entries.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
29
|
+
- **Configuration menu's `dbt engine` and `upgrade dbt` options** — removed `[6] dbt engine` (local `.datasecops.yml` toggle between `dbt2`/`dbt_core`) and `[7] upgrade dbt` (unpinned `pip install --upgrade dbt`, dbt2 only). The engine toggle duplicated the framework's `PROJECT` config (which is already the source of truth for `dbt_engine`), and `upgrade dbt` bypassed the framework's pinned dbt version instead of going through `[1] install dbt`.
|
|
30
|
+
|
|
31
|
+
## [0.7.0b11] - 2026-11-01
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- **`pipeline env` sets a run's full context from the app** — new `--mode release|ci|clone|default`, `--run-id`, `--clone-database` and `--profile` options. Besides the dbt target, the command calls the app's `api.pipeline_context` and exports the profile's databases (`DATABASE_PREFIX`, `SOURCE_DATABASE`, `TARGET_DATABASE` for the mode), `DBT_PROJECT_NAME`, `DBT_EXCLUDE_FLAG`, the docs repository, git tag identity, manifest storage settings and `DBT_VERSION`, so pipelines no longer hardcode them and settings changes apply on the next run. Apps without the procedure still get the dbt target values (with a note); any other failure to read the context fails the command, so a run never continues with part of it. Exported names must be plain upper-case variable names.
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- **Role diagrams no longer say "ACE"** — Entra ID security group (SCIM) roles are labelled by their name without the security prefix (no `ACE: ` in front), the security groups' box is "Entra ID security groups (SCIM)", and `datasecops model diagram`'s titles are Full hierarchy, Snowflake roles only, Entra ID functional and security groups, Entra ID groups and their Snowflake roles. The view ids are unchanged.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- **`download --profile` lost its `-p` short option** — fixing a review comment about `pipeline env --profile` reusing `-p` accidentally removed the alias from `download` instead, breaking existing invocations like `datasecops download pipelines -p core`. `-p` is restored on `download --profile`, and removed from `pipeline env --profile` (the option it was meant to come off).
|
|
44
|
+
- **`pipeline env` accepted a variable name with a trailing newline** — `export()`'s name check used `_NAME.match()`, and `$` in a non-multiline regex matches just before a trailing newline, so `{"X\n": "1"}` from the app passed validation and corrupted the written `$GITHUB_ENV`/`##vso` output. It now uses `fullmatch()`.
|
|
45
|
+
- **`test_import_round_trip_is_statement_identical` failed on Windows** — it wrote rendered SQL with `Path.write_text()` and no encoding, so Windows used the system locale (cp1252) instead of UTF-8 and crashed on the em dash in the rendered header comment; the writes now pass `encoding="utf-8"`, matching how the library itself reads and writes these files.
|
|
46
|
+
|
|
7
47
|
## [0.7.0b10] - 2026-10-28
|
|
8
48
|
|
|
9
49
|
### Fixed
|
|
@@ -23,9 +63,7 @@ All notable changes to the DataSecOps CLI are documented in this file.
|
|
|
23
63
|
### Fixed
|
|
24
64
|
|
|
25
65
|
- **`dbt build` was missing from the Development menu entirely** — `DbtRunner.build()` already existed and the README already advertised "dbt run, build, test, lint", but no menu option called it. It's now a top-level menu entry with full/modified/specific run options, mirroring `run`.
|
|
26
|
-
=======
|
|
27
66
|
- **`install-dbt` / `install-sqlfluff` failed when no version was marked active** — the CLI only used a `DBT_VERSIONS` entry with `active: true`, while the app falls back to the first enabled version, so a pipeline could fail to install dbt that the app considered configured. The CLI now uses the same fallback, and strips the `v` prefix the app stores (`v2.0.9` → `dbt==2.0.9`). Orbit pipelines now install dbt 2.0 through `datasecops download install-dbt` too (instead of a version pinned in the YAML), so they follow the version active in the app without re-rendering.
|
|
28
|
-
>>>>>>> b0b3c02 (Fall back to the first enabled version when none is active)
|
|
29
67
|
|
|
30
68
|
## [0.7.0b8] - 2026-10-27
|
|
31
69
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datasecops-cli
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.0b12
|
|
4
4
|
Summary: DataSecOps Framework CLI for Snowflake Native App
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -182,9 +182,22 @@ the branch, so pipelines don't hard-code them:
|
|
|
182
182
|
```bash
|
|
183
183
|
datasecops pipeline env --branch "$GITHUB_REF_NAME" # GitHub Actions: target whose Branch is this branch
|
|
184
184
|
datasecops pipeline env --branch "$BUILD_SOURCEBRANCH" # Azure DevOps (the full ref, not BUILD_SOURCEBRANCHNAME)
|
|
185
|
-
datasecops pipeline env --target unit-test
|
|
185
|
+
datasecops pipeline env --target unit-test --mode ci --run-id "$GITHUB_RUN_ID" # a unit-test run
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
+
With an app that has `api.pipeline_context`, the command also sets the run's other values from the
|
|
189
|
+
app's settings, so changing them in the app applies on the next run without regenerating the pipelines:
|
|
190
|
+
|
|
191
|
+
| Variable | From |
|
|
192
|
+
|---|---|
|
|
193
|
+
| `DBT_PROJECT_NAME`, `DATABASE_PREFIX`, `SOURCE_DATABASE`, `DBT_EXCLUDE_FLAG` | the dbt profile (`--profile`, default the project's in `.datasecops.yml`); `SOURCE_DATABASE` uses the production branch |
|
|
194
|
+
| `TARGET_DATABASE` | `--mode`: `release` `<prefix><TARGET>` (default), `ci` `<prefix>UT_<--run-id>`, `clone` `<prefix><--clone-database>`, `default` the production database |
|
|
195
|
+
| `DBT_DOCS_REPO`, `DBT_DOCS_REPO_FOLDER`, `GIT_TAG_EMAIL`, `GIT_TAG_NAME` | Settings › Deployment |
|
|
196
|
+
| `S3_MANIFEST_BUCKET`, `AWS_REGION` / `AZURE_STORAGE_ACCOUNT`, `AZURE_STORAGE_CONTAINER`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` | the manifest storage provider's settings |
|
|
197
|
+
| `DBT_VERSION` | the active version of the project's dbt engine, dbt 2.0 or dbt Core (without the `v`) |
|
|
198
|
+
|
|
199
|
+
No secrets are returned. Older apps only give the dbt target (a note is printed).
|
|
200
|
+
|
|
188
201
|
Pass the branch through the runner's environment variable, not a `${{ ... }}` / `$(...)` expression:
|
|
189
202
|
those are substituted into the script before the shell runs, so a branch name containing `$(...)`
|
|
190
203
|
would execute.
|
|
@@ -162,9 +162,22 @@ the branch, so pipelines don't hard-code them:
|
|
|
162
162
|
```bash
|
|
163
163
|
datasecops pipeline env --branch "$GITHUB_REF_NAME" # GitHub Actions: target whose Branch is this branch
|
|
164
164
|
datasecops pipeline env --branch "$BUILD_SOURCEBRANCH" # Azure DevOps (the full ref, not BUILD_SOURCEBRANCHNAME)
|
|
165
|
-
datasecops pipeline env --target unit-test
|
|
165
|
+
datasecops pipeline env --target unit-test --mode ci --run-id "$GITHUB_RUN_ID" # a unit-test run
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
With an app that has `api.pipeline_context`, the command also sets the run's other values from the
|
|
169
|
+
app's settings, so changing them in the app applies on the next run without regenerating the pipelines:
|
|
170
|
+
|
|
171
|
+
| Variable | From |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `DBT_PROJECT_NAME`, `DATABASE_PREFIX`, `SOURCE_DATABASE`, `DBT_EXCLUDE_FLAG` | the dbt profile (`--profile`, default the project's in `.datasecops.yml`); `SOURCE_DATABASE` uses the production branch |
|
|
174
|
+
| `TARGET_DATABASE` | `--mode`: `release` `<prefix><TARGET>` (default), `ci` `<prefix>UT_<--run-id>`, `clone` `<prefix><--clone-database>`, `default` the production database |
|
|
175
|
+
| `DBT_DOCS_REPO`, `DBT_DOCS_REPO_FOLDER`, `GIT_TAG_EMAIL`, `GIT_TAG_NAME` | Settings › Deployment |
|
|
176
|
+
| `S3_MANIFEST_BUCKET`, `AWS_REGION` / `AZURE_STORAGE_ACCOUNT`, `AZURE_STORAGE_CONTAINER`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID` | the manifest storage provider's settings |
|
|
177
|
+
| `DBT_VERSION` | the active version of the project's dbt engine, dbt 2.0 or dbt Core (without the `v`) |
|
|
178
|
+
|
|
179
|
+
No secrets are returned. Older apps only give the dbt target (a note is printed).
|
|
180
|
+
|
|
168
181
|
Pass the branch through the runner's environment variable, not a `${{ ... }}` / `$(...)` expression:
|
|
169
182
|
those are substituted into the script before the shell runs, so a branch name containing `$(...)`
|
|
170
183
|
would execute.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The CLI provides a structured git workflow designed around a branching strategy where feature branches are squash-merged into a `test` branch for integration testing, and only `main` is deployed to production.
|
|
4
4
|
|
|
5
|
+
> The `main`/`test`/`prod` branch names below are the defaults. They're configurable via the native app's `SOURCE_CONTROL` framework config (`trunk_branch`, `integration_branch`, `production_branch`) — set those if your project uses different branch names (e.g. `trunk`/`staging`/`release`).
|
|
6
|
+
|
|
5
7
|
## Branch Strategy
|
|
6
8
|
|
|
7
9
|
```
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Review: "Squash Merge into Test" Functionality
|
|
2
|
+
|
|
3
|
+
This is a code-level review of what `datasecops`'s "squash to test" / "remove from test" Git
|
|
4
|
+
Operations actually do, as implemented today in `src/datasecops_cli/services/git_service.py`
|
|
5
|
+
and `src/datasecops_cli/menus/git_operations.py`. It traces the exact sequence of git commands
|
|
6
|
+
run, not just the intended design.
|
|
7
|
+
|
|
8
|
+
Branch names used below assume the defaults (`main` trunk, `test` integration branch), which are
|
|
9
|
+
now configurable via `SourceControl.trunk_branch` / `SourceControl.integration_branch` — see
|
|
10
|
+
[`docs/git-operations.md`](git-operations.md). Everywhere `test` is written below, read it as
|
|
11
|
+
"the configured integration branch", and `main` as "the configured trunk branch".
|
|
12
|
+
|
|
13
|
+
## What it's for
|
|
14
|
+
|
|
15
|
+
Feature/bugfix/hotfix branches are built from `main`. Instead of merging each one into `main`
|
|
16
|
+
directly, they're **squash-merged into a shared `test` branch** so multiple branches' changes can
|
|
17
|
+
be integration-tested together on Snowflake before anything reaches production. `test` is never
|
|
18
|
+
merged back into `main` — `main` only ever gets deployed to prod directly, from its own commits.
|
|
19
|
+
`test` is a disposable, force-pushed scratch branch whose entire history is rebuilt from `main` on
|
|
20
|
+
every squash merge.
|
|
21
|
+
|
|
22
|
+
## Entry point: `GitOperationsMenu._squash_merge_test()`
|
|
23
|
+
|
|
24
|
+
(`menus/git_operations.py:246-281`)
|
|
25
|
+
|
|
26
|
+
This is menu option `[7] squash to test`. It runs three checks *before* calling
|
|
27
|
+
`GitService.squash_merge_into_test()`, and the checks are where most of the actual safety logic
|
|
28
|
+
lives — `squash_merge_into_test()` itself does no validation at all.
|
|
29
|
+
|
|
30
|
+
### Check 1 — your branch must be up to date with `main`
|
|
31
|
+
|
|
32
|
+
`GitService.is_branch_up_to_date_with_main()` (`git_service.py:223-232`):
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
self.repo.remotes.origin.fetch()
|
|
36
|
+
merge_base = self.repo.git.merge_base("HEAD", f"origin/{self.trunk_branch}")
|
|
37
|
+
main_sha = self.repo.commit(f"origin/{self.trunk_branch}").hexsha
|
|
38
|
+
return merge_base.strip() == main_sha
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This checks that `origin/main`'s tip is an ancestor of `HEAD` — i.e. your branch already contains
|
|
42
|
+
every commit on `main`. If not, the menu rejects the merge outright ("Rebase with main first")
|
|
43
|
+
and nothing further happens. This is the only thing standing between your branch and a squash
|
|
44
|
+
merge; if you're behind main but a rebase isn't forced, nothing re-checks this later.
|
|
45
|
+
|
|
46
|
+
### Check 2 — file-overlap detection against what's currently on `test`
|
|
47
|
+
|
|
48
|
+
`GitService.get_test_file_conflicts()` (`git_service.py:320-363`):
|
|
49
|
+
|
|
50
|
+
1. Fetches, then diffs your branch against `origin/main` (`git diff --name-only origin/main...HEAD`)
|
|
51
|
+
to get the set of files *you've* touched.
|
|
52
|
+
2. Walks the last 100 commits on `origin/test`, looking only at commits whose message starts with
|
|
53
|
+
`"squash merge:"` — i.e. commits this same tool produced.
|
|
54
|
+
3. For each such commit, parses out which branch it came from by string-manipulating the commit
|
|
55
|
+
message (see **Known issue** below), and diffs that single commit's tree
|
|
56
|
+
(`git diff-tree --no-commit-id --name-only -r <sha>`) to get the files *it* touched.
|
|
57
|
+
4. If your files and that commit's files intersect, it's a "conflict" — recorded with the other
|
|
58
|
+
branch's name, its commit SHA, the overlapping files, and whether that branch still exists on
|
|
59
|
+
the remote (checked against `origin`'s current branch list).
|
|
60
|
+
|
|
61
|
+
Back in the menu, conflicts split into two buckets:
|
|
62
|
+
|
|
63
|
+
- **Active conflict** (the other branch still exists remotely): the merge is **rejected**. You're
|
|
64
|
+
told to resolve it with the branch owner or remove their branch from `test` first. Nothing is
|
|
65
|
+
mutated.
|
|
66
|
+
- **Stale conflict** (the other branch no longer exists remotely — e.g. it was merged to main and
|
|
67
|
+
deleted): the menu automatically calls `revert_from_test()` to drop that old commit from `test`
|
|
68
|
+
before proceeding, with a warning printed. This happens silently as part of "squash to test" —
|
|
69
|
+
there's no separate confirmation for this specific removal.
|
|
70
|
+
|
|
71
|
+
### Check 3 — final user confirmation, then the actual merge
|
|
72
|
+
|
|
73
|
+
Only after both checks pass does the menu ask "Continue?" and, if yes, call
|
|
74
|
+
`squash_merge_into_test()`.
|
|
75
|
+
|
|
76
|
+
## The merge itself: `GitService.squash_merge_into_test()`
|
|
77
|
+
|
|
78
|
+
(`git_service.py:234-272`)
|
|
79
|
+
|
|
80
|
+
Step by step:
|
|
81
|
+
|
|
82
|
+
1. **Stash** any uncommitted changes in the working tree (`git stash push -u`), remembering
|
|
83
|
+
whether anything was stashed.
|
|
84
|
+
2. **Fetch** from origin.
|
|
85
|
+
3. **Checkout `test`** via `_checkout_test()` (`git_service.py:213-221`), which:
|
|
86
|
+
- tries `git checkout test` (works if you already have a local `test` branch),
|
|
87
|
+
- else creates it from `origin/test` (`git checkout -b test origin/test`),
|
|
88
|
+
- else — if `origin/test` doesn't exist yet at all — creates it from `origin/main` instead.
|
|
89
|
+
4. **Pull** `test` (best-effort — failure here is silently swallowed; a brand-new local branch
|
|
90
|
+
with no upstream will fail this pull and that's expected/fine).
|
|
91
|
+
5. **Rebase `test` onto `origin/main`** (`git rebase origin/main`). This is the step that keeps
|
|
92
|
+
`test`'s base in sync with `main` — `test` always ends up looking like "main + all currently
|
|
93
|
+
active squash commits", never drifting from main's latest state.
|
|
94
|
+
6. **Squash-merge your branch into `test`** (`git merge --squash <current-branch>`) — stages your
|
|
95
|
+
branch's full diff without creating a merge commit.
|
|
96
|
+
7. **Commit** with message `"squash merge: {your-branch} into {test}"`. This exact string format
|
|
97
|
+
is load-bearing: it's how `get_test_commits()` and `get_test_file_conflicts()` later identify
|
|
98
|
+
which commits on `test` came from which feature branch.
|
|
99
|
+
8. **Force-push `test`** (`git push test --set-upstream --force`). Force is required because step
|
|
100
|
+
5 just rewrote `test`'s history via rebase.
|
|
101
|
+
9. **Checkout back to your original branch** and **pop the stash** if one was made.
|
|
102
|
+
|
|
103
|
+
### On any `GitCommandError` during the above
|
|
104
|
+
|
|
105
|
+
- Abort any in-progress rebase (`git rebase --abort`, failure ignored).
|
|
106
|
+
- Best-effort checkout back to your original branch.
|
|
107
|
+
- Best-effort stash pop.
|
|
108
|
+
- Return `False`; the menu's `success_line`/`error_line` reporting is based on this.
|
|
109
|
+
|
|
110
|
+
Note the ordering risk here: steps 3–8 all happen on `test` while your original branch sits
|
|
111
|
+
unchecked-out. If the process is killed between step 6 (squash) and step 9 (checkout back), you
|
|
112
|
+
are left on `test` with an uncommitted squash merge staged and your stash (if any) still stashed —
|
|
113
|
+
there's no re-entrant recovery for that specific failure window; it relies on the `except` block
|
|
114
|
+
running, which only triggers on `GitCommandError`, not on e.g. a `KeyboardInterrupt`.
|
|
115
|
+
|
|
116
|
+
## "Remove from Test": `GitOperationsMenu._cherry_pick_test()` → `revert_from_test()`
|
|
117
|
+
|
|
118
|
+
(`menus/git_operations.py:283-299`, `git_service.py:274-318`)
|
|
119
|
+
|
|
120
|
+
1. `get_test_commits()` (`git_service.py:365-384`) walks the last 100 commits on `origin/test`,
|
|
121
|
+
filters to ones starting with `"squash merge:"`, and parses out the branch name from each
|
|
122
|
+
message the same way `get_test_file_conflicts()` does.
|
|
123
|
+
2. The menu lists them (newest-first per git log order) and lets you pick one by number.
|
|
124
|
+
3. `revert_from_test(sha, branch_name)`:
|
|
125
|
+
- stash / fetch / checkout `test` (same pattern as the merge flow),
|
|
126
|
+
- pull `test` (best-effort),
|
|
127
|
+
- **refuses** if the target commit has more than one parent (i.e. it's not a plain squash
|
|
128
|
+
commit — defends against someone having manually merged something onto `test`),
|
|
129
|
+
- `git rebase --onto <sha>^ <sha> test` — this surgically **drops** that one commit from
|
|
130
|
+
history (not a revert-commit; the commit is gone, as if it never happened), replaying
|
|
131
|
+
everything after it on top of its parent,
|
|
132
|
+
- force-pushes `test`,
|
|
133
|
+
- checks out back to your original branch, pops stash if needed.
|
|
134
|
+
|
|
135
|
+
This is why `test`'s history is disposable: branches are added and removed from it by literally
|
|
136
|
+
rewriting history and force-pushing, never by merge/revert commits.
|
|
137
|
+
|
|
138
|
+
## Known issue found during this review
|
|
139
|
+
|
|
140
|
+
**Bug: commit-message parsing breaks if `integration_branch` is renamed after commits already
|
|
141
|
+
exist on the old name.**
|
|
142
|
+
|
|
143
|
+
Both `get_test_file_conflicts()` (`git_service.py:346`) and `get_test_commits()`
|
|
144
|
+
(`git_service.py:372`) parse the branch name out of a squash-merge commit message like this:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
other_branch = msg.replace("squash merge: ", "", 1).replace(f" into {self.integration_branch}", "")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
This only strips the `" into {integration_branch}"` suffix if it matches the **currently
|
|
151
|
+
configured** `integration_branch`. A commit made *before* a project renamed its integration branch
|
|
152
|
+
(say from `test` to `staging`) has the literal text `"squash merge: feature/orders into test"`
|
|
153
|
+
baked into its message forever (commit messages don't change when you rename branches). After the
|
|
154
|
+
rename, `self.integration_branch` is `"staging"`, so `.replace(" into staging", "")` doesn't match
|
|
155
|
+
`" into test"`, and `other_branch` comes out as `"feature/orders into test"` instead of
|
|
156
|
+
`"feature/orders"`.
|
|
157
|
+
|
|
158
|
+
Concretely, this breaks:
|
|
159
|
+
- The "remove from test" menu — it lists a mangled, unselectable-looking branch name.
|
|
160
|
+
- File-conflict detection — `other_branch == current` can never be true for that old commit (since
|
|
161
|
+
`current` is a real branch name without the `" into test"` suffix), so a conflict against your
|
|
162
|
+
*own* branch's old commit won't be recognized as "skip, that's me." More importantly,
|
|
163
|
+
`other_branch in remote_branches` will be `False` for the mangled name even if the real branch
|
|
164
|
+
still exists, so the commit is misclassified as **stale** and gets auto-removed
|
|
165
|
+
(`revert_from_test`) and force-pushed over on your next squash merge — silently dropping another
|
|
166
|
+
branch's integration-test changes without the "active conflict, rejected" warning that would
|
|
167
|
+
normally protect it.
|
|
168
|
+
|
|
169
|
+
This only manifests after an `integration_branch` rename with pre-existing history on the old
|
|
170
|
+
branch name; it does not affect projects that have never changed `integration_branch` from its
|
|
171
|
+
configured value. Fix direction: parse using the last `" into "` separator in the message
|
|
172
|
+
(independent of the currently configured name), e.g. `msg[len("squash merge: "):].rsplit(" into ", 1)[0]`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.0b12"
|
|
@@ -254,40 +254,72 @@ def pipeline():
|
|
|
254
254
|
help="Branch being built: picks the dbt target mapped to it (a GitHub pull request's "
|
|
255
255
|
"<n>/merge ref resolves to its source branch)")
|
|
256
256
|
@click.option("--target", "-t", default=None, help="dbt target name (instead of --branch)")
|
|
257
|
+
@click.option("--mode", "-m", type=click.Choice(pipeline_env.MODES), default="release", show_default=True,
|
|
258
|
+
help="The database the run writes to: release <prefix><TARGET>, ci <prefix>UT_<run id>, "
|
|
259
|
+
"clone <prefix><clone database>, default the production database")
|
|
260
|
+
@click.option("--run-id", default=None, help="ci mode: the run's id (the unit-test database suffix)")
|
|
261
|
+
@click.option("--clone-database", default=None, help="clone mode: the database to clone into (without the prefix)")
|
|
262
|
+
@click.option("--profile", default=None, help="dbt profile (default: the project's, from .datasecops.yml)")
|
|
257
263
|
@click.option("--connection", "-c", default=None, help="Snowflake connection name (overrides .datasecops.yml)")
|
|
258
264
|
@click.option("--format", "fmt", type=click.Choice(["auto", *pipeline_env.PLATFORMS]), default="auto",
|
|
259
265
|
show_default=True, help="auto: GitHub when $GITHUB_ENV is set, Azure DevOps when $TF_BUILD is set")
|
|
260
|
-
def pipeline_env_cmd(branch: Optional[str], target: Optional[str],
|
|
261
|
-
|
|
266
|
+
def pipeline_env_cmd(branch: Optional[str], target: Optional[str], mode: str, run_id: Optional[str],
|
|
267
|
+
clone_database: Optional[str], profile: Optional[str], connection: Optional[str], fmt: str):
|
|
268
|
+
"""Set a pipeline run's variables from the app's settings.
|
|
269
|
+
|
|
270
|
+
The dbt target (TARGET, SF_ROLE, SF_WAREHOUSE, TARGET_SCHEMA) and, from apps with api.pipeline_context, the
|
|
271
|
+
profile's databases (DATABASE_PREFIX, SOURCE_DATABASE, TARGET_DATABASE for --mode), DBT_PROJECT_NAME,
|
|
272
|
+
DBT_EXCLUDE_FLAG, the docs repository, git tag identity, manifest storage and DBT_VERSION. Settings changed
|
|
273
|
+
in the app apply on the next run.
|
|
262
274
|
|
|
263
275
|
GitHub Actions: appended to $GITHUB_ENV. Azure DevOps: set with ##vso logging commands.
|
|
264
276
|
Otherwise printed as KEY=value. Empty role / warehouse / schema values are left unset.
|
|
265
277
|
"""
|
|
266
278
|
if bool(branch) == bool(target):
|
|
267
279
|
raise click.UsageError("give exactly one of --branch or --target")
|
|
280
|
+
if mode == "ci" and not run_id:
|
|
281
|
+
raise click.UsageError("--mode ci needs --run-id")
|
|
282
|
+
if mode == "clone" and not clone_database:
|
|
283
|
+
raise click.UsageError("--mode clone needs --clone-database")
|
|
268
284
|
config = Config()
|
|
269
285
|
if not config.load(connection_name=connection):
|
|
270
286
|
sys.exit(1)
|
|
271
287
|
sf_service = SnowflakeService(config.datasecops)
|
|
272
288
|
try:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
289
|
+
try:
|
|
290
|
+
raw = sf_service.get_framework_config("PROJECT") or {}
|
|
291
|
+
except Exception as e: # noqa: BLE001 - connector errors
|
|
292
|
+
error_line(f"Failed to read the dbt targets from {config.datasecops.app_database}: {e}")
|
|
293
|
+
sys.exit(1)
|
|
294
|
+
targets = [DbtTarget(**{k: v for k, v in t.items() if k in DbtTarget.model_fields})
|
|
295
|
+
for t in raw.get("targets") or []]
|
|
296
|
+
try:
|
|
297
|
+
resolved = pipeline_env.resolve_target(targets, branch=branch, target=target)
|
|
298
|
+
except pipeline_env.TargetNotFound as e:
|
|
299
|
+
error_line(str(e))
|
|
300
|
+
sys.exit(1)
|
|
301
|
+
values = pipeline_env.env_values(resolved)
|
|
302
|
+
params = {"profile": profile or config.profile_name, "target": resolved.target_name, "mode": mode,
|
|
303
|
+
"run_id": run_id or "", "clone_database": clone_database or ""}
|
|
304
|
+
try:
|
|
305
|
+
context, note = pipeline_env.app_context(sf_service, params)
|
|
306
|
+
except pipeline_env.PipelineContextError as e:
|
|
307
|
+
error_line(str(e))
|
|
308
|
+
sys.exit(1)
|
|
309
|
+
if note:
|
|
310
|
+
click.echo(f"Note: {config.datasecops.app_database}: {note}", err=True)
|
|
311
|
+
values = {**values, **context}
|
|
277
312
|
finally:
|
|
278
313
|
sf_service.close()
|
|
279
|
-
|
|
280
|
-
for t in raw.get("targets") or []]
|
|
314
|
+
platform = pipeline_env.detect_platform() if fmt == "auto" else fmt
|
|
281
315
|
try:
|
|
282
|
-
|
|
283
|
-
except
|
|
284
|
-
error_line(
|
|
316
|
+
lines = pipeline_env.export(values, platform)
|
|
317
|
+
except ValueError as e:
|
|
318
|
+
error_line(f"Pipeline context: {e}")
|
|
285
319
|
sys.exit(1)
|
|
286
|
-
|
|
287
|
-
platform = pipeline_env.detect_platform() if fmt == "auto" else fmt
|
|
288
|
-
for line in pipeline_env.export(values, platform):
|
|
320
|
+
for line in lines:
|
|
289
321
|
click.echo(line)
|
|
290
|
-
click.echo("
|
|
322
|
+
click.echo("pipeline environment: " + ", ".join(f"{k}={v}" for k, v in values.items()), err=True)
|
|
291
323
|
|
|
292
324
|
|
|
293
325
|
# ── model commands ─────────────────────────────────────────────────────────
|
|
@@ -933,7 +965,11 @@ def _run_interactive(config: Config):
|
|
|
933
965
|
)
|
|
934
966
|
|
|
935
967
|
try:
|
|
936
|
-
git_service = GitService(
|
|
968
|
+
git_service = GitService(
|
|
969
|
+
config.project_dir,
|
|
970
|
+
trunk_branch=config.source_control.trunk_branch,
|
|
971
|
+
integration_branch=config.source_control.integration_branch,
|
|
972
|
+
)
|
|
937
973
|
except Exception:
|
|
938
974
|
git_service = None
|
|
939
975
|
|
{datasecops_cli-0.7.0b10 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/configuration.py
RENAMED
|
@@ -10,11 +10,10 @@ from datasecops_cli.services.download_service import DownloadService
|
|
|
10
10
|
from datasecops_cli.services.linting_service import LintingService
|
|
11
11
|
from datasecops_cli.utilities.display import (
|
|
12
12
|
clear, section_header, display_action_header, menu_option,
|
|
13
|
-
get_input_number,
|
|
14
|
-
info_line, success_line,
|
|
13
|
+
get_input_number, complete_action,
|
|
14
|
+
info_line, success_line, error_line,
|
|
15
15
|
get_input_string, select_from_list, select_multiple_from_list
|
|
16
16
|
)
|
|
17
|
-
from datasecops_cli.utilities.yaml_utils import write_datasecops_config
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
class ConfigurationMenu:
|
|
@@ -49,16 +48,11 @@ class ConfigurationMenu:
|
|
|
49
48
|
complete_action()
|
|
50
49
|
elif option == 5:
|
|
51
50
|
self._cortex_upgrade()
|
|
52
|
-
elif option == 6:
|
|
53
|
-
self._toggle_dbt_engine()
|
|
54
|
-
elif option == 7:
|
|
55
|
-
self._upgrade_dbt2()
|
|
56
51
|
self._menu()
|
|
57
52
|
option = get_input_number("Choose an option: ")
|
|
58
53
|
|
|
59
54
|
def _menu(self) -> None:
|
|
60
55
|
clear()
|
|
61
|
-
engine_label = self.datasecops_config.get_engine_label()
|
|
62
56
|
is_dbt2 = self.datasecops_config.dbt_engine == "dbt2"
|
|
63
57
|
section_header("Configuration", self.profile_name)
|
|
64
58
|
if is_dbt2:
|
|
@@ -69,9 +63,6 @@ class ConfigurationMenu:
|
|
|
69
63
|
menu_option(3, "mcp servers - Configure MCP servers for AI tools")
|
|
70
64
|
menu_option(4, "new project - Initialize a new dbt project with framework profiles")
|
|
71
65
|
menu_option(5, "cortex update - Update CoCo to the latest version")
|
|
72
|
-
menu_option(6, f"dbt engine - Switch dbt engine (current: {engine_label})")
|
|
73
|
-
if is_dbt2:
|
|
74
|
-
menu_option(7, "upgrade dbt - Upgrade dbt 2.0 to the latest version (pip)")
|
|
75
66
|
menu_option(0, "back - Return to main menu")
|
|
76
67
|
|
|
77
68
|
def _install_dbt_requirements(self) -> None:
|
|
@@ -238,47 +229,3 @@ class ConfigurationMenu:
|
|
|
238
229
|
except FileNotFoundError:
|
|
239
230
|
error_line("CoCo CLI not found.")
|
|
240
231
|
complete_action()
|
|
241
|
-
|
|
242
|
-
def _toggle_dbt_engine(self) -> None:
|
|
243
|
-
"""Toggle between dbt 2.0 and dbt Core (1.x)."""
|
|
244
|
-
display_action_header("Switch dbt Engine")
|
|
245
|
-
current = self.datasecops_config.dbt_engine or "dbt_core"
|
|
246
|
-
info_line(f"Current engine: {self.datasecops_config.get_engine_label()} ({current})")
|
|
247
|
-
info_line("")
|
|
248
|
-
menu_option(1, "dbt 2.0 - dbt2 (recommended)")
|
|
249
|
-
menu_option(2, "dbt Core 1.x - dbt_core")
|
|
250
|
-
menu_option(0, "cancel")
|
|
251
|
-
option = get_input_number("Choose an option: ")
|
|
252
|
-
|
|
253
|
-
if option == 1:
|
|
254
|
-
new_engine = "dbt2"
|
|
255
|
-
elif option == 2:
|
|
256
|
-
new_engine = "dbt_core"
|
|
257
|
-
else:
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
if new_engine == current:
|
|
261
|
-
info_line("No change.")
|
|
262
|
-
complete_action()
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
self.datasecops_config.dbt_engine = new_engine
|
|
266
|
-
config_data = self.datasecops_config.model_dump(exclude={"VALID_ENGINES"})
|
|
267
|
-
write_datasecops_config(self.project_dir, config_data)
|
|
268
|
-
success_line(f"dbt engine switched to {self.datasecops_config.get_engine_label()} ({new_engine})")
|
|
269
|
-
warning_line("Restart the CLI for the change to take effect.")
|
|
270
|
-
complete_action()
|
|
271
|
-
|
|
272
|
-
def _upgrade_dbt2(self) -> None:
|
|
273
|
-
"""Upgrade dbt 2.0 to the latest version via pip."""
|
|
274
|
-
display_action_header("Upgrade dbt 2.0")
|
|
275
|
-
if not shutil.which("dbt"):
|
|
276
|
-
error_line("dbt not found. Install it first.")
|
|
277
|
-
complete_action()
|
|
278
|
-
return
|
|
279
|
-
try:
|
|
280
|
-
info_line("Upgrading dbt via uv pip...")
|
|
281
|
-
subprocess.run(["uv", "pip", "install", "--upgrade", "dbt"])
|
|
282
|
-
except FileNotFoundError:
|
|
283
|
-
error_line("uv not found.")
|
|
284
|
-
complete_action()
|
|
@@ -296,33 +296,32 @@ class DevelopmentMenu:
|
|
|
296
296
|
def _lint_menu(self) -> None:
|
|
297
297
|
clear()
|
|
298
298
|
is_dbt2 = self.linting.dbt_engine == "dbt2"
|
|
299
|
-
|
|
300
|
-
display_action_header(f"{lint_label} Linting Options")
|
|
301
|
-
menu_option(1, "find modified - Lint modified SQL files")
|
|
302
|
-
menu_option(2, "fix modified - Fix modified SQL files")
|
|
303
|
-
menu_option(3, "find all - Lint all SQL files")
|
|
304
|
-
menu_option(4, "fix all - Fix all SQL files")
|
|
305
|
-
menu_option(5, "specific - Lint specific file")
|
|
306
|
-
menu_option(6, "refresh config- Re-download .sqlfluff from framework")
|
|
299
|
+
display_action_header("Linting Options")
|
|
307
300
|
if is_dbt2:
|
|
308
|
-
menu_option(
|
|
309
|
-
|
|
301
|
+
menu_option(1, "changed - Lint only git-changed files (dbt lint --changed)")
|
|
302
|
+
else:
|
|
303
|
+
menu_option(1, "modified - Lint modified SQL files")
|
|
304
|
+
menu_option(2, "all - Lint all SQL files")
|
|
305
|
+
menu_option(3, "specific - Lint specific file")
|
|
306
|
+
menu_option(4, "refresh config- Re-download .sqlfluff from framework")
|
|
307
|
+
if is_dbt2:
|
|
308
|
+
menu_option(5, "format - Auto-format SQL files (dbt format/fmt)")
|
|
310
309
|
menu_option(0, "back - Return to development menu")
|
|
311
310
|
option = get_input_number("Choose an option: ")
|
|
312
|
-
if option in (1, 2, 3,
|
|
311
|
+
if option in (1, 2, 3, 5) and not self._ensure_sqlfluff_config():
|
|
313
312
|
complete_action()
|
|
314
313
|
return
|
|
315
314
|
if option == 1:
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
fix = get_input_true_false("Also auto-fix the issues found?", "n")
|
|
316
|
+
if is_dbt2:
|
|
317
|
+
self.linting.lint_changed(fix=fix)
|
|
318
|
+
else:
|
|
319
|
+
changed = self.git.get_all_modified_files() if self.git else []
|
|
320
|
+
self.linting.lint_modified(fix=fix, changed_files=changed)
|
|
318
321
|
elif option == 2:
|
|
319
|
-
|
|
320
|
-
self.linting.
|
|
322
|
+
fix = get_input_true_false("Also auto-fix the issues found?", "n")
|
|
323
|
+
self.linting.lint_file(fix=fix)
|
|
321
324
|
elif option == 3:
|
|
322
|
-
self.linting.lint_file(fix=False)
|
|
323
|
-
elif option == 4:
|
|
324
|
-
self.linting.lint_file(fix=True)
|
|
325
|
-
elif option == 5:
|
|
326
325
|
name = get_input_string("Enter model name or file path (e.g. stg_orders): ")
|
|
327
326
|
if name != "0":
|
|
328
327
|
path = name if name.endswith(".sql") else self.linting.resolve_model_path(name)
|
|
@@ -343,15 +342,12 @@ class DevelopmentMenu:
|
|
|
343
342
|
jinja_render_mode=jinja_render_mode)
|
|
344
343
|
else:
|
|
345
344
|
error_line(f"Could not find model '{name}' in models/ directory")
|
|
346
|
-
elif option ==
|
|
345
|
+
elif option == 4:
|
|
347
346
|
if not self.downloads:
|
|
348
347
|
error_line("Download service not available")
|
|
349
348
|
else:
|
|
350
349
|
self.downloads.download_sqlfluff_config(profiles_dir=self.profiles_dir, dbt_project_dir=self.linting.project_dir)
|
|
351
|
-
elif option ==
|
|
352
|
-
fix = get_input_true_false("Also auto-fix the issues found?", "n")
|
|
353
|
-
self.linting.lint_changed(fix=fix)
|
|
354
|
-
elif option == 8 and is_dbt2:
|
|
350
|
+
elif option == 5 and is_dbt2:
|
|
355
351
|
name = get_input_string(
|
|
356
352
|
"Enter model name or file path to format, or leave blank for the whole project "
|
|
357
353
|
"('0' to cancel): ",
|