Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,19 @@
# html_static_path = ['static']

# Output file base name for HTML help builder.
htmlhelp_basename = '%sdoc' % project
htmlhelp_basename = f'{project}doc'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index',
'%s.tex' % project,
u'%s Documentation' % project,
u'Kubernetes', 'manual'),
(
'index',
f'{project}.tex',
f'{project} Documentation',
u'Kubernetes',
'manual',
)
Comment on lines -84 to +96
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 84-93 refactored with the following changes:

]

# Example configuration for intersphinx: refer to the Python standard library.
Expand Down
2 changes: 1 addition & 1 deletion examples/deployment_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def main():
k8s_apps_v1 = client.AppsV1Api()
resp = k8s_apps_v1.create_namespaced_deployment(
body=dep, namespace="default")
print("Deployment created. status='%s'" % resp.metadata.name)
print(f"Deployment created. status='{resp.metadata.name}'")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:



if __name__ == '__main__':
Expand Down
14 changes: 6 additions & 8 deletions examples/deployment_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@ def create_deployment_object():
replicas=3,
template=template,
selector={'matchLabels': {'app': 'nginx'}})
# Instantiate the deployment object
deployment = client.V1Deployment(
return client.V1Deployment(
api_version="apps/v1",
kind="Deployment",
metadata=client.V1ObjectMeta(name=DEPLOYMENT_NAME),
spec=spec)

return deployment
spec=spec,
)
Comment on lines -39 to +44
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_deployment_object refactored with the following changes:

This removes the following comments ( why? ):

# Instantiate the deployment object



def create_deployment(api_instance, deployment):
# Create deployement
api_response = api_instance.create_namespaced_deployment(
body=deployment,
namespace="default")
print("Deployment created. status='%s'" % str(api_response.status))
print(f"Deployment created. status='{str(api_response.status)}'")
Comment on lines -54 to +52
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_deployment refactored with the following changes:



def update_deployment(api_instance, deployment):
Expand All @@ -62,7 +60,7 @@ def update_deployment(api_instance, deployment):
name=DEPLOYMENT_NAME,
namespace="default",
body=deployment)
print("Deployment updated. status='%s'" % str(api_response.status))
print(f"Deployment updated. status='{str(api_response.status)}'")
Comment on lines -65 to +63
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function update_deployment refactored with the following changes:



def delete_deployment(api_instance):
Expand All @@ -73,7 +71,7 @@ def delete_deployment(api_instance):
body=client.V1DeleteOptions(
propagation_policy='Foreground',
grace_period_seconds=5))
print("Deployment deleted. status='%s'" % str(api_response.status))
print(f"Deployment deleted. status='{str(api_response.status)}'")
Comment on lines -76 to +74
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function delete_deployment refactored with the following changes:



def main():
Expand Down
14 changes: 6 additions & 8 deletions examples/job_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ def create_job_object():
spec = client.V1JobSpec(
template=template,
backoff_limit=4)
# Instantiate the job object
job = client.V1Job(
return client.V1Job(
api_version="batch/v1",
kind="Job",
metadata=client.V1ObjectMeta(name=JOB_NAME),
spec=spec)

return job
spec=spec,
)
Comment on lines -42 to +47
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_job_object refactored with the following changes:

This removes the following comments ( why? ):

# Instantiate the job object



def create_job(api_instance, job):
api_response = api_instance.create_namespaced_job(
body=job,
namespace="default")
print("Job created. status='%s'" % str(api_response.status))
print(f"Job created. status='{str(api_response.status)}'")
Comment on lines -56 to +54
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_job refactored with the following changes:



def update_job(api_instance, job):
Expand All @@ -63,7 +61,7 @@ def update_job(api_instance, job):
name=JOB_NAME,
namespace="default",
body=job)
print("Job updated. status='%s'" % str(api_response.status))
print(f"Job updated. status='{str(api_response.status)}'")
Comment on lines -66 to +64
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function update_job refactored with the following changes:



def delete_job(api_instance):
Expand All @@ -73,7 +71,7 @@ def delete_job(api_instance):
body=client.V1DeleteOptions(
propagation_policy='Foreground',
grace_period_seconds=5))
print("Job deleted. status='%s'" % str(api_response.status))
print(f"Job deleted. status='{str(api_response.status)}'")
Comment on lines -76 to +74
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function delete_job refactored with the following changes:



def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/pick_kube_config_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main():
# utility
config.load_kube_config(context=option)

