Skip to content

Commit 76b27bd

Browse files
committed
chore(helmbroker): verify instance_name length
1 parent c806f29 commit 76b27bd

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

rootfs/helmbroker/broker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .database.metadata import load_instance_meta, load_binding_meta, load_addons_meta, \
2222
save_instance_meta
2323
from .tasks import provision, bind, deprovision, update, unbind
24+
from .config import INSTANCE_NAME_LENS
2425

2526
logger = logging.getLogger(__name__)
2627

@@ -44,6 +45,10 @@ def provision(self,
4445
async_allowed: bool,
4546
**kwargs) -> ProvisionedServiceSpec:
4647
logger.debug(f"*** provision instance {instance_id}")
48+
# verify instance_name length
49+
if len(details.context["instance_name"]) > INSTANCE_NAME_LENS:
50+
raise ErrBadRequest(
51+
msg=f"The length of the instance name cannot exceed {INSTANCE_NAME_LENS}.")
4752
instance_path = get_instance_path(instance_id)
4853
if os.path.exists(instance_path):
4954
raise ErrInstanceAlreadyExists()

rootfs/helmbroker/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PASSWORD = os.environ.get('HELMBROKER_PASSWORD')
1212

1313
VALKEY_URL = os.environ.get("HELMBROKER_VALKEY_URL", 'redis://localhost:6379/0')
14+
INSTANCE_NAME_LENS = int(os.environ.get("INSTANCE_NAME_LENS", '32'))
1415

1516

1617
class Config:

0 commit comments

Comments
 (0)