From f3735187a620e3a40ee01b3fa04be191de2b5901 Mon Sep 17 00:00:00 2001 From: Niall Woodward Date: Thu, 27 Jan 2022 17:17:28 +0000 Subject: [PATCH] Run check_if_can_write_profile before create_profile_using_project_profile_template [CT-67] [Backport 1.0.latest] (#4447) * Run check_if_can_write_profile before create_profile_using_project_profile_template * Changelog Co-authored-by: Ian Knox <81931810+iknox-fa@users.noreply.github.com> --- CHANGELOG.md | 7 +++++-- core/dbt/task/init.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92431bb811d..7914ff11704 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,16 @@ - New Dockerfile to support specific db adapters and platforms. See docker/README.md for details ([#4495](https://github.com/dbt-labs/dbt-core/issues/4495), [#4487](https://github.com/dbt-labs/dbt-core/pull/4487)) ### Fixes - -* Add project name validation to `dbt init` ([#4490](https://github.com/dbt-labs/dbt-core/issues/4490),[#4536](https://github.com/dbt-labs/dbt-core/pull/4536)) +- User wasn't asked for permission to overwite a profile entry when running init inside an existing project ([#4375](https://github.com/dbt-labs/dbt-core/issues/4375), [#4447](https://github.com/dbt-labs/dbt-core/pull/4447)) +- Add project name validation to `dbt init` ([#4490](https://github.com/dbt-labs/dbt-core/issues/4490),[#4536](https://github.com/dbt-labs/dbt-core/pull/4536)) ### Under the hood - Testing cleanup ([#4496](https://github.com/dbt-labs/dbt-core/pull/4496), [#4509](https://github.com/dbt-labs/dbt-core/pull/4509)) - Clean up test deprecation warnings ([#3988](https://github.com/dbt-labs/dbt-core/issue/3988), [#4556](https://github.com/dbt-labs/dbt-core/pull/4556)) +Contributors: +- [@NiallRees](https://github.com/NiallRees) ([#4447](https://github.com/dbt-labs/dbt-core/pull/4447)) + ## dbt-core 1.0.2 (TBD) ### Fixes diff --git a/core/dbt/task/init.py b/core/dbt/task/init.py index daba2d3af62..1f1d0daa182 100644 --- a/core/dbt/task/init.py +++ b/core/dbt/task/init.py @@ -297,6 +297,8 @@ def run(self): # just setup the user's profile. fire_event(SettingUpProfile()) profile_name = self.get_profile_name_from_current_project() + if not self.check_if_can_write_profile(profile_name=profile_name): + return # If a profile_template.yml exists in the project root, that effectively # overrides the profile_template.yml for the given target. profile_template_path = Path("profile_template.yml") @@ -308,8 +310,6 @@ def run(self): return except Exception: fire_event(InvalidProfileTemplateYAML()) - if not self.check_if_can_write_profile(profile_name=profile_name): - return adapter = self.ask_for_adapter_choice() self.create_profile_from_target( adapter, profile_name=profile_name