Skip to content

Commit

Permalink
Extended validations for the project names (#5620)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodkat authored Aug 10, 2022
1 parent 4d6208b commit a3b018f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20220805-221022.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Extended validations for the project names
time: 2022-08-05T22:10:22.746830854+02:00
custom:
Author: Goodkat
Issue: "5379"
PR: "5620"
8 changes: 7 additions & 1 deletion core/dbt/task/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

from dbt.include.starter_project import PACKAGE_PATH as starter_project_directory

from dbt.include.global_project import PROJECT_NAME as GLOBAL_PROJECT_NAME

from dbt.task.base import BaseTask, move_to_nearest_project_dir

DOCS_URL = "https://docs.getdbt.com/docs/configure-your-profile"
Expand Down Expand Up @@ -258,7 +260,11 @@ def ask_for_adapter_choice(self) -> str:
def get_valid_project_name(self) -> str:
"""Returns a valid project name, either from CLI arg or user prompt."""
name = self.args.project_name
while not ProjectName.is_valid(name):
internal_package_names = {GLOBAL_PROJECT_NAME}
available_adapters = list(_get_adapter_plugin_names())
for adapter_name in available_adapters:
internal_package_names.update(f"dbt_{adapter_name}")
while not ProjectName.is_valid(name) or name in internal_package_names:
if name:
click.echo(name + " is not a valid project name.")
name = click.prompt("Enter a name for your project (letters, digits, underscore)")
Expand Down

0 comments on commit a3b018f

Please sign in to comment.