Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15d36c9

Browse files
committed
Use optional parameter for method
1 parent 06776ce commit 15d36c9

File tree

3 files changed

+5
-62
lines changed

3 files changed

+5
-62
lines changed

kubernetes/e2e_test/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def test_create_namespaces_apps_deployment_from_yaml(self):
333333
Should be able to create an apps/v1beta1 deployment.
334334
"""
335335
k8s_client = client.api_client.ApiClient(configuration=self.config)
336-
utils.create_namespaced_from_yaml(
336+
utils.create_from_yaml(
337337
k8s_client, self.path_prefix + "apps-deployment.yaml", namespace=self.test_namespace)
338338
app_api = client.AppsV1beta1Api(k8s_client)
339339
dep = app_api.read_namespaced_deployment(name="nginx-app",
@@ -349,7 +349,7 @@ def test_create_from_list_in_multi_resource_yaml(self):
349349
specified in the multi-resource file
350350
"""
351351
k8s_client = client.api_client.ApiClient(configuration=self.config)
352-
utils.create_namespaced_from_yaml(
352+
utils.create_from_yaml(
353353
k8s_client, self.path_prefix + "multi-resource-with-list.yaml", namespace=self.test_namespace)
354354
core_api = client.CoreV1Api(k8s_client)
355355
app_api = client.AppsV1beta1Api(k8s_client)

kubernetes/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414

1515
from __future__ import absolute_import
1616

17-
from .create_from_yaml import (FailToCreateError, create_from_yaml,
18-
create_namespaced_from_yaml)
17+
from .create_from_yaml import FailToCreateError, create_from_yaml

kubernetes/utils/create_from_yaml.py

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,6 @@
2222

2323

2424
def create_from_yaml(
25-
k8s_client,
26-
yaml_file,
27-
verbose=False,
28-
**kwargs):
29-
"""
30-
Perform an action from a yaml file. Pass True for verbose to
31-
print confirmation information.
32-
Input:
33-
yaml_file: string. Contains the path to yaml file.
34-
k8s_client: an ApiClient object, initialized with the client args.
35-
verbose: If True, print confirmation from the create action.
36-
Default is False.
37-
38-
Returns:
39-
An k8s api object or list of apis objects created from YAML.
40-
When a single object is generated, return type is dependent
41-
on output_list.
42-
43-
Throws a FailToCreateError exception if creation of any object
44-
fails with helpful messages from the server.
45-
46-
Available parameters for creating <kind>:
47-
:param async_req bool
48-
:param bool include_uninitialized: If true, partially initialized
49-
resources are included in the response.
50-
:param str pretty: If 'true', then the output is pretty printed.
51-
:param str dry_run: When present, indicates that modifications
52-
should not be persisted. An invalid or unrecognized dryRun
53-
directive will result in an error response and no further
54-
processing of the request.
55-
Valid values are: - All: all dry run stages will be processed
56-
"""
57-
58-
create_namespaced_from_yaml(
59-
k8s_client,
60-
yaml_file,
61-
verbose,
62-
namespace="default",
63-
**kwargs
64-
)
65-
66-
67-
def create_namespaced_from_yaml(
6825
k8s_client,
6926
yaml_file,
7027
verbose=False,
@@ -118,14 +75,14 @@ def create_namespaced_from_yaml(
11875
yml_object["apiVersion"] = yml_document["apiVersion"]
11976
yml_object["kind"] = kind
12077
try:
121-
create_namespaced_from_yaml_single_item(
78+
create_from_yaml_single_item(
12279
k8s_client, yml_object, verbose, namespace, **kwargs)
12380
except client.rest.ApiException as api_exception:
12481
api_exceptions.append(api_exception)
12582
else:
12683
# This is a single object. Call the single item method
12784
try:
128-
create_namespaced_from_yaml_single_item(
85+
create_from_yaml_single_item(
12986
k8s_client, yml_document, verbose, namespace, **kwargs)
13087
except client.rest.ApiException as api_exception:
13188
api_exceptions.append(api_exception)
@@ -135,19 +92,6 @@ def create_namespaced_from_yaml(
13592

13693

13794
def create_from_yaml_single_item(
138-
k8s_client,
139-
yml_object,
140-
verbose=False,
141-
**kwargs):
142-
create_namespaced_from_yaml_single_item(
143-
k8s_client,
144-
yml_object,
145-
verbose,
146-
namespace="default",
147-
**kwargs)
148-
149-
150-
def create_namespaced_from_yaml_single_item(
15195
k8s_client,
15296
yml_object,
15397
verbose=False,

0 commit comments

Comments
 (0)