Skip to content

Commit

Permalink
Merge pull request #1695 from yliaog/automated-release-of-22.6.0b1-up…
Browse files Browse the repository at this point in the history
…stream-release-22.0-1644255027

Automated release of 22.6.0b1 upstream release 22.0 1644255027
  • Loading branch information
k8s-ci-robot committed Feb 8, 2022
2 parents f88c760 + 9ec2a3f commit 4e83cb7
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 131 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v22.6.0b1

Kubernetes API Version: v1.22.6

### Feature
- Add `utils.create_from_directory` for creating all yaml files in a directory (#1683, @dingyiyi0226)

# v22.6.0a1

Kubernetes API Version: v1.22.6
Expand Down
26 changes: 9 additions & 17 deletions devel/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ are a higher than expected number of issues there can be multiple releases

## Automated release

### 1. (Optional) Update submodules

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.

### 2. Run the release script and send a PR
### 1. Run the release script and send a PR
Generate a Github personal access token following instruction
[link](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)

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

### 3. README (not required for snapshots)
### 2. README (not required for snapshots)

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

### 4. Submit pull request
### 3. Submit pull request

For snapshots, create a PR against the master repo.

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

### 5. (Repo admin) Create release branch
### 4. (Repo admin) Create release branch

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

## (Deprecated) Manual release

### 1. Update submodules

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.

### 2. Create or update release branch
### 1. Create or update release branch

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

### 3. Update release tags
### 2. Update release tags

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

### 4. Hot issues
### 3. Hot issues

Use the `scripts/apply-hotfixes.sh` script to apply the fixes below in one step.
**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.**
Expand All @@ -152,15 +144,15 @@ For more details, see [#974](https://github.com/kubernetes-client/python/issues/

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.

### 5. CHANGELOG
### 4. CHANGELOG

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

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

### 6. README
### 5. README

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

Expand Down
29 changes: 0 additions & 29 deletions devel/submodules.md

This file was deleted.

2 changes: 1 addition & 1 deletion kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: release-1.22
- Package version: 22.6.0a1
- Package version: 22.6.0b1
- Build package: org.openapitools.codegen.languages.PythonClientCodegen

## Requirements.
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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

import kubernetes.client
import kubernetes.config
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import absolute_import

__version__ = "22.6.0a1"
__version__ = "22.6.0b1"

# import apis into sdk package
from kubernetes.client.api.well_known_api import WellKnownApi
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'OpenAPI-Generator/22.6.0a1/python'
self.user_agent = 'OpenAPI-Generator/22.6.0b1/python'
self.client_side_validation = configuration.client_side_validation

def __enter__(self):
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: release-1.22\n"\
"SDK Package Version: 22.6.0a1".\
"SDK Package Version: 22.6.0b1".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
22 changes: 22 additions & 0 deletions kubernetes/e2e_test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,28 @@ def test_create_implicit_service_list_from_yaml_with_conflict(self):
core_api.delete_namespaced_service(name="mock-4",
namespace="default", body={})

# Tests for creating multi-resource from directory

def test_create_multi_resource_from_directory(self):
"""
Should be able to create a service and a replication controller
from a directory
"""
k8s_client = client.api_client.ApiClient(configuration=self.config)
utils.create_from_directory(
k8s_client, self.path_prefix + "multi-resource/")
core_api = client.CoreV1Api(k8s_client)
svc = core_api.read_namespaced_service(name="mock",
namespace="default")
self.assertIsNotNone(svc)
ctr = core_api.read_namespaced_replication_controller(
name="mock", namespace="default")
self.assertIsNotNone(ctr)
core_api.delete_namespaced_replication_controller(
name="mock", namespace="default", propagation_policy="Background")
core_api.delete_namespaced_service(name="mock",
namespace="default", body={})

# Tests for multi-resource yaml objects

def test_create_from_multi_resource_yaml(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: mock
spec:
replicas: 1
selector:
app: mock
template:
metadata:
labels:
app: mock
spec:
containers:
- name: mock-container
image: k8s.gcr.io/pause:2.0
ports:
- containerPort: 9949
protocol: TCP
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: mock
labels:
app: mock
spec:
ports:
- port: 99
protocol: TCP
targetPort: 9949
selector:
app: mock
2 changes: 1 addition & 1 deletion kubernetes/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
from __future__ import absolute_import

from .create_from_yaml import (FailToCreateError, create_from_dict,
create_from_yaml)
create_from_yaml, create_from_directory)
from .quantity import parse_quantity
74 changes: 72 additions & 2 deletions kubernetes/utils/create_from_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


import re
from os import path
import os

import yaml

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


def create_from_directory(
k8s_client,
yaml_dir=None,
verbose=False,
namespace="default",
**kwargs):
"""
Perform an action from files from a directory. Pass True for verbose to
print confirmation information.
Input:
k8s_client: an ApiClient object, initialized with the client args.
yaml_dir: string. Contains the path to directory.
verbose: If True, print confirmation from the create action.
Default is False.
namespace: string. Contains the namespace to create all
resources inside. The namespace must preexist otherwise
the resource creation will fail. If the API object in
the yaml file already contains a namespace definition
this parameter has no effect.
Available parameters for creating <kind>:
:param async_req bool
:param bool include_uninitialized: If true, partially initialized
resources are included in the response.
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: When present, indicates that modifications
should not be persisted. An invalid or unrecognized dryRun
directive will result in an error response and no further
processing of the request.
Valid values are: - All: all dry run stages will be processed
Returns:
The list containing the created kubernetes API objects.
Raises:
FailToCreateError which holds list of `client.rest.ApiException`
instances for each object that failed to create.
"""

if not yaml_dir:
raise ValueError(
'`yaml_dir` argument must be provided')
elif not os.path.isdir(yaml_dir):
raise ValueError(
'`yaml_dir` argument must be a path to directory')

files = [os.path.join(yaml_dir, i) for i in os.listdir(yaml_dir)
if os.path.isfile(os.path.join(yaml_dir, i))]
if not files:
raise ValueError(
'`yaml_dir` contains no files')

failures = []
k8s_objects_all = []

for file in files:
try:
k8s_objects = create_from_yaml(k8s_client, file,
verbose=verbose,
namespace=namespace,
**kwargs)
k8s_objects_all.append(k8s_objects)
except FailToCreateError as failure:
failures.extend(failure.api_exceptions)
if failures:
raise FailToCreateError(failures)
return k8s_objects_all


def create_from_yaml(
k8s_client,
yaml_file=None,
Expand Down Expand Up @@ -87,7 +157,7 @@ def create_with(objects):
yml_document_all = yaml_objects
return create_with(yml_document_all)
elif yaml_file:
with open(path.abspath(yaml_file)) as f:
with open(os.path.abspath(yaml_file)) as f:
yml_document_all = yaml.safe_load_all(f)
return create_with(yml_document_all)
else:
Expand Down
4 changes: 2 additions & 2 deletions scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
KUBERNETES_BRANCH = "release-1.22"

# client version for packaging and releasing.
CLIENT_VERSION = "22.6.0a1"
CLIENT_VERSION = "22.6.0b1"

# Name of the release package
PACKAGE_NAME = "kubernetes"

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


# If called directly, return the constant value given
Expand Down
Loading

0 comments on commit 4e83cb7

Please sign in to comment.