print("Active host is %s" % configuration.Configuration().host)
print(f"Active host is {configuration.Configuration().host}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:


v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
Expand Down
2 changes: 1 addition & 1 deletion examples/pod_config_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
# utility
config.load_kube_config(context=option)

print("Active host is %s" % configuration.Configuration().host)
print(f"Active host is {configuration.Configuration().host}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:


v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
Expand Down
23 changes: 11 additions & 12 deletions examples/pod_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def exec_commands(api_instance):
namespace='default')
except ApiException as e:
if e.status != 404:
print("Unknown error: %s" % e)
print(f"Unknown error: {e}")
exit(1)

if not resp:
print("Pod %s does not exist. Creating it..." % name)
print(f"Pod {name} does not exist. Creating it...")
Comment on lines -36 to +40
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function exec_commands refactored with the following changes:

pod_manifest = {
'apiVersion': 'v1',
'kind': 'Pod',
Expand Down Expand Up @@ -77,7 +77,7 @@ def exec_commands(api_instance):
command=exec_command,
stderr=True, stdin=False,
stdout=True, tty=False)
print("Response: " + resp)
print(f"Response: {resp}")

# Calling exec interactively
exec_command = ['/bin/sh']
Expand All @@ -96,22 +96,21 @@ def exec_commands(api_instance):
while resp.is_open():
resp.update(timeout=1)
if resp.peek_stdout():
print("STDOUT: %s" % resp.read_stdout())
print(f"STDOUT: {resp.read_stdout()}")
if resp.peek_stderr():
print("STDERR: %s" % resp.read_stderr())
if commands:
c = commands.pop(0)
print("Running command... %s\n" % c)
resp.write_stdin(c + "\n")
else:
print(f"STDERR: {resp.read_stderr()}")
if not commands:
break

c = commands.pop(0)
print("Running command... %s\n" % c)
resp.write_stdin(c + "\n")
resp.write_stdin("date\n")
sdate = resp.readline_stdout(timeout=3)
print("Server date command returns: %s" % sdate)
print(f"Server date command returns: {sdate}")
resp.write_stdin("whoami\n")
user = resp.readline_stdout(timeout=3)
print("Server user is: %s" % user)
print(f"Server user is: {user}")
resp.close()


Expand Down
8 changes: 3 additions & 5 deletions examples/pod_namespace_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ def main():
count = 10
w = watch.Watch()
for event in w.stream(v1.list_namespace, timeout_seconds=10):
print("Event: %s %s" % (event['type'], event['object'].metadata.name))
print(f"Event: {event['type']} {event['object'].metadata.name}")
count -= 1
if not count:
w.stop()
print("Finished namespace stream.")

for event in w.stream(v1.list_pod_for_all_namespaces, timeout_seconds=10):
print("Event: %s %s %s" % (
event['type'],
event['object'].kind,
event['object'].metadata.name)
print(
f"Event: {event['type']} {event['object'].kind} {event['object'].metadata.name}"
Comment on lines -35 to +43
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

)
count -= 1
if not count:
Expand Down
2 changes: 1 addition & 1 deletion examples/remote_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main():
# ssl_ca_cert is the filepath to the file that contains the certificate.
# configuration.ssl_ca_cert="certificate"

aConfiguration.api_key = {"authorization": "Bearer " + aToken}
aConfiguration.api_key = {"authorization": f"Bearer {aToken}"}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:


# Create a ApiClient with our config
aApiClient = client.ApiClient(aConfiguration)
Expand Down
43 changes: 20 additions & 23 deletions kubernetes/client/api/admissionregistration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, api_client=None):
api_client = ApiClient()
self.api_client = api_client

def get_api_group(self, **kwargs): # noqa: E501
def get_api_group(self, **kwargs): # noqa: E501
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AdmissionregistrationApi.get_api_group refactored with the following changes:

"""get_api_group # noqa: E501

get information of a group # noqa: E501
Expand All @@ -47,13 +47,9 @@ def get_api_group(self, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_api_group_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_api_group_with_http_info(**kwargs) # noqa: E501
return data
return self.get_api_group_with_http_info(**kwargs) # noqa: E501

def get_api_group_with_http_info(self, **kwargs): # noqa: E501
def get_api_group_with_http_info(self, **kwargs): # noqa: E501
Comment on lines -56 to +52
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AdmissionregistrationApi.get_api_group_with_http_info refactored with the following changes:

This removes the following comments ( why? ):

# noqa: E501
# HTTP header `Accept`

"""get_api_group # noqa: E501

get information of a group # noqa: E501
Expand All @@ -70,40 +66,41 @@ def get_api_group_with_http_info(self, **kwargs): # noqa: E501

local_var_params = locals()

all_params = [] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

all_params = [
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout',
]
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_api_group" % key
f"Got an unexpected keyword argument '{key}' to method get_api_group"
)
local_var_params[key] = val
del local_var_params['kwargs']

collection_formats = {}

path_params = {}

query_params = []

header_params = {}

form_params = []
local_var_files = {}

body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json', 'application/yaml', 'application/vnd.kubernetes.protobuf']) # noqa: E501

header_params = {
'Accept': self.api_client.select_header_accept(
[
'application/json',
'application/yaml',
'application/vnd.kubernetes.protobuf',
]
)
}
# Authentication setting
auth_settings = ['BearerToken'] # noqa: E501

collection_formats = {}
return self.api_client.call_api(
'/apis/admissionregistration.k8s.io/', 'GET',
path_params,
Expand Down
Loading