Skip to content

Commit 2eb95f3

Browse files
renovate[bot]iciclespider
authored andcommitted
Integrate render command with an active cluster
1 parent 4f53ce9 commit 2eb95f3

4 files changed

Lines changed: 359 additions & 164 deletions

File tree

crossplane/pythonic/composite.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,18 @@ def __init__(self, composite, name):
242242
self.autoReady = None
243243
self.usages = None
244244

245-
def __call__(self, apiVersion=_notset, kind=_notset, namespace=_notset, name=_notset):
245+
def __call__(self, kind=_notset, apiVersion=_notset, namespace=_notset, name=_notset):
246246
self.desired()
247+
if kind != _notset:
248+
# Allow for apiVersion in the first arg and kind in the second arg
249+
if '/' in kind or kind == 'v1':
250+
if apiVersion != _notset:
251+
self.kind = apiVersion
252+
apiVersion = kind
253+
else:
254+
self.kind = kind
247255
if apiVersion != _notset:
248256
self.apiVersion = apiVersion
249-
if kind != _notset:
250-
self.kind = kind
251257
if namespace != _notset:
252258
self.metadata.namespace = namespace
253259
if name != _notset:
@@ -408,12 +414,18 @@ def __init__(self, composite, name):
408414
self._resources = composite.request.required_resources[name]
409415
self._cache = {}
410416

411-
def __call__(self, apiVersion=_notset, kind=_notset, namespace=_notset, name=_notset, labels=_notset):
417+
def __call__(self, kind=_notset, apiVersion=_notset, namespace=_notset, name=_notset, labels=_notset):
412418
self._selector()
419+
if kind != _notset:
420+
# Allow for apiVersion in the first arg and kind in the second arg
421+
if '/' in kind or kind == 'v1':
422+
if apiVersion != _notset:
423+
self.kind = apiVersion
424+
apiVersion = kind
425+
else:
426+
self.kind = kind
413427
if apiVersion != _notset:
414428
self.apiVersion = apiVersion
415-
if kind != _notset:
416-
self.kind = kind
417429
if namespace != _notset:
418430
self.namespace = namespace
419431
if name != _notset:

crossplane/pythonic/protobuf.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,29 @@ def Unknown():
3737

3838
def Yaml(string, readOnly=None):
3939
if isinstance(string, (FieldMessage, Value)):
40+
if not string:
41+
return string
4042
string = str(string)
4143
return Value(None, None, yaml.safe_load(string), readOnly)
4244

4345
def Json(string, readOnly=None):
4446
if isinstance(string, (FieldMessage, Value)):
47+
if not string:
48+
return string
4549
string = str(string)
4650
return Value(None, None, json.loads(string), readOnly)
4751

4852
def B64Encode(string):
4953
if isinstance(string, (FieldMessage, Value)):
54+
if not string:
55+
return string
5056
string = str(string)
5157
return base64.b64encode(string.encode('utf-8')).decode('utf-8')
5258

5359
def B64Decode(string):
5460
if isinstance(string, (FieldMessage, Value)):
61+
if not string:
62+
return string
5563
string = str(string)
5664
return base64.b64decode(string.encode('utf-8')).decode('utf-8')
5765

@@ -684,10 +692,11 @@ def __getattr__(self, key):
684692

685693
def __getitem__(self, key):
686694
key = self._validate_key(key)
687-
if key in self._cache:
688-
return self._cache[key]
689-
if key in self._unknowns:
690-
return self._unknowns[key]
695+
if key != append:
696+
if key in self._cache:
697+
return self._cache[key]
698+
if key in self._unknowns:
699+
return self._unknowns[key]
691700
if isinstance(key, str):
692701
match self._kind:
693702
case 'struct_value':
@@ -701,14 +710,26 @@ def __getitem__(self, key):
701710
elif isinstance(key, int):
702711
match self._kind:
703712
case 'list_value':
713+
if key < 0:
714+
key = len(self._value.list_value.values) + key
715+
if key < 0:
716+
key = 0
704717
if key < len(self._value.list_value.values):
705718
value = self._value.list_value.values[key]
706719
else:
720+
if key == append:
721+
key = len(self._value.list_value.values)
707722
value = _Unknown
708723
case 'ListValue':
724+
if key < 0:
725+
key = len(self._value.values) + key
726+
if key < 0:
727+
key = 0
709728
if key < len(self._value.values):
710729
value = self._value.values[key]
711730
else:
731+
if key == append:
732+
key = len(self._value.values)
712733
value = _Unknown
713734
case 'Unknown':
714735
value = _Unknown

0 commit comments

Comments
 (0)