Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding name convention validator for QHub project name #761

Merged
merged 32 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e28d83b
add validation to project name
viniciusdc Aug 10, 2021
6497cf7
Add project naming convention validator
viniciusdc Aug 13, 2021
911eef3
backen
viniciusdc Aug 13, 2021
17886c2
Commit suggestions
viniciusdc Aug 13, 2021
5547781
Commit suggestions
viniciusdc Aug 13, 2021
c0848c4
Commit suggestions
viniciusdc Aug 13, 2021
73fb5e1
Commit suggestions
viniciusdc Aug 13, 2021
a0f11c2
Commit suggestions
viniciusdc Aug 13, 2021
0ce8634
update regex
viniciusdc Aug 13, 2021
6d1c489
Add loop for azure provider project name check
tarundmsharma Sep 29, 2021
8dcca0f
Adding project name check for azure deployment
tarundmsharma Sep 29, 2021
6e71f46
Formatting code using black
tarundmsharma Sep 29, 2021
7cc5b21
adding naming convection check for azure
tarundmsharma Oct 1, 2021
398d31c
black formatting
tarundmsharma Oct 1, 2021
e2268f9
adding naming convection check for azure only
tarundmsharma Oct 1, 2021
26e1abc
adding naming convection check for azure only
tarundmsharma Oct 1, 2021
af8323c
Validator for Azure only
tarundmsharma Oct 2, 2021
087c46d
changes in project name for test files
tarundmsharma Oct 6, 2021
737565a
changes in project name for test files
tarundmsharma Oct 6, 2021
53caea9
Project name validator
tarundmsharma Oct 8, 2021
828c71a
black formatting
tarundmsharma Oct 8, 2021
6f21ec9
flake8 error
tarundmsharma Oct 8, 2021
74b7c62
Check for provider and raise related message
viniciusdc Oct 8, 2021
4414266
Undo changes into test project names
viniciusdc Oct 26, 2021
47c522d
Merge branch 'main' into project_name_regex
iameskild Nov 17, 2021
43b7305
Merge branch 'main' into project_name_regex
Dec 15, 2021
5d97dc7
Fix project name to please validator
Dec 15, 2021
ce849f7
Merge branch 'main' into project_name_regex
viniciusdc Mar 18, 2022
f4ceca9
Merge remote-tracking branch 'origin/main' into project_name_regex
viniciusdc Apr 21, 2022
7ac47fb
Blacken
viniciusdc Apr 21, 2022
aea17c5
Merge branch 'main' into project_name_regex
costrouc Apr 26, 2022
00caa91
Update project name
May 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
pip install .[dev]
- name: QHub Initialize
run: |
qhub init "${{ matrix.provider }}" --project "test--${{ matrix.provider }}-${{ matrix.cicd }}" --domain "${{ matrix.provider }}.qhub.dev" --auth-provider github --disable-prompt --ci-provider ${{ matrix.cicd }}
qhub init "${{ matrix.provider }}" --project "TestProvider" --domain "${{ matrix.provider }}.qhub.dev" --auth-provider github --disable-prompt --ci-provider ${{ matrix.cicd }}
cat "qhub-config.yaml"
- name: QHub Render
run: |
Expand Down
44 changes: 41 additions & 3 deletions qhub/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,13 @@ def enabled_must_have_fields(cls, values):


# ==================== Main ===================

letter_dash_underscore_pydantic = pydantic.constr(regex=namestr_regex)


class Main(Base):
project_name: letter_dash_underscore_pydantic
namespace: typing.Optional[letter_dash_underscore_pydantic]
provider: ProviderEnum
project_name: str
namespace: typing.Optional[letter_dash_underscore_pydantic]
qhub_version: str = ""
ci_cd: typing.Optional[CICD]
domain: str
Expand Down Expand Up @@ -485,6 +484,45 @@ def check_default(cls, v):
def is_version_accepted(cls, v):
return v != "" and rounded_ver_parse(v) == rounded_ver_parse(__version__)

@validator("project_name")
def project_name_convention(cls, value: typing.Any, values):
convention = """
In order to successfully deploy QHub, there are some project naming conventions which need
to be followed. First, ensure your name is compatible with the specific one for
your chosen Cloud provider. In addition, the QHub project name should also obey the following
format requirements:
- Letters from A to Z (upper and lower case) and numbers;
- Maximum accepted length of the name string is 16 characters.
- If using AWS: names should not start with the string "aws";
Copy link
Contributor

@tylerpotts tylerpotts Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this come from? It looks like the current aws test has a project name aws-test

This is causing the AWS tests to fail

Copy link
Contributor Author

@viniciusdc viniciusdc Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the description... but I don't remember why we need to avoid that. I remember a discussion about that a really long time ago... Anyways I will need to add another step in that validation because the Azure storage name must not contain any dashes

- If using Azure: names should not contain "-".
"""
if len(value) > 16:
raise ValueError(
"\n".join(
[
convention,
"Maximum accepted length of the project name string is 16 characters.",
]
)
)
elif values["provider"] == "azure" and ("-" in value):
raise ValueError(
"\n".join(
[convention, "Provider [azure] does not allow '-' in project name."]
)
)
elif values["provider"] == "aws" and value.startswith("aws"):
raise ValueError(
"\n".join(
[
convention,
"Provider [aws] does not allow 'aws' as starting sequence in project name.",
]
)
)
else:
return letter_dash_underscore_pydantic


def verify(config):
return Main(**config)
Expand Down