datasecops-cli 0.7.0b16__tar.gz → 0.7.0b17__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.0b16 → datasecops_cli-0.7.0b17}/CHANGELOG.md +9 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/PKG-INFO +1 -1
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/pyproject.toml +1 -1
- datasecops_cli-0.7.0b17/src/datasecops_cli/__init__.py +1 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dbt_project_generator.py +99 -3
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/directory_scaffolder.py +1 -1
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/download_service.py +21 -4
- datasecops_cli-0.7.0b17/tests/test_dbt_project_generator_yml.py +128 -0
- datasecops_cli-0.7.0b17/tests/test_directory_scaffolder.py +19 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_download_service.py +68 -0
- datasecops_cli-0.7.0b16/src/datasecops_cli/__init__.py +0 -1
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/.github/workflows/auto-tag.yml +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/.github/workflows/publish-cli.yml +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/.github/workflows/test.yml +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/.gitignore +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/AGENTS.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/DEVELOPMENT.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/LICENSE +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/README.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/dcm.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/getting-started.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/git-operations.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/legacy.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/legacy_plan_of_action.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/mcp-server.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/docs/squash-merge-into-test-review.md +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/mcp-servers.json +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/scripts/vendor_model.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/setup.ps1 +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/setup.sh +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/config.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/main.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/configuration.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/dcm_operations.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/development.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/downloads.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/git_operations.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/models/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/models/git_helpers.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/models/project_config.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/bootstrap_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dbt_runner.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_orchestrator.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_pipelines.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_registry.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/git_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/linting_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/model_commands.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/pipeline_env.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/skill_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/snowflake_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/upstream_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/display.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/file_utils.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/mcp.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/yaml_utils.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_mcp/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_mcp/__main__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_mcp/connection.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_mcp/server.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/convert.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/diagram.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/expand.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/extract.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/render.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/schema.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/scope.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/scripts.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/starter.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/templates/macros/role.sql +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/templates/macros/role_guard.sql +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/templates/macros/warehouse.sql +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/validate.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/__init__.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_config.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_dbt_project_generator_profiles.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_dbt_runner.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_dcm_model.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_dcm_orchestrator.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_dcm_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_file_utils.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_git_operations_menu.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_git_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_linting_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_main.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_mcp_branching_rules.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_mcp_lint_tools.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_model_commands.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_models.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_pipeline_env.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_upstream_service.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_version.py +0 -0
- {datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_yaml_utils.py +0 -0
|
@@ -4,6 +4,15 @@ All notable changes to the DataSecOps CLI are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.7.0b17] - 2026-11-05
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Generated `dbt_project.yml` had `analysis-paths`/`test-paths` that didn't match the scaffolded folders** — `analysis-paths` pointed at `"analysis"` (singular) while `scaffold_directories()` creates `analyses`, and `test-paths` pointed at `"tests"`. Both now point at the folders that actually get created: `analyses` and `data-tests` (the directory scaffolder now creates `data-tests` instead of `tests` to match). **Migration for existing projects:** only re-running `bootstrap` regenerates `dbt_project.yml` (`download packages` only touches `packages.yml`) — rename any existing `analysis/`/`tests/` folders to `analyses/`/`data-tests/` before re-running it. The old folders are left in place (never deleted) but dbt will stop discovering files under them once `dbt_project.yml` is regenerated.
|
|
12
|
+
- **Generated `dbt_project.yml` was missing framework `vars` and a `flags` section** — added `sds_env`, the `dbt_dataengineers_materializations` defaults (`default_monitorial_error_integration`, `default_monitorial_serverless`, `default_monitorial_object_type`), the standard "Unknown Values" vars (surrogate keys, string/date/numeric placeholders, current/deleted/boolean flags), and a top-level `flags:` block (`require_generic_test_arguments_property`, `warn_error_options.silence`).
|
|
13
|
+
- **No `.gitignore` was written at the repository root** — `bootstrap` only wrote a `.gitignore` inside the dbt project folder (build artifacts), so `.sqlfluff`/`.sqlfluffignore` and `.venv/` had nothing preventing them from being committed. A root-level `.gitignore` is now written alongside it during project scaffolding (merged into one file if the dbt project is scaffolded directly at the repo root), without ever overwriting a developer's own existing `.gitignore` rules — both files are merged in as a clearly marked, idempotent block. `.datasecops.yml` is deliberately not ignored: the README documents it as committed (it holds no secrets) so CI pipelines can read `connection_name`/`app_database`.
|
|
14
|
+
- **`__init__.py`'s `__version__` had drifted from `pyproject.toml`** (stuck at `0.7.0b14` since the `0.7.0b15` release) — synced to `0.7.0b17`.
|
|
15
|
+
|
|
7
16
|
## [0.7.0b16] - 2026-11-05
|
|
8
17
|
|
|
9
18
|
### Fixed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.0b17"
|
|
@@ -122,8 +122,8 @@ config-version: 2
|
|
|
122
122
|
profile: __PROFILE_NAME__
|
|
123
123
|
|
|
124
124
|
model-paths: ["models", "objects"]
|
|
125
|
-
analysis-paths: ["
|
|
126
|
-
test-paths: ["tests"]
|
|
125
|
+
analysis-paths: ["analyses"]
|
|
126
|
+
test-paths: ["data-tests"]
|
|
127
127
|
seed-paths: ["seeds"]
|
|
128
128
|
macro-paths: ["macros"]
|
|
129
129
|
snapshot-paths: ["snapshots"]
|
|
@@ -189,6 +189,45 @@ vars:
|
|
|
189
189
|
#The schema name where tags are located
|
|
190
190
|
policies_store: "__GOVERNANCE_POLICIES_STORE__"
|
|
191
191
|
tag_store: "__GOVERNANCE_TAG_STORE__"
|
|
192
|
+
|
|
193
|
+
######################################
|
|
194
|
+
###### Framework variables ######
|
|
195
|
+
######################################
|
|
196
|
+
# source database enviornment
|
|
197
|
+
sds_env: PRD
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
####################################################
|
|
201
|
+
### dbt_dataengineers_materializations variables ###
|
|
202
|
+
####################################################
|
|
203
|
+
default_monitorial_error_integration: "MONITORIAL_PULSE_QUEUE"
|
|
204
|
+
default_monitorial_serverless: false
|
|
205
|
+
default_monitorial_object_type: "task"
|
|
206
|
+
|
|
207
|
+
#######################################
|
|
208
|
+
###### Unknown Values ######
|
|
209
|
+
#######################################
|
|
210
|
+
unknown_member_surrogate_key: md5(concat('unknown', -1))
|
|
211
|
+
unknown_string_value: "'Unknown'"
|
|
212
|
+
unknown_string_value_yml: Unknown
|
|
213
|
+
unknown_numeric_value: '-1'
|
|
214
|
+
unknown_date_value: to_date('1900-01-01', 'yyyy-mm-dd')
|
|
215
|
+
unknown_effective_from_date: to_timestamp_ntz('1900-01-01 00:00:00.0000')
|
|
216
|
+
unknown_effective_to_date: to_timestamp_ntz('2999-12-31 23:59:59.9999')
|
|
217
|
+
unknown_from_date_key: '19000101'
|
|
218
|
+
unknown_to_date_key: '29991231'
|
|
219
|
+
unknown_is_current: 'TRUE'
|
|
220
|
+
unknown_is_deleted: 'FALSE'
|
|
221
|
+
unknown_boolean_value: 'FALSE'
|
|
222
|
+
|
|
223
|
+
flags:
|
|
224
|
+
require_generic_test_arguments_property: true
|
|
225
|
+
warn_error_options:
|
|
226
|
+
silence:
|
|
227
|
+
- UnsupportedConstraintMaterialization
|
|
228
|
+
# - JinjaWarn
|
|
229
|
+
# - LicenseError
|
|
230
|
+
# - ColumnTypeMismatch
|
|
192
231
|
"""
|
|
193
232
|
|
|
194
233
|
return (
|
|
@@ -534,7 +573,7 @@ def generate_packages_yml(
|
|
|
534
573
|
|
|
535
574
|
|
|
536
575
|
def generate_gitignore() -> str:
|
|
537
|
-
"""Generate a .gitignore for dbt
|
|
576
|
+
"""Generate a .gitignore for the dbt project directory itself (build/run artifacts)."""
|
|
538
577
|
return """target/
|
|
539
578
|
dbt_packages/
|
|
540
579
|
logs/
|
|
@@ -542,3 +581,60 @@ logs/
|
|
|
542
581
|
__pycache__/
|
|
543
582
|
profiles.yml
|
|
544
583
|
"""
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
def generate_root_gitignore() -> str:
|
|
587
|
+
"""Generate a .gitignore for the repository root: framework files that are
|
|
588
|
+
downloaded per-developer rather than committed, plus the usual local tooling
|
|
589
|
+
artifacts. `.datasecops.yml` is intentionally NOT included - the README documents
|
|
590
|
+
it as committed (it holds no secrets) so CI pipelines can read connection_name/
|
|
591
|
+
app_database from a checked-out repo."""
|
|
592
|
+
return """# DataSecOps local/personal config - never commit
|
|
593
|
+
.datasecops/
|
|
594
|
+
.sqlfluff
|
|
595
|
+
.sqlfluffignore
|
|
596
|
+
|
|
597
|
+
# Python
|
|
598
|
+
.venv/
|
|
599
|
+
__pycache__/
|
|
600
|
+
*.pyc
|
|
601
|
+
|
|
602
|
+
# OS
|
|
603
|
+
.DS_Store
|
|
604
|
+
"""
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
_GITIGNORE_MARKER = "# --- DataSecOps managed ignores ({label}): do not edit between these lines ---"
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
def merge_gitignore(existing: str, generated: str, label: str) -> str:
|
|
611
|
+
"""Merge `generated` ignore entries into `existing` .gitignore content as a
|
|
612
|
+
clearly marked, idempotently-replaceable block, leaving any other content
|
|
613
|
+
(e.g. a developer's own custom rules) untouched.
|
|
614
|
+
|
|
615
|
+
Args:
|
|
616
|
+
existing: Current .gitignore content, or "" if the file doesn't exist yet.
|
|
617
|
+
generated: The framework-managed ignore entries to merge in.
|
|
618
|
+
label: Distinguishes blocks when more than one is merged into the same file
|
|
619
|
+
(e.g. "dbt" and "root" when the dbt project is scaffolded at the repo root).
|
|
620
|
+
"""
|
|
621
|
+
begin = _GITIGNORE_MARKER.format(label=label)
|
|
622
|
+
end = _GITIGNORE_MARKER.format(label=f"end {label}")
|
|
623
|
+
block = f"{begin}\n{generated.rstrip()}\n{end}\n"
|
|
624
|
+
|
|
625
|
+
if not existing.strip():
|
|
626
|
+
return block
|
|
627
|
+
|
|
628
|
+
if begin in existing and end in existing:
|
|
629
|
+
pre, _, rest = existing.partition(begin)
|
|
630
|
+
_, _, post = rest.partition(end)
|
|
631
|
+
# block already supplies the separator newline right after `end` - drop the
|
|
632
|
+
# one newline immediately following the old end-marker so replacing the block
|
|
633
|
+
# in place doesn't grow an extra blank line on every rerun.
|
|
634
|
+
if post.startswith("\n"):
|
|
635
|
+
post = post[1:]
|
|
636
|
+
return f"{pre}{block}{post}"
|
|
637
|
+
|
|
638
|
+
sep = "" if existing.endswith("\n") else "\n"
|
|
639
|
+
return f"{existing}{sep}\n{block}"
|
|
640
|
+
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/download_service.py
RENAMED
|
@@ -10,7 +10,7 @@ from datasecops_cli.models.project_config import ProjectProfile, ProjectSettings
|
|
|
10
10
|
from datasecops_cli.services.snowflake_service import SnowflakeService
|
|
11
11
|
from datasecops_cli.services.upstream_service import get_latest_tag
|
|
12
12
|
from datasecops_cli.utilities.display import info_line, success_line, error_line, warning_line
|
|
13
|
-
from datasecops_cli.utilities.file_utils import write_file, ensure_dir
|
|
13
|
+
from datasecops_cli.utilities.file_utils import write_file, read_file, ensure_dir
|
|
14
14
|
|
|
15
15
|
# Env var dbt resolves (via `env_var()` in packages.yml) to authenticate Azure DevOps
|
|
16
16
|
# git package URLs. Projects set this once per environment to a PAT with read access
|
|
@@ -399,6 +399,8 @@ class DownloadService:
|
|
|
399
399
|
generate_dbt_project_yml,
|
|
400
400
|
write_profiles_yml,
|
|
401
401
|
generate_gitignore,
|
|
402
|
+
generate_root_gitignore,
|
|
403
|
+
merge_gitignore,
|
|
402
404
|
)
|
|
403
405
|
from datasecops_cli.services.directory_scaffolder import scaffold_directories
|
|
404
406
|
from datasecops_cli.services.snowflake_service import get_connection_params
|
|
@@ -430,9 +432,24 @@ class DownloadService:
|
|
|
430
432
|
return False
|
|
431
433
|
success_line(f"profiles.yml {status} in {profiles_dir}")
|
|
432
434
|
|
|
433
|
-
# Generate .gitignore
|
|
434
|
-
|
|
435
|
-
|
|
435
|
+
# Generate .gitignore (dbt project build artifacts, and the repository root's
|
|
436
|
+
# downloaded-per-developer files - .sqlfluff, .venv, etc.). Merged into any
|
|
437
|
+
# existing .gitignore as a clearly marked block, so a developer's own custom
|
|
438
|
+
# rules (e.g. .env, *.pem) are never overwritten.
|
|
439
|
+
if dbt_project_dir == self.project_dir:
|
|
440
|
+
# dbt project scaffolded directly at the repo root - merge both blocks into one file
|
|
441
|
+
existing = read_file(dbt_project_dir / ".gitignore")
|
|
442
|
+
merged = merge_gitignore(existing, generate_gitignore(), "dbt")
|
|
443
|
+
merged = merge_gitignore(merged, generate_root_gitignore(), "root")
|
|
444
|
+
write_file(dbt_project_dir / ".gitignore", merged)
|
|
445
|
+
success_line(f".gitignore written to {dbt_project_dir}")
|
|
446
|
+
else:
|
|
447
|
+
existing_dbt = read_file(dbt_project_dir / ".gitignore")
|
|
448
|
+
write_file(dbt_project_dir / ".gitignore", merge_gitignore(existing_dbt, generate_gitignore(), "dbt"))
|
|
449
|
+
success_line(f".gitignore written to {dbt_project_dir}")
|
|
450
|
+
existing_root = read_file(self.project_dir / ".gitignore")
|
|
451
|
+
write_file(self.project_dir / ".gitignore", merge_gitignore(existing_root, generate_root_gitignore(), "root"))
|
|
452
|
+
success_line(f".gitignore written to {self.project_dir}")
|
|
436
453
|
|
|
437
454
|
# Create directory structure
|
|
438
455
|
info_line("Creating directory structure...")
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Tests for dbt_project.yml generation (paths, vars, flags)."""
|
|
2
|
+
|
|
3
|
+
import yaml
|
|
4
|
+
|
|
5
|
+
from datasecops_cli.models.project_config import DbtTarget, ProjectProfile, ProjectSettings
|
|
6
|
+
from datasecops_cli.services.dbt_project_generator import (
|
|
7
|
+
generate_dbt_project_yml, generate_root_gitignore, merge_gitignore,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _profile() -> ProjectProfile:
|
|
12
|
+
return ProjectProfile(
|
|
13
|
+
profile_name="core",
|
|
14
|
+
project_name="my project",
|
|
15
|
+
model_types=["sources"],
|
|
16
|
+
dbt_version="2.0.9",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _project_settings() -> ProjectSettings:
|
|
21
|
+
return ProjectSettings(targets=[
|
|
22
|
+
DbtTarget(target_name="dev", target_warehouse="DEV_WH", is_default=True),
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_analysis_and_test_paths_match_scaffolded_directories():
|
|
27
|
+
"""analysis-paths/test-paths must point at the directories scaffold_directories()
|
|
28
|
+
actually creates ("analyses" and "data-tests"), not stale singular/legacy names."""
|
|
29
|
+
content = generate_dbt_project_yml(_profile(), _project_settings())
|
|
30
|
+
data = yaml.safe_load(content)
|
|
31
|
+
|
|
32
|
+
assert data["analysis-paths"] == ["analyses"]
|
|
33
|
+
assert data["test-paths"] == ["data-tests"]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_vars_include_framework_and_unknown_value_defaults():
|
|
37
|
+
content = generate_dbt_project_yml(_profile(), _project_settings())
|
|
38
|
+
data = yaml.safe_load(content)
|
|
39
|
+
|
|
40
|
+
assert data["vars"]["sds_env"] == "PRD"
|
|
41
|
+
assert data["vars"]["default_monitorial_error_integration"] == "MONITORIAL_PULSE_QUEUE"
|
|
42
|
+
assert data["vars"]["default_monitorial_serverless"] is False
|
|
43
|
+
assert data["vars"]["default_monitorial_object_type"] == "task"
|
|
44
|
+
assert data["vars"]["unknown_string_value_yml"] == "Unknown"
|
|
45
|
+
assert data["vars"]["unknown_numeric_value"] == "-1"
|
|
46
|
+
assert data["vars"]["unknown_is_current"] == "TRUE"
|
|
47
|
+
assert data["vars"]["unknown_is_deleted"] == "FALSE"
|
|
48
|
+
assert data["vars"]["unknown_boolean_value"] == "FALSE"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_flags_section():
|
|
52
|
+
content = generate_dbt_project_yml(_profile(), _project_settings())
|
|
53
|
+
data = yaml.safe_load(content)
|
|
54
|
+
|
|
55
|
+
assert data["flags"]["require_generic_test_arguments_property"] is True
|
|
56
|
+
assert data["flags"]["warn_error_options"]["silence"] == ["UnsupportedConstraintMaterialization"]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_root_gitignore_ignores_downloaded_and_local_files():
|
|
60
|
+
content = generate_root_gitignore()
|
|
61
|
+
|
|
62
|
+
assert ".datasecops/" in content
|
|
63
|
+
assert ".sqlfluff" in content
|
|
64
|
+
assert ".sqlfluffignore" in content
|
|
65
|
+
assert ".venv/" in content
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_root_gitignore_does_not_ignore_datasecops_yml():
|
|
69
|
+
""".datasecops.yml must stay committed - README documents it as the CI pipeline's
|
|
70
|
+
connection_name/app_database source, and it holds no secrets."""
|
|
71
|
+
content = generate_root_gitignore()
|
|
72
|
+
|
|
73
|
+
assert ".datasecops.yml" not in content
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class TestMergeGitignore:
|
|
77
|
+
def test_appends_to_empty_file(self):
|
|
78
|
+
result = merge_gitignore("", "target/\n", "dbt")
|
|
79
|
+
assert "target/" in result
|
|
80
|
+
|
|
81
|
+
def test_preserves_existing_custom_rules(self):
|
|
82
|
+
"""Merging must never drop a developer's own .gitignore entries."""
|
|
83
|
+
existing = ".env\n*.pem\n"
|
|
84
|
+
result = merge_gitignore(existing, "target/\n", "dbt")
|
|
85
|
+
|
|
86
|
+
assert ".env" in result
|
|
87
|
+
assert "*.pem" in result
|
|
88
|
+
assert "target/" in result
|
|
89
|
+
|
|
90
|
+
def test_idempotent_rerun_does_not_duplicate_block(self):
|
|
91
|
+
"""Running the merge twice with the same generated content must not grow
|
|
92
|
+
the file - the managed block is replaced in place, not appended again."""
|
|
93
|
+
existing = ".env\n"
|
|
94
|
+
once = merge_gitignore(existing, "target/\n", "dbt")
|
|
95
|
+
twice = merge_gitignore(once, "target/\n", "dbt")
|
|
96
|
+
|
|
97
|
+
assert twice == once
|
|
98
|
+
assert twice.count("target/") == 1
|
|
99
|
+
assert twice.count(".env") == 1
|
|
100
|
+
|
|
101
|
+
def test_updates_managed_block_when_generated_content_changes(self):
|
|
102
|
+
"""Re-running with different generated content replaces the old managed
|
|
103
|
+
block rather than appending a second one alongside it."""
|
|
104
|
+
existing = ".env\n"
|
|
105
|
+
once = merge_gitignore(existing, "target/\n", "dbt")
|
|
106
|
+
twice = merge_gitignore(once, "target/\nnew_entry/\n", "dbt")
|
|
107
|
+
|
|
108
|
+
assert "new_entry/" in twice
|
|
109
|
+
assert twice.count("target/") == 1
|
|
110
|
+
|
|
111
|
+
def test_idempotent_rerun_does_not_grow_file_with_content_after_block(self):
|
|
112
|
+
"""When other content follows the managed block, replacing it in place must
|
|
113
|
+
not insert an extra blank line on every rerun."""
|
|
114
|
+
existing = ".env\n"
|
|
115
|
+
once = merge_gitignore(existing, "target/\n", "dbt")
|
|
116
|
+
once_with_trailer = once + "custom_rule/\n"
|
|
117
|
+
|
|
118
|
+
twice = merge_gitignore(once_with_trailer, "target/\n", "dbt")
|
|
119
|
+
|
|
120
|
+
assert twice == once_with_trailer
|
|
121
|
+
|
|
122
|
+
def test_repeated_two_block_merge_is_byte_identical(self):
|
|
123
|
+
"""Merging two labelled blocks (dbt project scaffolded at the repo root) twice
|
|
124
|
+
in a row with the same generated content must produce identical output."""
|
|
125
|
+
merged_once = merge_gitignore(merge_gitignore("", "target/\n", "dbt"), ".sqlfluff\n", "root")
|
|
126
|
+
merged_twice = merge_gitignore(merge_gitignore(merged_once, "target/\n", "dbt"), ".sqlfluff\n", "root")
|
|
127
|
+
|
|
128
|
+
assert merged_twice == merged_once
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Tests for the dbt project directory scaffolding."""
|
|
2
|
+
|
|
3
|
+
from datasecops_cli.services.directory_scaffolder import scaffold_directories
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_creates_data_tests_not_tests(tmp_path):
|
|
7
|
+
"""The folder name must match dbt_project.yml's test-paths: ["data-tests"]."""
|
|
8
|
+
scaffold_directories(tmp_path, model_types=["sources"])
|
|
9
|
+
|
|
10
|
+
assert (tmp_path / "data-tests").is_dir()
|
|
11
|
+
assert not (tmp_path / "tests").exists()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_creates_analyses_plural(tmp_path):
|
|
15
|
+
"""The folder name must match dbt_project.yml's analysis-paths: ["analyses"]."""
|
|
16
|
+
scaffold_directories(tmp_path, model_types=["sources"])
|
|
17
|
+
|
|
18
|
+
assert (tmp_path / "analyses").is_dir()
|
|
19
|
+
assert not (tmp_path / "analysis").exists()
|
|
@@ -234,3 +234,71 @@ class TestDownloadDbtPackagesUpstreamDependency:
|
|
|
234
234
|
def test_project_dir_defaults_to_dbt(self):
|
|
235
235
|
from datasecops_cli.models.project_config import ProjectProfile
|
|
236
236
|
assert ProjectProfile().project_dir == "dbt"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class TestInitDbtProject:
|
|
240
|
+
"""Tests for the dbt project scaffold's .gitignore generation."""
|
|
241
|
+
|
|
242
|
+
def _run(self, tmp_path, project_dir="./dbt"):
|
|
243
|
+
from datasecops_cli.models.project_config import ProjectProfile, ProjectSettings
|
|
244
|
+
|
|
245
|
+
mock_sf = MagicMock()
|
|
246
|
+
mock_sf.config.connection_name = "conn"
|
|
247
|
+
mock_sf.config.sandpit_name = "jon"
|
|
248
|
+
|
|
249
|
+
profile = ProjectProfile(profile_name="core", project_name="my project")
|
|
250
|
+
settings = ProjectSettings(project_dir=project_dir, profile_dir=str(tmp_path / "dbt_profiles"))
|
|
251
|
+
|
|
252
|
+
service = DownloadService(mock_sf, tmp_path)
|
|
253
|
+
with patch("datasecops_cli.services.snowflake_service.get_connection_params", return_value={}):
|
|
254
|
+
result = service.init_dbt_project(settings, profile)
|
|
255
|
+
|
|
256
|
+
assert result is True
|
|
257
|
+
return tmp_path
|
|
258
|
+
|
|
259
|
+
def test_writes_dbt_level_and_root_level_gitignore(self, tmp_path):
|
|
260
|
+
"""A dbt project nested under dbt/ gets two .gitignore files: one scoped to dbt
|
|
261
|
+
build artifacts, one at the repo root for downloaded/local tooling files."""
|
|
262
|
+
project_dir = self._run(tmp_path, project_dir="./dbt")
|
|
263
|
+
|
|
264
|
+
dbt_gitignore = (project_dir / "dbt" / ".gitignore").read_text(encoding="utf-8")
|
|
265
|
+
root_gitignore = (project_dir / ".gitignore").read_text(encoding="utf-8")
|
|
266
|
+
|
|
267
|
+
assert "target/" in dbt_gitignore
|
|
268
|
+
assert ".sqlfluff" in root_gitignore
|
|
269
|
+
assert ".venv/" in root_gitignore
|
|
270
|
+
# .datasecops.yml stays committed - the README documents it as required for CI
|
|
271
|
+
assert ".datasecops.yml" not in root_gitignore
|
|
272
|
+
|
|
273
|
+
def test_merges_gitignore_when_dbt_project_is_repo_root(self, tmp_path):
|
|
274
|
+
"""When the dbt project lives directly at the repo root, both ignore lists
|
|
275
|
+
must end up in the single .gitignore file rather than one overwriting the other."""
|
|
276
|
+
project_dir = self._run(tmp_path, project_dir=".")
|
|
277
|
+
|
|
278
|
+
gitignore = (project_dir / ".gitignore").read_text(encoding="utf-8")
|
|
279
|
+
|
|
280
|
+
assert "target/" in gitignore
|
|
281
|
+
assert ".venv/" in gitignore
|
|
282
|
+
|
|
283
|
+
def test_preserves_existing_custom_gitignore_rules(self, tmp_path):
|
|
284
|
+
"""Re-running init on a project with a hand-edited root .gitignore must not
|
|
285
|
+
drop the developer's own rules (e.g. .env, *.pem)."""
|
|
286
|
+
(tmp_path / ".gitignore").write_text(".env\n*.pem\n", encoding="utf-8")
|
|
287
|
+
|
|
288
|
+
project_dir = self._run(tmp_path, project_dir="./dbt")
|
|
289
|
+
|
|
290
|
+
root_gitignore = (project_dir / ".gitignore").read_text(encoding="utf-8")
|
|
291
|
+
assert ".env" in root_gitignore
|
|
292
|
+
assert "*.pem" in root_gitignore
|
|
293
|
+
assert ".venv/" in root_gitignore
|
|
294
|
+
|
|
295
|
+
def test_rerunning_does_not_duplicate_managed_block(self, tmp_path):
|
|
296
|
+
"""Running init twice (e.g. re-running bootstrap) must not keep appending
|
|
297
|
+
another copy of the managed ignore block."""
|
|
298
|
+
self._run(tmp_path, project_dir="./dbt")
|
|
299
|
+
self._run(tmp_path, project_dir="./dbt")
|
|
300
|
+
|
|
301
|
+
root_gitignore = (tmp_path / ".gitignore").read_text(encoding="utf-8")
|
|
302
|
+
assert root_gitignore.count(".venv/") == 1
|
|
303
|
+
|
|
304
|
+
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.7.0b14"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/configuration.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/dcm_operations.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/menus/git_operations.py
RENAMED
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/models/git_helpers.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/models/project_config.py
RENAMED
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/bootstrap_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dbt_runner.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_orchestrator.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_pipelines.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_registry.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/dcm_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/git_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/linting_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/model_commands.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/pipeline_env.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/skill_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/snowflake_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/services/upstream_service.py
RENAMED
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/file_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_cli/utilities/yaml_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/src/datasecops_model/templates/macros/role.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datasecops_cli-0.7.0b16 → datasecops_cli-0.7.0b17}/tests/test_dbt_project_generator_profiles.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|