Skip to content

Commit 4e83cb7

Browse files
authored
Merge pull request #1695 from yliaog/automated-release-of-22.6.0b1-upstream-release-22.0-1644255027
Automated release of 22.6.0b1 upstream release 22.0 1644255027
2 parents f88c760 + 9ec2a3f commit 4e83cb7

16 files changed

+152
-131
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v22.6.0b1
2+
3+
Kubernetes API Version: v1.22.6
4+
5+
### Feature
6+
- Add `utils.create_from_directory` for creating all yaml files in a directory (#1683, @dingyiyi0226)
7+
18
# v22.6.0a1
29

310
Kubernetes API Version: v1.22.6

devel/release.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ are a higher than expected number of issues there can be multiple releases
1717

1818
## Automated release
1919

20-
### 1. (Optional) Update submodules
21-
22-
Update submodules by referring to this [link](https://github.com/kubernetes-client/python/blob/master/devel/submodules.md#update-submodule). Commit the changes and open a pull request.
23-
24-
### 2. Run the release script and send a PR
20+
### 1. Run the release script and send a PR
2521
Generate a Github personal access token following instruction
2622
[link](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
2723

@@ -49,11 +45,11 @@ $ KUBERNETES_BRANCH=release-1.${MINOR_VERSION} CLIENT_VERSION=${MINOR_VERSION}.$
4945
Checkout the generated local branch (named "automated-release-of-xxx") to
5046
continue with the remaining steps.
5147

52-
### 3. README (not required for snapshots)
48+
### 2. README (not required for snapshots)
5349

5450
Update the compatibility matrix and maintenance status in the README file.
5551

56-
### 4. Submit pull request
52+
### 3. Submit pull request
5753

5854
For snapshots, create a PR against the master repo.
5955

@@ -62,17 +58,13 @@ For actual releases, create:
6258
- a second PR against the master branch to cherrypick the CHANGELOG and README
6359
changes.
6460

65-
### 5. (Repo admin) Create release branch
61+
### 4. (Repo admin) Create release branch
6662

6763
After merging a new snapshot, create a release branch from the master branch.
6864

6965
## (Deprecated) Manual release
7066

71-
### 1. Update submodules
72-
73-
Update submodules by referring to this [link](https://github.com/kubernetes-client/python/blob/master/devel/submodules.md#update-submodule). Commit the changes and open a pull request.
74-
75-
### 2. Create or update release branch
67+
### 1. Create or update release branch
7668

7769
The release branch name should have release-x.x format. All minor and pre-releases
7870
should be on the same branch. To update an existing branch with master (only for
@@ -89,7 +81,7 @@ git pull -X theirs upstream master
8981
You may need to fix some conflicts. For auto-generated files, you can commit
9082
either version. They will be updated to the current version in the next step.
9183

92-
### 3. Update release tags
84+
### 2. Update release tags
9385

9486
Release tags are in the "scripts/constants.py" file. These are the constants you
9587
may need to update:
@@ -126,7 +118,7 @@ apply the manual fixes.***
126118
git push upstream $RELEASE_BRANCH
127119
```
128120

129-
### 4. Hot issues
121+
### 3. Hot issues
130122

131123
Use the `scripts/apply-hotfixes.sh` script to apply the fixes below in one step.
132124
**As mentioned above, the script should be run after finishing the section "Update release tags". Also, ensure a clean working directory before applying the script.**
@@ -152,15 +144,15 @@ For more details, see [#974](https://github.com/kubernetes-client/python/issues/
152144

153145
5. Add tests for the default `Configuration` behavior (ref: https://github.com/kubernetes-client/python/pull/1303 and https://github.com/kubernetes-client/python/pull/1285). The commit [1ffa61d0650e4c93e0d7f0becd2c54797eafd407](https://github.com/kubernetes-client/python/pull/1285/commits/1ffa61d0650e4c93e0d7f0becd2c54797eafd407) should be cherry-picked.
154146

155-
### 5. CHANGELOG
147+
### 4. CHANGELOG
156148

157149
Make sure the change logs are up to date [here](https://github.com/kubernetes-client/python/blob/master/CHANGELOG.md).
158150
If they are not, follow commits added after the last release and update/commit
159151
the change logs to master.
160152

161153
Then based on the release, follow one of next two steps.
162154

163-
### 6. README
155+
### 5. README
164156

165157
Update the compatibility matrix and maintenance status in the README file.
166158

devel/submodules.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

kubernetes/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
44
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
55

66
- API version: release-1.22
7-
- Package version: 22.6.0a1
7+
- Package version: 22.6.0b1
88
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
99

1010
## Requirements.

kubernetes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
__project__ = 'kubernetes'
1616
# The version is auto-updated. Please do not edit.
17-
__version__ = "22.6.0a1"
17+
__version__ = "22.6.0b1"
1818

1919
import kubernetes.client
2020
import kubernetes.config

kubernetes/client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import absolute_import
1616

17-
__version__ = "22.6.0a1"
17+
__version__ = "22.6.0b1"
1818

1919
# import apis into sdk package
2020
from kubernetes.client.api.well_known_api import WellKnownApi

kubernetes/client/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7878
self.default_headers[header_name] = header_value
7979
self.cookie = cookie
8080
# Set default User-Agent.
81-
self.user_agent = 'OpenAPI-Generator/22.6.0a1/python'
81+
self.user_agent = 'OpenAPI-Generator/22.6.0b1/python'
8282
self.client_side_validation = configuration.client_side_validation
8383

8484
def __enter__(self):

kubernetes/client/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def to_debug_report(self):
350350
"OS: {env}\n"\
351351
"Python Version: {pyversion}\n"\
352352
"Version of the API: release-1.22\n"\
353-
"SDK Package Version: 22.6.0a1".\
353+
"SDK Package Version: 22.6.0b1".\
354354
format(env=sys.platform, pyversion=sys.version)
355355

356356
def get_host_settings(self):

kubernetes/e2e_test/test_utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,28 @@ def test_create_implicit_service_list_from_yaml_with_conflict(self):
288288
core_api.delete_namespaced_service(name="mock-4",
289289
namespace="default", body={})
290290

291+
# Tests for creating multi-resource from directory
292+
293+
def test_create_multi_resource_from_directory(self):
294+
"""
295+
Should be able to create a service and a replication controller
296+
from a directory
297+
"""
298+
k8s_client = client.api_client.ApiClient(configuration=self.config)
299+
utils.create_from_directory(
300+
k8s_client, self.path_prefix + "multi-resource/")
301+
core_api = client.CoreV1Api(k8s_client)
302+
svc = core_api.read_namespaced_service(name="mock",
303+
namespace="default")
304+
self.assertIsNotNone(svc)
305+
ctr = core_api.read_namespaced_replication_controller(
306+
name="mock", namespace="default")
307+
self.assertIsNotNone(ctr)
308+
core_api.delete_namespaced_replication_controller(
309+
name="mock", namespace="default", propagation_policy="Background")
310+
core_api.delete_namespaced_service(name="mock",
311+
namespace="default", body={})
312+
291313
# Tests for multi-resource yaml objects
292314

293315
def test_create_from_multi_resource_yaml(self):
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: ReplicationController
3+
metadata:
4+
name: mock
5+
spec:
6+
replicas: 1
7+
selector:
8+
app: mock
9+
template:
10+
metadata:
11+
labels:
12+
app: mock
13+
spec:
14+
containers:
15+
- name: mock-container
16+
image: k8s.gcr.io/pause:2.0
17+
ports:
18+
- containerPort: 9949
19+
protocol: TCP
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mock
5+
labels:
6+
app: mock
7+
spec:
8+
ports:
9+
- port: 99
10+
protocol: TCP
11+
targetPort: 9949
12+
selector:
13+
app: mock

kubernetes/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
from __future__ import absolute_import
1616

1717
from .create_from_yaml import (FailToCreateError, create_from_dict,
18-
create_from_yaml)
18+
create_from_yaml, create_from_directory)
1919
from .quantity import parse_quantity

kubernetes/utils/create_from_yaml.py

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
import re
17-
from os import path
17+
import os
1818

1919
import yaml
2020

@@ -24,6 +24,76 @@
2424
LOWER_OR_NUM_FOLLOWED_BY_UPPER_RE = re.compile('([a-z0-9])([A-Z])')
2525

2626

27+
def create_from_directory(
28+
k8s_client,
29+
yaml_dir=None,
30+
verbose=False,
31+
namespace="default",
32+
**kwargs):
33+
"""
34+
Perform an action from files from a directory. Pass True for verbose to
35+
print confirmation information.
36+
37+
Input:
38+
k8s_client: an ApiClient object, initialized with the client args.
39+
yaml_dir: string. Contains the path to directory.
40+
verbose: If True, print confirmation from the create action.
41+
Default is False.
42+
namespace: string. Contains the namespace to create all
43+
resources inside. The namespace must preexist otherwise
44+
the resource creation will fail. If the API object in
45+
the yaml file already contains a namespace definition
46+
this parameter has no effect.
47+
48+
Available parameters for creating <kind>:
49+
:param async_req bool
50+
:param bool include_uninitialized: If true, partially initialized
51+
resources are included in the response.
52+
:param str pretty: If 'true', then the output is pretty printed.
53+
:param str dry_run: When present, indicates that modifications
54+
should not be persisted. An invalid or unrecognized dryRun
55+
directive will result in an error response and no further
56+
processing of the request.
57+
Valid values are: - All: all dry run stages will be processed
58+
59+
Returns:
60+
The list containing the created kubernetes API objects.
61+
62+
Raises:
63+
FailToCreateError which holds list of `client.rest.ApiException`
64+
instances for each object that failed to create.
65+
"""
66+
67+
if not yaml_dir:
68+
raise ValueError(
69+
'`yaml_dir` argument must be provided')
70+
elif not os.path.isdir(yaml_dir):
71+
raise ValueError(
72+
'`yaml_dir` argument must be a path to directory')
73+
74+
files = [os.path.join(yaml_dir, i) for i in os.listdir(yaml_dir)
75+
if os.path.isfile(os.path.join(yaml_dir, i))]
76+
if not files:
77+
raise ValueError(
78+
'`yaml_dir` contains no files')
79+
80+
failures = []
81+
k8s_objects_all = []
82+
83+
for file in files:
84+
try:
85+
k8s_objects = create_from_yaml(k8s_client, file,
86+
verbose=verbose,
87+
namespace=namespace,
88+
**kwargs)
89+
k8s_objects_all.append(k8s_objects)
90+
except FailToCreateError as failure:
91+
failures.extend(failure.api_exceptions)
92+
if failures:
93+
raise FailToCreateError(failures)
94+
return k8s_objects_all
95+
96+
2797
def create_from_yaml(
2898
k8s_client,
2999
yaml_file=None,
@@ -87,7 +157,7 @@ def create_with(objects):
87157
yml_document_all = yaml_objects
88158
return create_with(yml_document_all)
89159
elif yaml_file:
90-
with open(path.abspath(yaml_file)) as f:
160+
with open(os.path.abspath(yaml_file)) as f:
91161
yml_document_all = yaml.safe_load_all(f)
92162
return create_with(yml_document_all)
93163
else:

scripts/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
KUBERNETES_BRANCH = "release-1.22"
1919

2020
# client version for packaging and releasing.
21-
CLIENT_VERSION = "22.6.0a1"
21+
CLIENT_VERSION = "22.6.0b1"
2222

2323
# Name of the release package
2424
PACKAGE_NAME = "kubernetes"
2525

2626
# Stage of development, mainly used in setup.py's classifiers.
27-
DEVELOPMENT_STATUS = "3 - Alpha"
27+
DEVELOPMENT_STATUS = "4 - Beta"
2828

2929

3030
# If called directly, return the constant value given

0 commit comments

Comments
 (0)