Skip to content

Commit e60b44a

Browse files
authored
Merge pull request #244 from hpe-container-platform-community/snowch/validate-k-s-cluster-id-243
fix(cli): #243
2 parents 6fb4d99 + 967020f commit e60b44a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

hpecp/tenant.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from __future__ import absolute_import
2222

23+
import re
2324
from enum import Enum
2425

2526
from requests.structures import CaseInsensitiveDict
@@ -132,7 +133,11 @@ def __init__(self, client):
132133
self.client = client
133134

134135
def create(
135-
self, name=None, description=None, tenant_type=None, k8s_cluster=None
136+
self,
137+
name=None,
138+
description=None,
139+
tenant_type=None,
140+
k8s_cluster_id=None,
136141
):
137142

138143
assert (
@@ -142,11 +147,15 @@ def create(
142147
description, basestring
143148
), "'description' if provided, must be a string"
144149

150+
assert isinstance(k8s_cluster_id, str) and re.match(
151+
r"\/api\/v2\/k8scluster\/[0-9]+", k8s_cluster_id
152+
), "'k8s_cluster_id' must have format '/api/v2/k8scluster/[0-9]+'"
153+
145154
data = {
146155
"label": {"name": name},
147156
"tenant_type": tenant_type,
148157
"member_key_available": "all_admins",
149-
"k8s_cluster": k8s_cluster,
158+
"k8s_cluster": k8s_cluster_id,
150159
}
151160
if description is not None:
152161
data["label"]["description"] = description

0 commit comments

Comments
 (0)