desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'return whether volume is bound'
| def is_bound(self):
| return (self.get(PersistentVolumeClaim.bound_path) or [])
|
'add an access_mode'
| def add_access_mode(self, inc_mode):
| if self.access_modes:
self.access_modes.append(inc_mode)
else:
self.put(PersistentVolumeClaim.access_modes_path, [inc_mode])
return True
|
'remove an access_mode'
| def remove_access_mode(self, inc_mode):
| try:
self.access_modes.remove(inc_mode)
except ValueError as _:
return False
return True
|
'update an access_mode'
| def update_access_mode(self, inc_mode):
| try:
index = self.access_modes.index(inc_mode)
except ValueError as _:
return self.add_access_mode(inc_mode)
self.access_modes[index] = inc_mode
return True
|
'find a user'
| def find_access_mode(self, inc_mode):
| index = None
try:
index = self.access_modes.index(inc_mode)
except ValueError as _:
return index
return index
|
'Project constructor'
| def __init__(self, content):
| super(Project, self).__init__(content=content)
|
'return the annotations'
| def get_annotations(self):
| return (self.get(Project.annotations_path) or {})
|
'add an annotation to the other annotations'
| def add_annotations(self, inc_annos):
| if (not isinstance(inc_annos, list)):
inc_annos = [inc_annos]
annos = self.get_annotations()
if (not annos):
self.put(Project.annotations_path, inc_annos)
else:
for anno in inc_annos:
for (key, value) in anno.items():
annos[key] = value
return True... |
'find an annotation'
| def find_annotation(self, key):
| annotations = self.get_annotations()
for anno in annotations:
if ((Project.annotation_prefix + key) == anno):
return annotations[anno]
return None
|
'remove an annotation from a project'
| def delete_annotation(self, inc_anno_keys):
| if (not isinstance(inc_anno_keys, list)):
inc_anno_keys = [inc_anno_keys]
annos = (self.get(Project.annotations_path) or {})
if (not annos):
return True
removed = False
for inc_anno in inc_anno_keys:
anno = self.find_annotation(inc_anno)
if anno:
del annos... |
'remove an annotation for a project'
| def update_annotation(self, key, value):
| annos = (self.get(Project.annotations_path) or {})
if (not annos):
return True
updated = False
anno = self.find_annotation(key)
if anno:
annos[(Project.annotation_prefix + key)] = value
updated = True
else:
self.add_annotations({(Project.annotation_prefix + key): ... |
'constructor for handling service options'
| def __init__(self, sname, namespace, ports, selector=None, labels=None, cluster_ip=None, portal_ip=None, session_affinity=None, service_type=None, external_ips=None):
| self.name = sname
self.namespace = namespace
self.ports = ports
self.selector = selector
self.labels = labels
self.cluster_ip = cluster_ip
self.portal_ip = portal_ip
self.session_affinity = session_affinity
self.service_type = service_type
self.external_ips = external_ips
sel... |
'instantiates a service dict'
| def create_dict(self):
| self.data['apiVersion'] = 'v1'
self.data['kind'] = 'Service'
self.data['metadata'] = {}
self.data['metadata']['name'] = self.name
self.data['metadata']['namespace'] = self.namespace
if self.labels:
self.data['metadata']['labels'] = {}
for (lab, lab_value) in self.labels.items():
... |
'Service constructor'
| def __init__(self, content):
| super(Service, self).__init__(content=content)
|
'get a list of ports'
| def get_ports(self):
| return (self.get(Service.port_path) or [])
|
'get the service selector'
| def get_selector(self):
| return (self.get(Service.selector_path) or {})
|
'add a port object to the ports list'
| def add_ports(self, inc_ports):
| if (not isinstance(inc_ports, list)):
inc_ports = [inc_ports]
ports = self.get_ports()
if (not ports):
self.put(Service.port_path, inc_ports)
else:
ports.extend(inc_ports)
return True
|
'find a specific port'
| def find_ports(self, inc_port):
| for port in self.get_ports():
if (port['port'] == inc_port['port']):
return port
return None
|
'remove a port from a service'
| def delete_ports(self, inc_ports):
| if (not isinstance(inc_ports, list)):
inc_ports = [inc_ports]
ports = (self.get(Service.port_path) or [])
if (not ports):
return True
removed = False
for inc_port in inc_ports:
port = self.find_ports(inc_port)
if port:
ports.remove(port)
remove... |
'add cluster ip'
| def add_cluster_ip(self, sip):
| self.put(Service.cluster_ip, sip)
|
'add cluster ip'
| def add_portal_ip(self, pip):
| self.put(Service.portal_ip, pip)
|
'get a list of external_ips'
| def get_external_ips(self):
| return (self.get(Service.external_ips) or [])
|
'add an external_ip to the external_ips list'
| def add_external_ips(self, inc_external_ips):
| if (not isinstance(inc_external_ips, list)):
inc_external_ips = [inc_external_ips]
external_ips = self.get_external_ips()
if (not external_ips):
self.put(Service.external_ips, inc_external_ips)
else:
external_ips.extend(inc_external_ips)
return True
|
'find a specific external IP'
| def find_external_ips(self, inc_external_ip):
| val = None
try:
idx = self.get_external_ips().index(inc_external_ip)
val = self.get_external_ips()[idx]
except ValueError:
pass
return val
|
'remove an external IP from a service'
| def delete_external_ips(self, inc_external_ips):
| if (not isinstance(inc_external_ips, list)):
inc_external_ips = [inc_external_ips]
external_ips = (self.get(Service.external_ips) or [])
if (not external_ips):
return True
removed = False
for inc_external_ip in inc_external_ips:
external_ip = self.find_external_ips(inc_extern... |
'constructor for handling user options'
| def __init__(self, kubeconfig, username, full_name):
| self.kubeconfig = kubeconfig
self.username = username
self.full_name = full_name
self.data = {}
self.create_dict()
|
'return a user as a dict'
| def create_dict(self):
| self.data['apiVersion'] = 'v1'
self.data['fullName'] = self.full_name
self.data['groups'] = None
self.data['identities'] = None
self.data['kind'] = 'User'
self.data['metadata'] = {}
self.data['metadata']['name'] = self.username
|
'User constructor'
| def __init__(self, content):
| super(User, self).__init__(content=content)
|
'constructor for handling storageclass options'
| def __init__(self, name, provisioner, parameters=None, annotations=None, default_storage_class='false', api_version='v1', kubeconfig='/etc/origin/master/admin.kubeconfig'):
| self.name = name
self.parameters = parameters
self.annotations = annotations
self.provisioner = provisioner
self.api_version = api_version
self.default_storage_class = str(default_storage_class).lower()
self.kubeconfig = kubeconfig
self.data = {}
self.create_dict()
|
'instantiates a storageclass dict'
| def create_dict(self):
| self.data['apiVersion'] = self.api_version
self.data['kind'] = 'StorageClass'
self.data['metadata'] = {}
self.data['metadata']['name'] = self.name
self.data['metadata']['annotations'] = {}
if (self.annotations is not None):
self.data['metadata']['annotations'] = self.annotations
self... |
'StorageClass constructor'
| def __init__(self, content):
| super(StorageClass, self).__init__(content=content)
|
'get a list of ports'
| def get_annotations(self):
| return (self.get(StorageClass.annotations_path) or {})
|
'get the service selector'
| def get_parameters(self):
| return (self.get(StorageClass.parameters_path) or {})
|
'constructor for handling route options'
| def __init__(self, sname, namespace, kubeconfig, destcacert=None, cacert=None, cert=None, key=None, host=None, tls_termination=None, service_name=None, wildcard_policy=None, weight=None, port=None):
| self.kubeconfig = kubeconfig
self.name = sname
self.namespace = namespace
self.host = host
self.tls_termination = tls_termination
self.destcacert = destcacert
self.cacert = cacert
self.cert = cert
self.key = key
self.service_name = service_name
self.port = port
self.data ... |
'return a service as a dict'
| def create_dict(self):
| self.data['apiVersion'] = 'v1'
self.data['kind'] = 'Route'
self.data['metadata'] = {}
self.data['metadata']['name'] = self.name
self.data['metadata']['namespace'] = self.namespace
self.data['spec'] = {}
self.data['spec']['host'] = self.host
if self.tls_termination:
self.data['spe... |
'Route constructor'
| def __init__(self, content):
| super(Route, self).__init__(content=content)
|
'return cert'
| def get_destcacert(self):
| return self.get(Route.destcacert_path)
|
'return cert'
| def get_cert(self):
| return self.get(Route.cert_path)
|
'return key'
| def get_key(self):
| return self.get(Route.key_path)
|
'return cacert'
| def get_cacert(self):
| return self.get(Route.cacert_path)
|
'return service name'
| def get_service(self):
| return self.get(Route.service_path)
|
'return service weight'
| def get_weight(self):
| return self.get(Route.weight_path)
|
'return tls termination'
| def get_termination(self):
| return self.get(Route.termination_path)
|
'return host'
| def get_host(self):
| return self.get(Route.host_path)
|
'return port'
| def get_port(self):
| return self.get(Route.port_path)
|
'return wildcardPolicy'
| def get_wildcard_policy(self):
| return self.get(Route.wildcard_policy)
|
'constructor for handling scc options'
| def __init__(self, sname, kubeconfig, options=None, fs_group='MustRunAs', default_add_capabilities=None, groups=None, priority=None, required_drop_capabilities=None, run_as_user='MustRunAsRange', se_linux_context='MustRunAs', supplemental_groups='RunAsAny', users=None, annotations=None):
| self.kubeconfig = kubeconfig
self.name = sname
self.options = options
self.fs_group = fs_group
self.default_add_capabilities = default_add_capabilities
self.groups = groups
self.priority = priority
self.required_drop_capabilities = required_drop_capabilities
self.run_as_user = run_as... |
'assign the correct properties for a scc dict'
| def create_dict(self):
| if self.options:
for (key, value) in self.options.items():
self.data[key] = value
else:
self.data['allowHostDirVolumePlugin'] = False
self.data['allowHostIPC'] = False
self.data['allowHostNetwork'] = False
self.data['allowHostPID'] = False
self.data['a... |
'SecurityContextConstraints constructor'
| def __init__(self, content):
| super(SecurityContextConstraints, self).__init__(content=content)
self._users = None
self._groups = None
|
'users property getter'
| @property
def users(self):
| if (self._users is None):
self._users = self.get_users()
return self._users
|
'groups property getter'
| @property
def groups(self):
| if (self._groups is None):
self._groups = self.get_groups()
return self._groups
|
'users property setter'
| @users.setter
def users(self, data):
| self._users = data
|
'groups property setter'
| @groups.setter
def groups(self, data):
| self._groups = data
|
'get scc users'
| def get_users(self):
| return (self.get(SecurityContextConstraints.users_path) or [])
|
'get scc groups'
| def get_groups(self):
| return (self.get(SecurityContextConstraints.groups_path) or [])
|
'add a user'
| def add_user(self, inc_user):
| if self.users:
self.users.append(inc_user)
else:
self.put(SecurityContextConstraints.users_path, [inc_user])
return True
|
'add a group'
| def add_group(self, inc_group):
| if self.groups:
self.groups.append(inc_group)
else:
self.put(SecurityContextConstraints.groups_path, [inc_group])
return True
|
'remove a user'
| def remove_user(self, inc_user):
| try:
self.users.remove(inc_user)
except ValueError as _:
return False
return True
|
'remove a group'
| def remove_group(self, inc_group):
| try:
self.groups.remove(inc_group)
except ValueError as _:
return False
return True
|
'update a user'
| def update_user(self, inc_user):
| try:
index = self.users.index(inc_user)
except ValueError as _:
return self.add_user(inc_user)
self.users[index] = inc_user
return True
|
'update a group'
| def update_group(self, inc_group):
| try:
index = self.groups.index(inc_group)
except ValueError as _:
return self.add_group(inc_group)
self.groups[index] = inc_group
return True
|
'find a user'
| def find_user(self, inc_user):
| index = None
try:
index = self.users.index(inc_user)
except ValueError as _:
return index
return index
|
'find a group'
| def find_group(self, inc_group):
| index = None
try:
index = self.groups.index(inc_group)
except ValueError as _:
return index
return index
|
'Constructor for deploymentconfig'
| def __init__(self, content=None):
| if (not content):
content = DeploymentConfig.default_deployment_config
super(DeploymentConfig, self).__init__(content=content)
|
'add key, value pair to env array'
| def add_env_value(self, key, value):
| rval = False
env = self.get_env_vars()
if env:
env.append({'name': key, 'value': value})
rval = True
else:
result = self.put(DeploymentConfig.env_path, {'name': key, 'value': value})
rval = result[0]
return rval
|
'return whether a key, value pair exists'
| def exists_env_value(self, key, value):
| results = self.get_env_vars()
if (not results):
return False
for result in results:
if ((result['name'] == key) and (result['value'] == value)):
return True
return False
|
'return whether a key, value pair exists'
| def exists_env_key(self, key):
| results = self.get_env_vars()
if (not results):
return False
for result in results:
if (result['name'] == key):
return True
return False
|
'return a environment variables'
| def get_env_var(self, key):
| results = (self.get(DeploymentConfig.env_path) or [])
if (not results):
return None
for env_var in results:
if (env_var['name'] == key):
return env_var
return None
|
'return a environment variables'
| def get_env_vars(self):
| return (self.get(DeploymentConfig.env_path) or [])
|
'delete a list of keys'
| def delete_env_var(self, keys):
| if (not isinstance(keys, list)):
keys = [keys]
env_vars_array = self.get_env_vars()
modified = False
idx = None
for key in keys:
for (env_idx, env_var) in enumerate(env_vars_array):
if (env_var['name'] == key):
idx = env_idx
break
i... |
'place an env in the env var list'
| def update_env_var(self, key, value):
| env_vars_array = self.get_env_vars()
idx = None
for (env_idx, env_var) in enumerate(env_vars_array):
if (env_var['name'] == key):
idx = env_idx
break
if idx:
env_vars_array[idx]['value'] = value
else:
self.add_env_value(key, value)
return True
|
'return whether a volume mount exists'
| def exists_volume_mount(self, volume_mount):
| exist_volume_mounts = self.get_volume_mounts()
if (not exist_volume_mounts):
return False
volume_mount_found = False
for exist_volume_mount in exist_volume_mounts:
if (exist_volume_mount['name'] == volume_mount['name']):
volume_mount_found = True
break
return ... |
'return whether a volume exists'
| def exists_volume(self, volume):
| exist_volumes = self.get_volumes()
volume_found = False
for exist_volume in exist_volumes:
if (exist_volume['name'] == volume['name']):
volume_found = True
break
return volume_found
|
'return the index of a volume'
| def find_volume_by_name(self, volume, mounts=False):
| volumes = []
if mounts:
volumes = self.get_volume_mounts()
else:
volumes = self.get_volumes()
for exist_volume in volumes:
if (exist_volume['name'] == volume['name']):
return exist_volume
return None
|
'return replicas setting'
| def get_replicas(self):
| return self.get(DeploymentConfig.replicas_path)
|
'return volume mount information'
| def get_volume_mounts(self):
| return self.get_volumes(mounts=True)
|
'return volume mount information'
| def get_volumes(self, mounts=False):
| if mounts:
return (self.get(DeploymentConfig.volume_mounts_path) or [])
return (self.get(DeploymentConfig.volumes_path) or [])
|
'delete a volume'
| def delete_volume_by_name(self, volume):
| modified = False
exist_volume_mounts = self.get_volume_mounts()
exist_volumes = self.get_volumes()
del_idx = None
for (idx, exist_volume) in enumerate(exist_volumes):
if (('name' in exist_volume) and (exist_volume['name'] == volume['name'])):
del_idx = idx
break
i... |
'add a volume or volume mount to the proper location'
| def add_volume_mount(self, volume_mount):
| exist_volume_mounts = self.get_volume_mounts()
if ((not exist_volume_mounts) and volume_mount):
self.put(DeploymentConfig.volume_mounts_path, [volume_mount])
else:
exist_volume_mounts.append(volume_mount)
|
'add a volume or volume mount to the proper location'
| def add_volume(self, volume):
| exist_volumes = self.get_volumes()
if (not volume):
return
if (not exist_volumes):
self.put(DeploymentConfig.volumes_path, [volume])
else:
exist_volumes.append(volume)
|
'update replicas value'
| def update_replicas(self, replicas):
| self.put(DeploymentConfig.replicas_path, replicas)
|
'place an env in the env var list'
| def update_volume(self, volume):
| exist_volumes = self.get_volumes()
if (not volume):
return False
update_idx = None
for (idx, exist_vol) in enumerate(exist_volumes):
if (exist_vol['name'] == volume['name']):
update_idx = idx
break
if (update_idx != None):
exist_volumes[update_idx] = v... |
'place an env in the env var list'
| def update_volume_mount(self, volume_mount):
| modified = False
exist_volume_mounts = self.get_volume_mounts()
if (not volume_mount):
return False
for exist_vol_mount in exist_volume_mounts:
if (exist_vol_mount['name'] == volume_mount['name']):
if (('mountPath' in exist_vol_mount) and (str(exist_vol_mount['mountPath']) !=... |
'verify a volume update is needed'
| def needs_update_volume(self, volume, volume_mount):
| exist_volume = self.find_volume_by_name(volume)
exist_volume_mount = self.find_volume_by_name(volume, mounts=True)
results = []
results.append((exist_volume['name'] == volume['name']))
if ('secret' in volume):
results.append(('secret' in exist_volume))
results.append((exist_volume['s... |
'verify whether a replica update is needed'
| def needs_update_replicas(self, replicas):
| current_reps = self.get(DeploymentConfig.replicas_path)
return (not (current_reps == replicas))
|
'return a properly structured volume'
| @staticmethod
def create_volume_structure(volume_info):
| volume_mount = None
volume = {'name': volume_info['name']}
volume_type = volume_info['type'].lower()
if (volume_type == 'secret'):
volume['secret'] = {}
volume[volume_info['type']] = {'secretName': volume_info['secret_name']}
volume_mount = {'mountPath': volume_info['path'], 'nam... |
'instantiate a properly structured volume'
| def create_dict(self):
| self.data['apiVersion'] = 'v1'
self.data['kind'] = 'ServiceAccount'
self.data['metadata'] = {}
self.data['metadata']['name'] = self.name
self.data['metadata']['namespace'] = self.namespace
self.data['secrets'] = []
if self.secrets:
for sec in self.secrets:
self.data['secr... |
'ServiceAccount constructor'
| def __init__(self, content):
| super(ServiceAccount, self).__init__(content=content)
self._secrets = None
self._image_pull_secrets = None
|
'property for image_pull_secrets'
| @property
def image_pull_secrets(self):
| if (self._image_pull_secrets is None):
self._image_pull_secrets = (self.get(ServiceAccount.image_pull_secrets_path) or [])
return self._image_pull_secrets
|
'property for secrets'
| @image_pull_secrets.setter
def image_pull_secrets(self, secrets):
| self._image_pull_secrets = secrets
|
'property for secrets'
| @property
def secrets(self):
| if (not self._secrets):
self._secrets = (self.get(ServiceAccount.secrets_path) or [])
return self._secrets
|
'property for secrets'
| @secrets.setter
def secrets(self, secrets):
| self._secrets = secrets
|
'remove a secret'
| def delete_secret(self, inc_secret):
| remove_idx = None
for (idx, sec) in enumerate(self.secrets):
if (sec['name'] == inc_secret):
remove_idx = idx
break
if remove_idx:
del self.secrets[remove_idx]
return True
return False
|
'remove a image_pull_secret'
| def delete_image_pull_secret(self, inc_secret):
| remove_idx = None
for (idx, sec) in enumerate(self.image_pull_secrets):
if (sec['name'] == inc_secret):
remove_idx = idx
break
if remove_idx:
del self.image_pull_secrets[remove_idx]
return True
return False
|
'find secret'
| def find_secret(self, inc_secret):
| for secret in self.secrets:
if (secret['name'] == inc_secret):
return secret
return None
|
'find secret'
| def find_image_pull_secret(self, inc_secret):
| for secret in self.image_pull_secrets:
if (secret['name'] == inc_secret):
return secret
return None
|
'add secret'
| def add_secret(self, inc_secret):
| if self.secrets:
self.secrets.append({'name': inc_secret})
else:
self.put(ServiceAccount.secrets_path, [{'name': inc_secret}])
|
'add image_pull_secret'
| def add_image_pull_secret(self, inc_secret):
| if self.image_pull_secrets:
self.image_pull_secrets.append({'name': inc_secret})
else:
self.put(ServiceAccount.image_pull_secrets_path, [{'name': inc_secret}])
|
'constructor for handling secret options'
| def __init__(self, sname, namespace, kubeconfig, secrets=None, stype=None):
| self.kubeconfig = kubeconfig
self.name = sname
self.type = stype
self.namespace = namespace
self.secrets = secrets
self.data = {}
self.create_dict()
|
'assign the correct properties for a secret dict'
| def create_dict(self):
| self.data['apiVersion'] = 'v1'
self.data['kind'] = 'Secret'
self.data['type'] = self.type
self.data['metadata'] = {}
self.data['metadata']['name'] = self.name
self.data['metadata']['namespace'] = self.namespace
self.data['data'] = {}
if self.secrets:
for (key, value) in self.secr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.