def match_expressions(self, me=None): if not is_valid_list(me, LabelSelectorRequirement): raise SyntaxError( 'LabelSelector: match_expressions: [ {} ] is invalid.'.format( me)) self._match_expressions = me
def required_during_scheduling_ignored_during_execution(self, pats=None): # raise NotImplementedError('Not yet implemented in Kubernetes 1.6') if not is_valid_list(pats, PodAffinityTerm): raise SyntaxError( 'PodAffinity: required_during_scheduling_ignored_during_execution: [ {} ] is invald.' .format(pats)) self._required_during_scheduling_ignored_during_execution = pats
def access_modes(self, modes=None): if not is_valid_list(modes, str): raise SyntaxError( 'PersistentVolumeClaimStatus: access_modes: [ {} ] is invalid.' .format(modes)) filtered = filter( lambda x: x in PersistentVolumeSpec.VALID_ACCESS_MODES, modes) self._access_modes = filtered
def http_headers(self, headers=None): msg = 'HTTPGetAction: headers: [ {0} ] is invalid.'.format(headers) if not is_valid_list(headers, dict): raise SyntaxError(msg) for x in headers: if not is_valid_dict(x, ['name', 'value']): raise SyntaxError(msg) self._http_headers = headers
def external_ips(self, ips=None): msg = 'ServiceSpec: external_ips: [ {0} ] is invalid.'.format(ips) if not is_valid_list(ips, str): raise SyntaxError(msg) for ip in ips: if not is_reachable(ip): raise SyntaxError(msg) self._external_ips = ips
def containers(self, containers=None): if not is_valid_list(containers, K8sContainer): raise SyntaxError( 'K8sCronJob: containers: [ {} ] is invalid.'.format(containers)) models = [] for obj in containers: models.append(obj.model) self.model.spec.job_template.spec.template.spec.containers = models
def add_image_pull_secrets(self, secrets=None): if not is_valid_list(secrets, dict): raise SyntaxError('PodSpec.add_image_pull_secrets() secrets : [ {0} ] is invalid.'.format(secrets)) s = self.image_pull_secrets if s is None: combined = secrets else: combined = s + secrets filtered = filter(lambda x: isinstance(x, dict), combined) self.image_pull_secrets = filtered return self
def add_image_pull_secrets(self, secrets=None): if not is_valid_list(secrets, dict): raise SyntaxError('PodSpec.add_image_pull_secrets() secrets : [ {0} ] is invalid.'.format(secrets)) s = self.image_pull_secrets if s is None: l = secrets else: l = s + secrets self.image_pull_secrets = [dict(t) for t in set([tuple(d.items()) for d in l])] return self
def values(self, v=None): if not is_valid_list(convert(v), str): raise SyntaxError( 'NodeSelectorRequirement: values: [ {} ] is invalid.'.format(v)) if self.operator in ['In, NotIn'] and v == []: raise SyntaxError( 'NodeSelectorRequirement: values: [ {} ] cannot be empty, if operator in [ "In", "NotIn" ]'.format(v)) if self.operator in ['Exists', 'NotExists'] and v != []: raise SyntaxError( 'NodeSelectorRequirement: values: [ {} ] must be empty, if operator in [ "Exists", "NotExists" ]'.format(v)) if self.operator in ['Gt', 'Lt']: if len(v) != 1: raise SyntaxError( 'NodeSelectorRequirement: values: [ {} ] must be an array of length 1, if operator in [ "Gt", "Lt" ]'.format(v)) if not isinstance(v[0], int): raise SyntaxError( 'NodeSelectorRequirement: values: [ {} ] must contain a single integer, if operator in [ "Gt", "Lt" ]'.format(v)) self._values = v
def access_modes(self, modes=None): if not is_valid_list(modes, str): raise SyntaxError('PersistentVolumeClaimStatus: access_modes: [ {} ] is invalid.'.format(modes)) filtered = list(filter(lambda x: x in PersistentVolumeSpec.VALID_ACCESS_MODES, modes)) self._access_modes = filtered
def namespaces(self, n=None): if not is_valid_list(convert(n), str): raise SyntaxError( 'PodAffinityTerm: namespaces: [ {} ] is invalid.'.format(n)) self._namespaces = n
def items(self, items=None): if not is_valid_list(items, KeyToPath): raise SyntaxError('SecretVolumeSource: items: [ {0} ] is invalid.'.format(items)) self._items = items
def ingress(self, ingress=None): if not is_valid_list(ingress, LoadBalancerIngress): raise SyntaxError('LoadBalancerStatus: ingress: [ {0} ] is invalid.'.format(ingress)) self._ingress = ingress
def volume_mounts(self, mounts=None): if not is_valid_list(mounts, VolumeMount): raise SyntaxError('Container: volume_mounts: [ {0} ] is invalid.'.format(mounts)) self._volume_mounts = mounts
def args(self, args=None): if not is_valid_list(args, str): raise SyntaxError('Container: args: [ {0} ] is invalid.'.format(args)) self._args = args
def tolerations(self, t=None): if not is_valid_list(t, Toleration): raise SyntaxError('PodSpec: tolerations: [ {} ] is invalid.'.format(t)) self._tolerations = t
def image_pull_secrets(self, secrets=None): if not is_valid_list(secrets, dict): raise SyntaxError('PodSpec: image_pull_secrets: [ {0} ] is invalid.'.format(secrets)) self._image_pull_secrets = secrets
def containers(self, containers=None): if not is_valid_list(containers, Container): raise SyntaxError('PodSpec: containers: [ {0} ] is invalid.'.format(containers)) self._containers = containers
def volume_claim_templates(self, vcts=None): if not is_valid_list(vcts, PersistentVolumeClaim): raise SyntaxError('StatefulSetSpec: volume_claim_templates: [ {} ] is invalid.'.format(vcts)) self._volume_claim_templates = vcts
def ports(self, ports=None): if not is_valid_list(ports, ServicePort): raise SyntaxError( 'ServiceSpec: ports: [ {0} ] is invalid.'.format(ports)) self._ports = ports
def env(self, env=None): if not is_valid_list(env, EnvVar): raise SyntaxError( "Container: env: [ {0} ] is invalid.".format(env)) self._env = env
def volumes(self, volumes=None): if not is_valid_list(volumes, Volume): raise SyntaxError('PodSpec: volumes: [ {0} ] is invalid.'.format(volumes)) self._volumes = volumes
def volume_mounts(self, mounts=None): if not is_valid_list(mounts, VolumeMount): raise SyntaxError( 'Container: volume_mounts: [ {0} ] is invalid.'.format(mounts)) self._volume_mounts = mounts
def tolerations(self, t=None): if not is_valid_list(t, Toleration): raise SyntaxError( 'PodSpec: tolerations: [ {} ] is invalid.'.format(t)) self._tolerations = t
def env(self, env=None): if not is_valid_list(env, EnvVar): raise SyntaxError("Container: env: [ {0} ] is invalid.".format(env)) self._env = env
def secrets(self, s=None): if not is_valid_list(s, ObjectReference): raise SyntaxError( 'ServiceAccount: secrets: [ {} ] is invalid.'.format(s)) self._secrets = s
def preferred_during_scheduling_ignored_during_execution(self, p=None): if not is_valid_list(p, PreferredSchedulingTerm): raise SyntaxError( 'NodeAffinity: preferred_during_scheduling_ignored_during_execution: [ {} ] is invalid.'.format(p)) self._preferred_during_scheduling_ignored_during_execution = p
def image_pull_secrets(self, s=None): if not is_valid_list(s, LocalObjectReference): raise SyntaxError( 'ServiceAccount: image_pull_secrets: [ {} ] is invalid.'. format(s)) self._image_pull_secrets = s
def conditions(self, conds=None): if not is_valid_list(conds, JobCondition): raise SyntaxError('JobStatus: conditions: [ {} ] is invalid.'.format(conds)) self._conditions = conds
def taints(self, t=None): if not is_valid_list(t, Taint): raise SyntaxError('NodeSpec: taints: [ {} ] is invalid.'.format(t)) self._taints = t
def items(self, i=None): if not is_valid_list(target=i, element_class=Node): raise SyntaxError('NodeList: items: [ {0} ] is invalid.'.format(i)) self._items = i
def taints(self, t=None): if not is_valid_list(t, Taint): raise SyntaxError('K8sNode: taints: [ {} ] is invalid.'.format(t)) self.model.spec.taints = t
def args(self, args=None): if not is_valid_list(args, str): raise SyntaxError( 'Container: args: [ {0} ] is invalid.'.format(args)) self._args = args
def add(self, a=None): if not is_valid_list(a, str): raise SyntaxError('Capabilities: add: [ {} ] is invalid.'.format(a)) self._add = a
def volumes(self, v=None): if not is_valid_list(v, K8sVolume): self.model.spec.template.spec.volumes = v
def namespaces(self, n=None): if not is_valid_list(convert(n), str): raise SyntaxError('PodAffinityTerm: namespaces: [ {} ] is invalid.'.format(n)) self._namespaces = n
def drop(self, d=None): if not is_valid_list(d, str): raise SyntaxError('Capabilities: add: [ {} ] is invalid.'.format(d)) self._drop = d
def containers(self, containers=None): if not is_valid_list(containers, K8sContainer): self.model.spec.containers = [x.model for x in containers]
def command(self, command=None): if not is_valid_list(command, str): raise SyntaxError( 'Container: command: [ {0} ] is invalid.'.format(command)) self._command = command
def ports(self, ports=None): if not is_valid_list(ports, ContainerPort): raise SyntaxError( 'Container: ports: [ {0} ] is invalid.'.format(ports)) self._ports = ports
def command(self, command=None): if not is_valid_list(command, str): raise SyntaxError('Container: command: [ {0} ] is invalid.'.format(command)) self._command = command
def volume_claim_templates(self, t=None): if not is_valid_list(t, PersistentVolumeClaim): raise SyntaxError('PetSetSpec: volume_claim_templates: [ {} ] is invalid.'.format(t)) self._volume_claim_templates = t
def ports(self, ports=None): if not is_valid_list(ports, ContainerPort): raise SyntaxError('Container: ports: [ {0} ] is invalid.'.format(ports)) self._ports = ports
def volume_claim_templates(self, vcts=None): if not is_valid_list(vcts, PersistentVolumeClaim): raise SyntaxError( 'StatefulSetSpec: volume_claim_templates: [ {} ] is invalid.'. format(vcts)) self._volume_claim_templates = vcts
def supplemental_groups(self, gids=None): if not is_valid_list(gids, int): raise SyntaxError( 'PodSecurityContext: supplemental_groups: [ {0} ] is invalid.'. format(gids)) self._supplemental_groups = gids
def supplemental_groups(self, gids=None): if not is_valid_list(gids, int): raise SyntaxError('PodSecurityContext: supplemental_groups: [ {0} ] is invalid.'.format(gids)) self._supplemental_groups = gids
def values(self, v=None): if not is_valid_list(v, str): raise SyntaxError('LabelSelectorRequirements: values: [ {} ] is invalid.'.format(v)) self._values = v