diff --git a/.changes/0.3.3.md b/.changes/0.3.3.md new file mode 100644 index 0000000..f298a59 --- /dev/null +++ b/.changes/0.3.3.md @@ -0,0 +1,4 @@ +## 0.3.3 - 2022-08-03 +### Added +* Added MockFeatureFlagClient which is used when env var DBT_FF_DISABLE is set in environment. This allows users to disable live clients without breaking their projects +* Started using changie for changelog management diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md new file mode 100644 index 0000000..df8faa7 --- /dev/null +++ b/.changes/header.tpl.md @@ -0,0 +1,6 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). diff --git a/.changes/unreleased/.gitkeep b/.changes/unreleased/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.changie.yaml b/.changie.yaml new file mode 100644 index 0000000..49897b0 --- /dev/null +++ b/.changie.yaml @@ -0,0 +1,19 @@ +changesDir: .changes +unreleasedDir: unreleased +headerPath: header.tpl.md +changelogPath: CHANGELOG.md +versionExt: md +versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}' +kindFormat: '### {{.Kind}}' +changeFormat: '* {{.Body}}' +kinds: +- label: Added +- label: Changed +- label: Deprecated +- label: Removed +- label: Fixed +- label: Security +newlines: + afterChangelogHeader: 1 + beforeChangelogVersion: 1 + endOfVersion: 1 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f5d4249 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). + + +## 0.3.3 - 2022-08-03 +### Added +* Added MockFeatureFlagClient which is used when env var DBT_FF_DISABLE is set in environment. This allows users to disable live clients without breaking their projects +* Started using changie for changelog management diff --git a/dbt_feature_flags/mock.py b/dbt_feature_flags/mock.py new file mode 100644 index 0000000..cf14c45 --- /dev/null +++ b/dbt_feature_flags/mock.py @@ -0,0 +1,17 @@ +from typing import Union + +from dbt_feature_flags.base import BaseFeatureFlagsClient + + +class MockFeatureFlagClient(BaseFeatureFlagsClient): + def bool_variation(self, flag: str) -> bool: + return False + + def string_variation(self, flag: str) -> str: + return "" + + def number_variation(self, flag: str) -> Union[float, int]: + return 0 + + def json_variation(self, flag: str) -> Union[dict, list]: + return {} diff --git a/dbt_feature_flags/patch.py b/dbt_feature_flags/patch.py index 3e854c6..defb330 100644 --- a/dbt_feature_flags/patch.py +++ b/dbt_feature_flags/patch.py @@ -3,12 +3,14 @@ """ import os -from dbt_feature_flags import base, harness, launchdarkly +from dbt_feature_flags import base, mock, harness, launchdarkly def _get_client() -> base.BaseFeatureFlagsClient: """Return the user specified client, valid impementations MUST inherit from BaseFeatureFlagsClient""" + if os.getenv("DBT_FF_DISABLE"): + return mock.MockFeatureFlagClient() ff_provider = os.getenv("FF_PROVIDER", "harness") ff_client = None if ff_provider == "harness": @@ -24,9 +26,6 @@ def _get_client() -> base.BaseFeatureFlagsClient: def patch_dbt_environment() -> None: - if os.getenv("DBT_FF_DISABLE"): - return - import functools from dbt.clients import jinja diff --git a/pyproject.toml b/pyproject.toml index 585385e..6af2d70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dbt-feature-flags" -version = "0.3.2" +version = "0.3.3" description = "Use feature flags in dbt models" authors = ["z3z1ma "] include = ["zzz_dbt_feature_flags.pth"]