Compare commits
21 Commits
master
...
release-22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44453c3eab | ||
|
|
770cbee8f6 | ||
|
|
16ec19d5a8 | ||
|
|
382484f3e6 | ||
|
|
c0b3d3ba8e | ||
|
|
115a9706d8 | ||
|
|
649c5fe59a | ||
|
|
386ff934f4 | ||
|
|
4e83cb78b5 | ||
|
|
9ec2a3f131 | ||
|
|
4cb1f87e91 | ||
|
|
85a258a4c3 | ||
|
|
87614465d5 | ||
|
|
0cac1054cb | ||
|
|
5535f09c84 | ||
|
|
f88c760f24 | ||
|
|
a7b34246c3 | ||
|
|
f9dfc11e52 | ||
|
|
dc191c11fe | ||
|
|
56309b93a0 | ||
|
|
873e8fd0d1 |
2
.github/workflows/e2e-master.yaml
vendored
2
.github/workflows/e2e-master.yaml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
# as we sync with Kubernetes upstream
|
# as we sync with Kubernetes upstream
|
||||||
config: .github/workflows/kind-configs/cluster-1.18.yaml
|
config: .github/workflows/kind-configs/cluster-1.18.yaml
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2.3.1
|
uses: actions/setup-python@v2.3.2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
2
.github/workflows/e2e-release-11.0.yaml
vendored
2
.github/workflows/e2e-release-11.0.yaml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
# as we sync with Kubernetes upstream
|
# as we sync with Kubernetes upstream
|
||||||
config: .github/workflows/kind-configs/cluster-1.15.yaml
|
config: .github/workflows/kind-configs/cluster-1.15.yaml
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2.3.1
|
uses: actions/setup-python@v2.3.2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
2
.github/workflows/e2e-release-12.0.yaml
vendored
2
.github/workflows/e2e-release-12.0.yaml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
# as we sync with Kubernetes upstream
|
# as we sync with Kubernetes upstream
|
||||||
config: .github/workflows/kind-configs/cluster-1.16.yaml
|
config: .github/workflows/kind-configs/cluster-1.16.yaml
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2.3.1
|
uses: actions/setup-python@v2.3.2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
2
.github/workflows/e2e-release-17.0.yaml
vendored
2
.github/workflows/e2e-release-17.0.yaml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
# as we sync with Kubernetes upstream
|
# as we sync with Kubernetes upstream
|
||||||
config: .github/workflows/kind-configs/cluster-1.17.yaml
|
config: .github/workflows/kind-configs/cluster-1.17.yaml
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2.3.1
|
uses: actions/setup-python@v2.3.2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
2
.github/workflows/e2e-release-18.0.yaml
vendored
2
.github/workflows/e2e-release-18.0.yaml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
# as we sync with Kubernetes upstream
|
# as we sync with Kubernetes upstream
|
||||||
config: .github/workflows/kind-configs/cluster-1.18.yaml
|
config: .github/workflows/kind-configs/cluster-1.18.yaml
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2.3.1
|
uses: actions/setup-python@v2.3.2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
23
.github/workflows/test.yaml
vendored
23
.github/workflows/test.yaml
vendored
@ -4,18 +4,20 @@ on: [ push, pull_request ]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
|
python-version: ["3.6", "3.7", "3.8", "3.10"]
|
||||||
|
include:
|
||||||
|
- python-version: "3.9"
|
||||||
|
use_coverage: 'coverage'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2.3.1
|
uses: actions/setup-python@v2.3.2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@ -31,5 +33,18 @@ jobs:
|
|||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
- name: Install Tox and any other packages
|
- name: Install Tox and any other packages
|
||||||
run: pip install tox
|
run: pip install tox
|
||||||
- name: Run Tox
|
|
||||||
|
- name: Test without coverage
|
||||||
|
if: "! matrix.use_coverage"
|
||||||
run: tox -e py # Run tox using the version of Python in `PATH`
|
run: tox -e py # Run tox using the version of Python in `PATH`
|
||||||
|
|
||||||
|
- name: Test with coverage
|
||||||
|
if: "matrix.use_coverage"
|
||||||
|
run: tox -e py-coverage
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
if: "matrix.use_coverage"
|
||||||
|
uses: codecov/codecov-action@v2
|
||||||
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
|||||||
21
CHANGELOG.md
21
CHANGELOG.md
@ -1,6 +1,23 @@
|
|||||||
# v22.0.0-snapshot
|
# v22.6.0
|
||||||
|
|
||||||
Kubernetes API Version: v1.22.5
|
Kubernetes API Version: v1.22.6
|
||||||
|
|
||||||
|
### Bug or Regression
|
||||||
|
- Notable feature additions for async creation of Custom resources using dynamic Client (#1697, @venukarnati92)
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
- Add `utils.create_from_directory` for creating all yaml files in a directory (#1683, @dingyiyi0226)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
### API Change
|
### API Change
|
||||||
- Kube-apiserver: Fixes handling of CRD schemas containing literal null values in enums (#104988, @liggitt) [SIG API Machinery, Apps and Network]
|
- Kube-apiserver: Fixes handling of CRD schemas containing literal null values in enums (#104988, @liggitt) [SIG API Machinery, Apps and Network]
|
||||||
|
|||||||
@ -91,6 +91,7 @@ supported versions of Kubernetes clusters.
|
|||||||
- [client 19.y.z](https://pypi.org/project/kubernetes/19.15.0/): Kubernetes 1.18 or below (+-), Kubernetes 1.19 (✓), Kubernetes 1.20 or above (+-)
|
- [client 19.y.z](https://pypi.org/project/kubernetes/19.15.0/): Kubernetes 1.18 or below (+-), Kubernetes 1.19 (✓), Kubernetes 1.20 or above (+-)
|
||||||
- [client 20.y.z](https://pypi.org/project/kubernetes/20.13.0/): Kubernetes 1.19 or below (+-), Kubernetes 1.20 (✓), Kubernetes 1.21 or above (+-)
|
- [client 20.y.z](https://pypi.org/project/kubernetes/20.13.0/): Kubernetes 1.19 or below (+-), Kubernetes 1.20 (✓), Kubernetes 1.21 or above (+-)
|
||||||
- [client 21.y.z](https://pypi.org/project/kubernetes/21.7.0/): Kubernetes 1.20 or below (+-), Kubernetes 1.21 (✓), Kubernetes 1.22 or above (+-)
|
- [client 21.y.z](https://pypi.org/project/kubernetes/21.7.0/): Kubernetes 1.20 or below (+-), Kubernetes 1.21 (✓), Kubernetes 1.22 or above (+-)
|
||||||
|
- [client 22.y.z](https://pypi.org/project/kubernetes/22.6.0/): Kubernetes 1.21 or below (+-), Kubernetes 1.22 (✓), Kubernetes 1.23 or above (+-)
|
||||||
|
|
||||||
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explanation of why there is no v13-v16 release.
|
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explanation of why there is no v13-v16 release.
|
||||||
|
|
||||||
@ -137,6 +138,8 @@ between client-python versions.
|
|||||||
| 20.0 | Kubernetes main repo, 1.20 branch | ✓ |
|
| 20.0 | Kubernetes main repo, 1.20 branch | ✓ |
|
||||||
| 21.0 Alpha/Beta | Kubernetes main repo, 1.21 branch | ✗ |
|
| 21.0 Alpha/Beta | Kubernetes main repo, 1.21 branch | ✗ |
|
||||||
| 21.0 | Kubernetes main repo, 1.21 branch | ✓ |
|
| 21.0 | Kubernetes main repo, 1.21 branch | ✓ |
|
||||||
|
| 22.0 Alpha/Beta | Kubernetes main repo, 1.22 branch | ✗ |
|
||||||
|
| 22.0 | Kubernetes main repo, 1.22 branch | ✓ |
|
||||||
|
|
||||||
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explanation of why there is no v13-v16 release.
|
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explanation of why there is no v13-v16 release.
|
||||||
|
|
||||||
|
|||||||
6
codecov.yml
Normal file
6
codecov.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# reference: https://docs.codecov.io/docs/codecovyml-reference
|
||||||
|
coverage:
|
||||||
|
status:
|
||||||
|
patch: true
|
||||||
|
project: false
|
||||||
|
comment: false
|
||||||
@ -17,11 +17,7 @@ are a higher than expected number of issues there can be multiple releases
|
|||||||
|
|
||||||
## Automated release
|
## Automated release
|
||||||
|
|
||||||
### 1. (Optional) Update submodules
|
### 1. Run the release script and send a PR
|
||||||
|
|
||||||
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
|
|
||||||
Generate a Github personal access token following instruction
|
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)
|
[link](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
|
||||||
|
|
||||||
@ -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
|
Checkout the generated local branch (named "automated-release-of-xxx") to
|
||||||
continue with the remaining steps.
|
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.
|
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.
|
For snapshots, create a PR against the master repo.
|
||||||
|
|
||||||
@ -62,17 +58,13 @@ For actual releases, create:
|
|||||||
- a second PR against the master branch to cherrypick the CHANGELOG and README
|
- a second PR against the master branch to cherrypick the CHANGELOG and README
|
||||||
changes.
|
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.
|
After merging a new snapshot, create a release branch from the master branch.
|
||||||
|
|
||||||
## (Deprecated) Manual release
|
## (Deprecated) Manual release
|
||||||
|
|
||||||
### 1. Update submodules
|
### 1. Create or update release branch
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
The release branch name should have release-x.x format. All minor and pre-releases
|
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
|
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
|
|||||||
You may need to fix some conflicts. For auto-generated files, you can commit
|
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.
|
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
|
Release tags are in the "scripts/constants.py" file. These are the constants you
|
||||||
may need to update:
|
may need to update:
|
||||||
@ -126,7 +118,7 @@ apply the manual fixes.***
|
|||||||
git push upstream $RELEASE_BRANCH
|
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.
|
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.**
|
**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,7 +144,7 @@ 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. 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).
|
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
|
If they are not, follow commits added after the last release and update/commit
|
||||||
@ -160,7 +152,7 @@ the change logs to master.
|
|||||||
|
|
||||||
Then based on the release, follow one of next two steps.
|
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.
|
Update the compatibility matrix and maintenance status in the README file.
|
||||||
|
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
# Submodules
|
|
||||||
|
|
||||||
To comply with [client library structure requirement](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/csi-client-structure-proposal.md),
|
|
||||||
python client base utilities is moved into the [kubernetes-client/python-base](https://github.com/kubernetes-client/python-base) repo. `git submodules` is being used to handle dependency to that repo.
|
|
||||||
This document will provide basic steps to get submodules working.
|
|
||||||
|
|
||||||
# Clone repo
|
|
||||||
|
|
||||||
To clone the repo, you need to pass the `recursive` parameter to make the clone also get submodules:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone --recursive https://github.com/kubernetes-client/python.git
|
|
||||||
```
|
|
||||||
|
|
||||||
if you have already cloned the repo with no `--recursive` option, you can run this command to get submodules:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git submodule update --init
|
|
||||||
```
|
|
||||||
|
|
||||||
# Update submodule
|
|
||||||
|
|
||||||
If you changed [kubernetes-client/python-base](https://github.com/kubernetes-client/python-base) and want to pull your changes into this repo run this command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scripts/update-submodule.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
After the script finishes, please create a commit "generated python-base update" and send a PR to this repository.
|
|
||||||
@ -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:
|
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||||
|
|
||||||
- API version: release-1.22
|
- API version: release-1.22
|
||||||
- Package version: 22.0.0-snapshot
|
- Package version: 22.6.0
|
||||||
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
|
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
|
||||||
|
|
||||||
## Requirements.
|
## Requirements.
|
||||||
@ -60,6 +60,8 @@ configuration.api_key['authorization'] = 'YOUR_API_KEY'
|
|||||||
# Defining host is optional and default to http://localhost
|
# Defining host is optional and default to http://localhost
|
||||||
configuration.host = "http://localhost"
|
configuration.host = "http://localhost"
|
||||||
|
|
||||||
|
# Defining host is optional and default to http://localhost
|
||||||
|
configuration.host = "http://localhost"
|
||||||
# Enter a context with an instance of the API kubernetes.client
|
# Enter a context with an instance of the API kubernetes.client
|
||||||
with kubernetes.client.ApiClient(configuration) as api_client:
|
with kubernetes.client.ApiClient(configuration) as api_client:
|
||||||
# Create an instance of the API class
|
# Create an instance of the API class
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
__project__ = 'kubernetes'
|
__project__ = 'kubernetes'
|
||||||
# The version is auto-updated. Please do not edit.
|
# The version is auto-updated. Please do not edit.
|
||||||
__version__ = "22.0.0-snapshot"
|
__version__ = "22.6.0"
|
||||||
|
|
||||||
import kubernetes.client
|
import kubernetes.client
|
||||||
import kubernetes.config
|
import kubernetes.config
|
||||||
|
|||||||
@ -267,7 +267,7 @@ class DynamicClient(object):
|
|||||||
# Authentication setting
|
# Authentication setting
|
||||||
auth_settings = ['BearerToken']
|
auth_settings = ['BearerToken']
|
||||||
|
|
||||||
return self.client.call_api(
|
api_response = self.client.call_api(
|
||||||
path,
|
path,
|
||||||
method.upper(),
|
method.upper(),
|
||||||
path_params,
|
path_params,
|
||||||
@ -281,6 +281,10 @@ class DynamicClient(object):
|
|||||||
_preload_content=False,
|
_preload_content=False,
|
||||||
_return_http_data_only=params.get('_return_http_data_only', True)
|
_return_http_data_only=params.get('_return_http_data_only', True)
|
||||||
)
|
)
|
||||||
|
if params.get('async_req'):
|
||||||
|
return api_response.get()
|
||||||
|
else:
|
||||||
|
return api_response
|
||||||
|
|
||||||
def validate(self, definition, version=None, strict=False):
|
def validate(self, definition, version=None, strict=False):
|
||||||
"""validate checks a kubernetes resource definition
|
"""validate checks a kubernetes resource definition
|
||||||
|
|||||||
@ -135,6 +135,121 @@ class TestDynamicClient(unittest.TestCase):
|
|||||||
changeme_api = client.resources.get(
|
changeme_api = client.resources.get(
|
||||||
api_version='apps.example.com/v1', kind='ClusterChangeMe')
|
api_version='apps.example.com/v1', kind='ClusterChangeMe')
|
||||||
|
|
||||||
|
def test_async_namespaced_custom_resources(self):
|
||||||
|
client = DynamicClient(api_client.ApiClient(configuration=self.config))
|
||||||
|
|
||||||
|
with self.assertRaises(ResourceNotFoundError):
|
||||||
|
changeme_api = client.resources.get(
|
||||||
|
api_version='apps.example.com/v1', kind='ChangeMe')
|
||||||
|
|
||||||
|
crd_api = client.resources.get(
|
||||||
|
api_version='apiextensions.k8s.io/v1beta1',
|
||||||
|
kind='CustomResourceDefinition')
|
||||||
|
|
||||||
|
name = 'changemes.apps.example.com'
|
||||||
|
|
||||||
|
crd_manifest = {
|
||||||
|
'apiVersion': 'apiextensions.k8s.io/v1beta1',
|
||||||
|
'kind': 'CustomResourceDefinition',
|
||||||
|
'metadata': {
|
||||||
|
'name': name,
|
||||||
|
},
|
||||||
|
'spec': {
|
||||||
|
'group': 'apps.example.com',
|
||||||
|
'names': {
|
||||||
|
'kind': 'ChangeMe',
|
||||||
|
'listKind': 'ChangeMeList',
|
||||||
|
'plural': 'changemes',
|
||||||
|
'singular': 'changeme',
|
||||||
|
},
|
||||||
|
'scope': 'Namespaced',
|
||||||
|
'version': 'v1',
|
||||||
|
'subresources': {
|
||||||
|
'status': {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async_resp = crd_api.create(crd_manifest, async_req=True)
|
||||||
|
|
||||||
|
self.assertEqual(name, async_resp.metadata.name)
|
||||||
|
self.assertTrue(async_resp.status)
|
||||||
|
|
||||||
|
async_resp = crd_api.get(
|
||||||
|
name=name,
|
||||||
|
async_req=True
|
||||||
|
)
|
||||||
|
self.assertEqual(name, async_resp.metadata.name)
|
||||||
|
self.assertTrue(async_resp.status)
|
||||||
|
|
||||||
|
try:
|
||||||
|
changeme_api = client.resources.get(
|
||||||
|
api_version='apps.example.com/v1', kind='ChangeMe')
|
||||||
|
except ResourceNotFoundError:
|
||||||
|
# Need to wait a sec for the discovery layer to get updated
|
||||||
|
time.sleep(2)
|
||||||
|
changeme_api = client.resources.get(
|
||||||
|
api_version='apps.example.com/v1', kind='ChangeMe')
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(async_req=True)
|
||||||
|
self.assertEqual(async_resp.items, [])
|
||||||
|
|
||||||
|
changeme_name = 'custom-resource' + short_uuid()
|
||||||
|
changeme_manifest = {
|
||||||
|
'apiVersion': 'apps.example.com/v1',
|
||||||
|
'kind': 'ChangeMe',
|
||||||
|
'metadata': {
|
||||||
|
'name': changeme_name,
|
||||||
|
},
|
||||||
|
'spec': {}
|
||||||
|
}
|
||||||
|
|
||||||
|
async_resp = changeme_api.create(body=changeme_manifest, namespace='default', async_req=True)
|
||||||
|
self.assertEqual(async_resp.metadata.name, changeme_name)
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(name=changeme_name, namespace='default', async_req=True)
|
||||||
|
self.assertEqual(async_resp.metadata.name, changeme_name)
|
||||||
|
|
||||||
|
changeme_manifest['spec']['size'] = 3
|
||||||
|
async_resp = changeme_api.patch(
|
||||||
|
body=changeme_manifest,
|
||||||
|
namespace='default',
|
||||||
|
content_type='application/merge-patch+json',
|
||||||
|
async_req=True
|
||||||
|
)
|
||||||
|
self.assertEqual(async_resp.spec.size, 3)
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(name=changeme_name, namespace='default', async_req=True)
|
||||||
|
self.assertEqual(async_resp.spec.size, 3)
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(namespace='default', async_req=True)
|
||||||
|
self.assertEqual(len(async_resp.items), 1)
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(async_req=True)
|
||||||
|
self.assertEqual(len(async_resp.items), 1)
|
||||||
|
|
||||||
|
async_resp = changeme_api.delete(
|
||||||
|
name=changeme_name,
|
||||||
|
namespace='default',
|
||||||
|
async_req=True
|
||||||
|
)
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(namespace='default', async_req=True)
|
||||||
|
self.assertEqual(len(async_resp.items), 0)
|
||||||
|
|
||||||
|
async_resp = changeme_api.get(async_req=True)
|
||||||
|
self.assertEqual(len(async_resp.items), 0)
|
||||||
|
|
||||||
|
async_resp = crd_api.delete(
|
||||||
|
name=name,
|
||||||
|
async_req=True
|
||||||
|
)
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
client.resources.invalidate_cache()
|
||||||
|
with self.assertRaises(ResourceNotFoundError):
|
||||||
|
changeme_api = client.resources.get(
|
||||||
|
api_version='apps.example.com/v1', kind='ChangeMe')
|
||||||
|
|
||||||
def test_namespaced_custom_resources(self):
|
def test_namespaced_custom_resources(self):
|
||||||
client = DynamicClient(api_client.ApiClient(configuration=self.config))
|
client = DynamicClient(api_client.ApiClient(configuration=self.config))
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
__version__ = "22.0.0-snapshot"
|
__version__ = "22.6.0"
|
||||||
|
|
||||||
# import apis into sdk package
|
# import apis into sdk package
|
||||||
from kubernetes.client.api.well_known_api import WellKnownApi
|
from kubernetes.client.api.well_known_api import WellKnownApi
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class ApiClient(object):
|
|||||||
self.default_headers[header_name] = header_value
|
self.default_headers[header_name] = header_value
|
||||||
self.cookie = cookie
|
self.cookie = cookie
|
||||||
# Set default User-Agent.
|
# Set default User-Agent.
|
||||||
self.user_agent = 'OpenAPI-Generator/22.0.0-snapshot/python'
|
self.user_agent = 'OpenAPI-Generator/22.6.0/python'
|
||||||
self.client_side_validation = configuration.client_side_validation
|
self.client_side_validation = configuration.client_side_validation
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
|||||||
@ -350,7 +350,7 @@ class Configuration(object):
|
|||||||
"OS: {env}\n"\
|
"OS: {env}\n"\
|
||||||
"Python Version: {pyversion}\n"\
|
"Python Version: {pyversion}\n"\
|
||||||
"Version of the API: release-1.22\n"\
|
"Version of the API: release-1.22\n"\
|
||||||
"SDK Package Version: 22.0.0-snapshot".\
|
"SDK Package Version: 22.6.0".\
|
||||||
format(env=sys.platform, pyversion=sys.version)
|
format(env=sys.platform, pyversion=sys.version)
|
||||||
|
|
||||||
def get_host_settings(self):
|
def get_host_settings(self):
|
||||||
|
|||||||
@ -288,6 +288,28 @@ class TestUtils(unittest.TestCase):
|
|||||||
core_api.delete_namespaced_service(name="mock-4",
|
core_api.delete_namespaced_service(name="mock-4",
|
||||||
namespace="default", body={})
|
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
|
# Tests for multi-resource yaml objects
|
||||||
|
|
||||||
def test_create_from_multi_resource_yaml(self):
|
def test_create_from_multi_resource_yaml(self):
|
||||||
|
|||||||
@ -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
|
||||||
@ -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
|
||||||
@ -15,5 +15,5 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from .create_from_yaml import (FailToCreateError, create_from_dict,
|
from .create_from_yaml import (FailToCreateError, create_from_dict,
|
||||||
create_from_yaml)
|
create_from_yaml, create_from_directory)
|
||||||
from .quantity import parse_quantity
|
from .quantity import parse_quantity
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from os import path
|
import os
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -24,6 +24,76 @@ UPPER_FOLLOWED_BY_LOWER_RE = re.compile('(.)([A-Z][a-z]+)')
|
|||||||
LOWER_OR_NUM_FOLLOWED_BY_UPPER_RE = re.compile('([a-z0-9])([A-Z])')
|
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(
|
def create_from_yaml(
|
||||||
k8s_client,
|
k8s_client,
|
||||||
yaml_file=None,
|
yaml_file=None,
|
||||||
@ -87,7 +157,7 @@ def create_from_yaml(
|
|||||||
yml_document_all = yaml_objects
|
yml_document_all = yaml_objects
|
||||||
return create_with(yml_document_all)
|
return create_with(yml_document_all)
|
||||||
elif yaml_file:
|
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)
|
yml_document_all = yaml.safe_load_all(f)
|
||||||
return create_with(yml_document_all)
|
return create_with(yml_document_all)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -18,13 +18,13 @@ import sys
|
|||||||
KUBERNETES_BRANCH = "release-1.22"
|
KUBERNETES_BRANCH = "release-1.22"
|
||||||
|
|
||||||
# client version for packaging and releasing.
|
# client version for packaging and releasing.
|
||||||
CLIENT_VERSION = "22.0.0-snapshot"
|
CLIENT_VERSION = "22.6.0"
|
||||||
|
|
||||||
# Name of the release package
|
# Name of the release package
|
||||||
PACKAGE_NAME = "kubernetes"
|
PACKAGE_NAME = "kubernetes"
|
||||||
|
|
||||||
# Stage of development, mainly used in setup.py's classifiers.
|
# Stage of development, mainly used in setup.py's classifiers.
|
||||||
DEVELOPMENT_STATUS = "3 - Alpha"
|
DEVELOPMENT_STATUS = "5 - Production/Stable"
|
||||||
|
|
||||||
|
|
||||||
# If called directly, return the constant value given
|
# If called directly, return the constant value given
|
||||||
|
|||||||
@ -1,73 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright 2021 The Kubernetes Authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
# Update python-base submodule and collect release notes.
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# $ scripts/update-submodule.sh
|
|
||||||
#
|
|
||||||
# # To update the release notes for a specific release (e.g. v18.17.0a1):
|
|
||||||
# $ TARGET_RELEASE="v18.17.0a1" scripts/update-submodule.sh
|
|
||||||
#
|
|
||||||
# After the script finishes, please create a commit "generated python-base update"
|
|
||||||
# and send a PR to this repository.
|
|
||||||
# TODO(roycaihw): make the script send a PR
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
|
|
||||||
repo_root="$(git rev-parse --show-toplevel)"
|
|
||||||
declare -r repo_root
|
|
||||||
cd "${repo_root}"
|
|
||||||
|
|
||||||
source scripts/util/changelog.sh
|
|
||||||
source scripts/util/common.sh
|
|
||||||
|
|
||||||
util::common::check_sed
|
|
||||||
go install k8s.io/release/cmd/release-notes@latest
|
|
||||||
|
|
||||||
TARGET_RELEASE=${TARGET_RELEASE:-"v$(grep "^CLIENT_VERSION = \"" scripts/constants.py | sed "s/CLIENT_VERSION = \"//g" | sed "s/\"//g")"}
|
|
||||||
|
|
||||||
# update submodule
|
|
||||||
git submodule update --remote
|
|
||||||
|
|
||||||
# download release notes
|
|
||||||
start_sha=$(git diff | grep "^-Subproject commit " | sed 's/-Subproject commit //g')
|
|
||||||
end_sha=$(git diff | grep "^+Subproject commit " | sed 's/+Subproject commit //g')
|
|
||||||
output="/tmp/python-base-relnote-$(date +%s).md"
|
|
||||||
release-notes --dependencies=false --org kubernetes-client --repo python-base --start-sha $start_sha --end-sha $end_sha --output $output
|
|
||||||
if [ -s $output ]; then
|
|
||||||
sed -i 's/(\[\#/(\[kubernetes-client\/python-base\#/g' $output
|
|
||||||
|
|
||||||
# update changelog
|
|
||||||
IFS_backup=$IFS
|
|
||||||
IFS=$'\n'
|
|
||||||
sections=($(grep "^### " $output))
|
|
||||||
IFS=$IFS_backup
|
|
||||||
for section in "${sections[@]}"; do
|
|
||||||
# ignore section titles and empty lines; replace newline with liternal "\n"
|
|
||||||
release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g')
|
|
||||||
util::changelog::write_changelog "$TARGET_RELEASE" "$section" "$release_notes"
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -f $output
|
|
||||||
echo "Successfully updated CHANGELOG for submodule."
|
|
||||||
else
|
|
||||||
echo "No CHANGELOG for submodule."
|
|
||||||
fi
|
|
||||||
4
setup.py
4
setup.py
@ -16,9 +16,9 @@ from setuptools import setup
|
|||||||
|
|
||||||
# Do not edit these constants. They will be updated automatically
|
# Do not edit these constants. They will be updated automatically
|
||||||
# by scripts/update-client.sh.
|
# by scripts/update-client.sh.
|
||||||
CLIENT_VERSION = "22.0.0-snapshot"
|
CLIENT_VERSION = "22.6.0"
|
||||||
PACKAGE_NAME = "kubernetes"
|
PACKAGE_NAME = "kubernetes"
|
||||||
DEVELOPMENT_STATUS = "3 - Alpha"
|
DEVELOPMENT_STATUS = "5 - Production/Stable"
|
||||||
|
|
||||||
# To install the library, run the following
|
# To install the library, run the following
|
||||||
#
|
#
|
||||||
|
|||||||
@ -9,7 +9,6 @@ mock>=2.0.0
|
|||||||
sphinx>=1.4 # BSD
|
sphinx>=1.4 # BSD
|
||||||
recommonmark
|
recommonmark
|
||||||
sphinx_markdown_tables
|
sphinx_markdown_tables
|
||||||
codecov>=1.4.0
|
|
||||||
pycodestyle
|
pycodestyle
|
||||||
autopep8
|
autopep8
|
||||||
isort
|
isort
|
||||||
|
|||||||
14
tox.ini
14
tox.ini
@ -11,8 +11,11 @@ deps = -r{toxinidir}/test-requirements.txt
|
|||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
commands =
|
commands =
|
||||||
python -V
|
python -V
|
||||||
!functional: pytest -vvv -s --ignore=kubernetes/e2e_test
|
!functional: pytest -vvv -s {env:_TOX_COVERAGE_RUN:} --ignore=kubernetes/e2e_test
|
||||||
functional: {toxinidir}/scripts/kube-init.sh pytest -vvv -s []
|
functional: {toxinidir}/scripts/kube-init.sh pytest -vvv -s []
|
||||||
|
coverage: python -m coverage xml
|
||||||
|
setenv =
|
||||||
|
coverage: _TOX_COVERAGE_RUN=--cov=kubernetes/watch --cov=kubernetes/config
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
commands =
|
commands =
|
||||||
@ -21,12 +24,3 @@ commands =
|
|||||||
[testenv:update-pycodestyle]
|
[testenv:update-pycodestyle]
|
||||||
commands =
|
commands =
|
||||||
{toxinidir}/scripts/update-pycodestyle.sh
|
{toxinidir}/scripts/update-pycodestyle.sh
|
||||||
|
|
||||||
[testenv:coverage]
|
|
||||||
commands =
|
|
||||||
python -V
|
|
||||||
pytest --cov=kubernetes/watch --cov=kubernetes/config kubernetes/watch kubernetes/config
|
|
||||||
|
|
||||||
[testenv:codecov]
|
|
||||||
commands =
|
|
||||||
codecov
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user