Skip to content

Commit 4bc5cf1

Browse files
authored
Add secret name length check (#69362)
* Add secret name length check * Add secret name length check * Reword error msg
1 parent 6923f99 commit 4bc5cf1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hack/gcp-secret-manager/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
# The string reserved for the service account secret associated with each collection.
2727
UPDATER_SA_SECRET_NAME = "updater-service-account"
2828

29+
# GCP limit for a secret name is 255 chars, 200 should be plenty
30+
# (we must also take into account the collection).
31+
SECRET_NAME_MAX_LENGTH = 200
32+
2933

3034
def ensure_authentication():
3135
"""
@@ -61,6 +65,8 @@ def validate_secret_name(_ctx, _param, value):
6165
)
6266
if not re.fullmatch("[A-Za-z0-9-]+", value):
6367
raise click.BadParameter("May only contain letters, numbers or dashes.")
68+
if len(value) > SECRET_NAME_MAX_LENGTH:
69+
raise click.BadParameter(f"Secret name must be less than {SECRET_NAME_MAX_LENGTH} characters.")
6470
return value
6571

6672

0 commit comments

Comments
 (0)