-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}'") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
|
|
||
|
|
||
| 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def update_deployment(api_instance, deployment): | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def delete_deployment(api_instance): | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def main(): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
|
|
||
|
|
||
| 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def update_job(api_instance, job): | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def delete_job(api_instance): | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| def main(): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| v1 = client.CoreV1Api() | ||
| print("Listing pods with their IPs:") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| v1 = client.CoreV1Api() | ||
| print("Listing pods with their IPs:") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| pod_manifest = { | ||
| 'apiVersion': 'v1', | ||
| 'kind': 'Pod', | ||
|
|
@@ -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'] | ||
|
|
@@ -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() | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| ) | ||
| count -= 1 | ||
| if not count: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}"} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| # Create a ApiClient with our config | ||
| aApiClient = client.ApiClient(aConfiguration) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| """get_api_group # noqa: E501 | ||
|
|
||
| get information of a group # noqa: E501 | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
| """get_api_group # noqa: E501 | ||
|
|
||
| get information of a group # noqa: E501 | ||
|
|
@@ -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, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
84-93refactored with the following changes:replace-interpolation-with-fstring)