def test_get_app_kind(self): self.assertEqual(split_str_by_capital_letters('ConfigMap'), 'config_map') self.assertEqual(split_str_by_capital_letters('Namespace'), 'namespace') self.assertEqual(split_str_by_capital_letters('PodDisruptionBudget'), 'pod_disruption_budget')
def _is_pvc_specs_equals(self, old_obj, new_dict): for new_key in new_dict.keys(): old_key = split_str_by_capital_letters(new_key) # if template has some new attributes if not hasattr(old_obj, old_key): return False old_value = getattr(old_obj, old_key) if isinstance(old_value, list) and \ isinstance(old_value[0], V1LabelSelectorRequirement): if len(old_value) != len(new_dict[new_key]): return False for i in range(0, len(old_value)): if not self._is_pvc_specs_equals(old_value[i], new_dict[new_key][i]): return False elif isinstance(old_value, (V1ResourceRequirements, V1LabelSelector)): if not self._is_pvc_specs_equals(old_value, new_dict[new_key]): return False elif old_value != new_dict[new_key]: log.error('{} != {}'.format(old_value, new_dict[new_key])) return False return True
def _ports_are_equal(old_port, new_port): for new_key in new_port.keys(): old_key = split_str_by_capital_letters(new_key) if getattr(old_port, old_key, None) != new_port.get(new_key, None): return False return True
def __init__(self, spec, api=None): super().__init__(spec) self.kind = split_str_by_capital_letters(spec['kind']) self.replicas = spec.get('spec', {}).get('replicas') self.api = api