From 9ca2a21e30dcf109f79937658da360c6c4b92a18 Mon Sep 17 00:00:00 2001 From: Gregory Foster Date: Sat, 2 Dec 2023 12:46:35 -0800 Subject: [PATCH] #145: bug_and_feature/pre_gen_project_hook - adding hook script to validate infrastructure_slug (#150) #145: adding pre_gen_project hook to validate input variable infrastructure_slug --- hooks/pre_gen_project.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 hooks/pre_gen_project.py diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py new file mode 100644 index 00000000..a39a07bb --- /dev/null +++ b/hooks/pre_gen_project.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys + +# Validate the specified Google Cloud Project name is <= 30 chars +infrastructure_slug = '{{ cookiecutter.infrastructure_slug }}' + +if len(infrastructure_slug) > 30: + print(f"ERROR: {infrastructure_slug} is not a valid Google Cloud Project name! (>30 characters)") + sys.exit(1)