-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cookiecutter and tf input validation
Co-Authored-By: Faisal Alquaddoomi <[email protected]>
- Loading branch information
1 parent
35a7cc7
commit 4581607
Showing
4 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Hook for checking values from cookiecutter variables before generating the project. | ||
See the following for more information: | ||
https://cookiecutter.readthedocs.io/en/1.7.0/advanced/hooks.html | ||
""" | ||
|
||
import sys | ||
|
||
project_name = "{{ cookiecutter.project_name }}" | ||
project_gc_project = "{{ cookiecutter.project_gc_project }}" | ||
|
||
# checking for proper length of the project name | ||
# note: we provide the limitation here based on constraints | ||
# for Google service accounts and how the variable is used within template. | ||
# See the following for more information: | ||
# https://cloud.google.com/iam/docs/service-accounts-create#creating | ||
if not 6 <= len(project_name) <= 21: | ||
print( | ||
"ERROR: %s Please use a project name of length 6-21 characters!" % project_name | ||
) | ||
sys.exit(1) | ||
|
||
# limitation for google project names | ||
# see the following for more information: | ||
# https://cloud.google.com/resource-manager/docs/creating-managing-projects | ||
if not 4 <= len(project_gc_project) <= 30: | ||
print( | ||
"ERROR: %s Please use a Google project name of length 4-30 characters!" % project_name | ||
) | ||
sys.exit(1) |
5 changes: 1 addition & 4 deletions
5
{{ cookiecutter.project_name }}/terraform/operations/accounts.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters