mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-12 12:32:05 +00:00
Compare commits
14 Commits
2.4.0
...
stable-2.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ec30da62f | ||
|
|
7103da38ff | ||
|
|
ed3969fc54 | ||
|
|
7e6c2cdd18 | ||
|
|
818f06f215 | ||
|
|
e9ae1fee21 | ||
|
|
c255d11c6e | ||
|
|
b01f78b0b7 | ||
|
|
d40f478552 | ||
|
|
bb45bb676f | ||
|
|
ea54179b23 | ||
|
|
9e41291489 | ||
|
|
15da427a34 | ||
|
|
0a6d3b604b |
7
.ansible-lint
Normal file
7
.ansible-lint
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
profile: production
|
||||||
|
skip_list:
|
||||||
|
- meta-runtime[unsupported-version]
|
||||||
|
exclude_paths:
|
||||||
|
- tests/integration
|
||||||
|
- tests/sanity
|
||||||
1
.github/stale.yml
vendored
1
.github/stale.yml
vendored
@@ -12,7 +12,6 @@ daysUntilClose: 30
|
|||||||
# Only issues or pull requests with all of these labels are check if stale.
|
# Only issues or pull requests with all of these labels are check if stale.
|
||||||
# Defaults to `[]` (disabled)
|
# Defaults to `[]` (disabled)
|
||||||
onlyLabels: []
|
onlyLabels: []
|
||||||
|
|
||||||
# Issues or Pull Requests with these labels will never be considered stale. Set
|
# Issues or Pull Requests with these labels will never be considered stale. Set
|
||||||
# to `[]` to disable
|
# to `[]` to disable
|
||||||
exemptLabels:
|
exemptLabels:
|
||||||
|
|||||||
21
.github/workflows/changelog.yaml
vendored
Normal file
21
.github/workflows/changelog.yaml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: Changelog
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
- labeled
|
||||||
|
- unlabeled
|
||||||
|
- synchronize
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changelog:
|
||||||
|
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
|
||||||
14
.github/workflows/galaxy-import.yaml
vendored
Normal file
14
.github/workflows/galaxy-import.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: galaxy-import
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.head_ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
galaxy_importer:
|
||||||
|
uses: ansible-network/github_actions/.github/workflows/galaxy_importer.yml@main
|
||||||
146
.github/workflows/integration-tests.yaml
vendored
Normal file
146
.github/workflows/integration-tests.yaml
vendored
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
name: Integration tests
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
- labeled
|
||||||
|
- unlabeled
|
||||||
|
- synchronize
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
splitter:
|
||||||
|
env:
|
||||||
|
source_dir: "./source"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
test_targets: ${{ steps.splitter.outputs.test_targets }}
|
||||||
|
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
|
||||||
|
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout the collection repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.source_dir }}
|
||||||
|
fetch-depth: "0"
|
||||||
|
|
||||||
|
- name: list changes for pull request
|
||||||
|
id: splitter
|
||||||
|
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main
|
||||||
|
with:
|
||||||
|
collections_to_test: ${{ env.source_dir }}
|
||||||
|
total_jobs: 8
|
||||||
|
|
||||||
|
- name: Display splitter output
|
||||||
|
run: |
|
||||||
|
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
|
||||||
|
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
|
||||||
|
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
|
||||||
|
shell: bash
|
||||||
|
integration:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
needs:
|
||||||
|
- splitter
|
||||||
|
if: ${{ needs.splitter.outputs.test_targets != '' }}
|
||||||
|
env:
|
||||||
|
source: "./source"
|
||||||
|
cloud_common: "./cloudcommon"
|
||||||
|
ansible_posix: "./ansible_posix"
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ansible-version:
|
||||||
|
- milestone
|
||||||
|
python-version:
|
||||||
|
- "3.12"
|
||||||
|
enable-turbo-mode:
|
||||||
|
- true
|
||||||
|
- false
|
||||||
|
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
|
||||||
|
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}"
|
||||||
|
steps:
|
||||||
|
- name: Read target
|
||||||
|
id: read-targets
|
||||||
|
run: |
|
||||||
|
import json, os
|
||||||
|
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
||||||
|
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
|
||||||
|
shell: python
|
||||||
|
env:
|
||||||
|
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }}
|
||||||
|
WORKFLOW_ID: ${{ matrix.workflow-id }}
|
||||||
|
|
||||||
|
- name: Display ansible test targets
|
||||||
|
run: |
|
||||||
|
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}"
|
||||||
|
|
||||||
|
- name: Checkout kubernetes.core repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.source }}
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
# install ansible
|
||||||
|
- name: Install ansible-core (${{ matrix.ansible-version }})
|
||||||
|
run: >-
|
||||||
|
python3 -m pip install
|
||||||
|
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz
|
||||||
|
--disable-pip-version-check
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Build and install collection
|
||||||
|
id: install-src
|
||||||
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||||
|
with:
|
||||||
|
install_python_dependencies: true
|
||||||
|
source_path: ${{ env.source }}
|
||||||
|
|
||||||
|
- name: checkout ansible-collections/cloud.common
|
||||||
|
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
||||||
|
with:
|
||||||
|
repository: ansible-collections/cloud.common
|
||||||
|
path: ${{ env.cloud_common }}
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: checkout ansible-collections/ansible.posix
|
||||||
|
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
||||||
|
with:
|
||||||
|
repository: ansible-collections/ansible.posix
|
||||||
|
path: ${{ env.ansible_posix }}
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: install cloud.common collection
|
||||||
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||||
|
with:
|
||||||
|
install_python_dependencies: true
|
||||||
|
source_path: ${{ env.cloud_common }}
|
||||||
|
|
||||||
|
- name: install ansible.posix collection
|
||||||
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||||
|
with:
|
||||||
|
install_python_dependencies: true
|
||||||
|
source_path: ${{ env.ansible_posix }}
|
||||||
|
|
||||||
|
- name: create kubernetes cluster
|
||||||
|
uses: helm/kind-action@v1.8.0
|
||||||
|
with:
|
||||||
|
node_image: "kindest/node:v1.29.2"
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
|
||||||
|
with:
|
||||||
|
collection_path: ${{ steps.install-src.outputs.collection_path }}
|
||||||
|
python_version: ${{ matrix.python-version }}
|
||||||
|
ansible_version: ${{ matrix.ansible-version }}
|
||||||
|
ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }}
|
||||||
|
ansible_test_environment: |
|
||||||
|
ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }}
|
||||||
24
.github/workflows/linters.yaml
vendored
Normal file
24
.github/workflows/linters.yaml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: Linters
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linters:
|
||||||
|
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main
|
||||||
|
ansible-lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Run ansible-lint
|
||||||
|
uses: ansible/ansible-lint@v6.21.0
|
||||||
15
.github/workflows/sanity-tests.yaml
vendored
Normal file
15
.github/workflows/sanity-tests.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
name: Sanity tests
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sanity:
|
||||||
|
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
|
||||||
15
.github/workflows/unit-tests.yaml
vendored
Normal file
15
.github/workflows/unit-tests.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
name: Unit tests
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
unit-source:
|
||||||
|
uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main
|
||||||
@@ -4,6 +4,26 @@ Kubernetes Collection Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v2.4.2
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
fix resource discovery when complex subresources present
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Resolve Collections util resource discovery fails when complex subresources present (https://github.com/ansible-collections/kubernetes.core/pull/676).
|
||||||
|
|
||||||
|
v2.4.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The kubernetes.core 2.4.1 release includes several trivial bug fixes related to code sanity.
|
||||||
|
|
||||||
v2.4.0
|
v2.4.0
|
||||||
======
|
======
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
|||||||
# Also needs to be updated in galaxy.yml
|
# Also needs to be updated in galaxy.yml
|
||||||
VERSION = 2.4.0
|
VERSION = 2.4.1
|
||||||
|
|
||||||
TEST_ARGS ?= ""
|
TEST_ARGS ?= ""
|
||||||
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ You can also include it in a `requirements.yml` file and install it via `ansible
|
|||||||
---
|
---
|
||||||
collections:
|
collections:
|
||||||
- name: kubernetes.core
|
- name: kubernetes.core
|
||||||
version: 2.4.0
|
version: 2.4.1
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing the Kubernetes Python Library
|
### Installing the Kubernetes Python Library
|
||||||
|
|||||||
@@ -762,3 +762,20 @@ releases:
|
|||||||
name: helm_pull
|
name: helm_pull
|
||||||
namespace: ''
|
namespace: ''
|
||||||
release_date: '2023-01-24'
|
release_date: '2023-01-24'
|
||||||
|
2.4.1:
|
||||||
|
changes:
|
||||||
|
release_summary: The kubernetes.core 2.4.1 release includes several trivial
|
||||||
|
bug fixes related to sanity.
|
||||||
|
fragments:
|
||||||
|
- fix_sanity_errors.yml
|
||||||
|
release_date: '2024-02-06'
|
||||||
|
2.4.2:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Resolve Collections util resource discovery fails when complex subresources
|
||||||
|
present (https://github.com/ansible-collections/kubernetes.core/pull/676).
|
||||||
|
release_summary: fix resource discovery when complex subresources present
|
||||||
|
fragments:
|
||||||
|
- 2.4.2.yml
|
||||||
|
- 20240222-Collections-util-resource-discovery-fails-when-complex-subresources-present.yml
|
||||||
|
release_date: '2024-03-01'
|
||||||
|
|||||||
@@ -10,21 +10,21 @@ notesdir: fragments
|
|||||||
prelude_section_name: release_summary
|
prelude_section_name: release_summary
|
||||||
prelude_section_title: Release Summary
|
prelude_section_title: Release Summary
|
||||||
sections:
|
sections:
|
||||||
- - major_changes
|
- - major_changes
|
||||||
- Major Changes
|
- Major Changes
|
||||||
- - minor_changes
|
- - minor_changes
|
||||||
- Minor Changes
|
- Minor Changes
|
||||||
- - breaking_changes
|
- - breaking_changes
|
||||||
- Breaking Changes / Porting Guide
|
- Breaking Changes / Porting Guide
|
||||||
- - deprecated_features
|
- - deprecated_features
|
||||||
- Deprecated Features
|
- Deprecated Features
|
||||||
- - removed_features
|
- - removed_features
|
||||||
- Removed Features (previously deprecated)
|
- Removed Features (previously deprecated)
|
||||||
- - security_fixes
|
- - security_fixes
|
||||||
- Security Fixes
|
- Security Fixes
|
||||||
- - bugfixes
|
- - bugfixes
|
||||||
- Bugfixes
|
- Bugfixes
|
||||||
- - known_issues
|
- - known_issues
|
||||||
- Known Issues
|
- Known Issues
|
||||||
title: Kubernetes Collection
|
title: Kubernetes Collection
|
||||||
trivial_section_name: trivial
|
trivial_section_name: trivial
|
||||||
|
|||||||
3
changelogs/fragments/654-helm-expand-user.yml
Normal file
3
changelogs/fragments/654-helm-expand-user.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- helm - expand kubeconfig path with user's home directory for consistency with k8s
|
||||||
@@ -9,8 +9,8 @@ authors:
|
|||||||
- mmazur (https://github.com/mmazur)
|
- mmazur (https://github.com/mmazur)
|
||||||
- jamescassell (https://github.com/jamescassell)
|
- jamescassell (https://github.com/jamescassell)
|
||||||
description: Kubernetes Collection for Ansible.
|
description: Kubernetes Collection for Ansible.
|
||||||
documentation: ''
|
documentation: ""
|
||||||
homepage: ''
|
homepage: ""
|
||||||
issues: https://github.com/ansible-collections/kubernetes.core/issues
|
issues: https://github.com/ansible-collections/kubernetes.core/issues
|
||||||
license_file: LICENSE
|
license_file: LICENSE
|
||||||
namespace: kubernetes
|
namespace: kubernetes
|
||||||
@@ -25,7 +25,7 @@ tags:
|
|||||||
- openshift
|
- openshift
|
||||||
- okd
|
- okd
|
||||||
- cluster
|
- cluster
|
||||||
version: 2.4.0
|
version: 2.4.1
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- .DS_Store
|
- .DS_Store
|
||||||
- '*.tar.gz'
|
- "*.tar.gz"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
requires_ansible: '>=2.9.17'
|
requires_ansible: ">=2.9.17"
|
||||||
|
|
||||||
action_groups:
|
action_groups:
|
||||||
helm:
|
helm:
|
||||||
@@ -29,18 +29,18 @@ plugin_routing:
|
|||||||
warning_text: Use kubernetes.core.k8s_info instead.
|
warning_text: Use kubernetes.core.k8s_info instead.
|
||||||
k8s_raw:
|
k8s_raw:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: 0.1.0
|
removal_version: "0.1.0"
|
||||||
warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||||
openshift_raw:
|
openshift_raw:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: 0.1.0
|
removal_version: "0.1.0"
|
||||||
warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||||
openshift_scale:
|
openshift_scale:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: 0.1.0
|
removal_version: "0.1.0"
|
||||||
warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead.
|
warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead.
|
||||||
lookup:
|
lookup:
|
||||||
openshift:
|
openshift:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: 0.1.0
|
removal_version: "0.1.0"
|
||||||
warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||||
|
|||||||
@@ -1,12 +1,50 @@
|
|||||||
# Copyright (c) 2017 Ansible Project
|
# Copyright (c) 2017 Ansible Project
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
|
||||||
|
name: k8s_config_resource_name
|
||||||
|
short_description: Generate resource name for the given resource of type ConfigMap, Secret
|
||||||
|
description:
|
||||||
|
- Generate resource name for the given resource of type ConfigMap, Secret.
|
||||||
|
- Resource must have a C(metadata.name) key to generate a resource name
|
||||||
|
options:
|
||||||
|
_input:
|
||||||
|
description:
|
||||||
|
- A valid YAML definition for a ConfigMap or a Secret.
|
||||||
|
type: dict
|
||||||
|
required: true
|
||||||
|
author:
|
||||||
|
- ansible cloud team
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
# Dump generated name for a configmap into a variable
|
||||||
|
- set_fact:
|
||||||
|
generated_name: '{{ definition | kubernetes.core.k8s_config_resource_name }}'
|
||||||
|
vars:
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: myconfigmap
|
||||||
|
namespace: mynamespace
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
_value:
|
||||||
|
description: Generated resource name.
|
||||||
|
type: str
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
from ansible.errors import AnsibleFilterError
|
from ansible.errors import AnsibleFilterError
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
||||||
generate_hash,
|
generate_hash,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ DOCUMENTATION = """
|
|||||||
connections:
|
connections:
|
||||||
description:
|
description:
|
||||||
- Optional list of cluster connection settings. If no connections are provided, the default
|
- Optional list of cluster connection settings. If no connections are provided, the default
|
||||||
I(~/.kube/config) and active context will be used, and objects will be returned for all namespaces
|
'~/.kube/config' and active context will be used, and objects will be returned for all namespaces
|
||||||
the active user is authorized to access.
|
the active user is authorized to access.
|
||||||
suboptions:
|
suboptions:
|
||||||
name:
|
name:
|
||||||
@@ -38,7 +38,7 @@ DOCUMENTATION = """
|
|||||||
description:
|
description:
|
||||||
- Path to an existing Kubernetes config file. If not provided, and no other connection
|
- Path to an existing Kubernetes config file. If not provided, and no other connection
|
||||||
options are provided, the Kubernetes client will attempt to load the default
|
options are provided, the Kubernetes client will attempt to load the default
|
||||||
configuration file from I(~/.kube/config). Can also be specified via K8S_AUTH_KUBECONFIG
|
configuration file from '~/.kube/config'. Can also be specified via K8S_AUTH_KUBECONFIG
|
||||||
environment variable.
|
environment variable.
|
||||||
context:
|
context:
|
||||||
description:
|
description:
|
||||||
@@ -94,22 +94,22 @@ DOCUMENTATION = """
|
|||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
# File must be named k8s.yaml or k8s.yml
|
# File must be named k8s.yaml or k8s.yml
|
||||||
|
|
||||||
# Authenticate with token, and return all pods and services for all namespaces
|
- name: Authenticate with token, and return all pods and services for all namespaces
|
||||||
plugin: kubernetes.core.k8s
|
plugin: kubernetes.core.k8s
|
||||||
connections:
|
connections:
|
||||||
- host: https://192.168.64.4:8443
|
- host: https://192.168.64.4:8443
|
||||||
api_key: xxxxxxxxxxxxxxxx
|
api_key: xxxxxxxxxxxxxxxx
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
||||||
# Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
||||||
plugin: kubernetes.core.k8s
|
plugin: kubernetes.core.k8s
|
||||||
connections:
|
connections:
|
||||||
- namespaces:
|
- namespaces:
|
||||||
- testing
|
- testing
|
||||||
|
|
||||||
# Use a custom config file, and a specific context.
|
- name: Use a custom config file, and a specific context.
|
||||||
plugin: kubernetes.core.k8s
|
plugin: kubernetes.core.k8s
|
||||||
connections:
|
connections:
|
||||||
- kubeconfig: /path/to/config
|
- kubeconfig: /path/to/config
|
||||||
context: 'awx/192-168-64-4:8443/developer'
|
context: 'awx/192-168-64-4:8443/developer'
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
|||||||
filter(lambda resource: "/" in resource["name"], resources_response)
|
filter(lambda resource: "/" in resource["name"], resources_response)
|
||||||
)
|
)
|
||||||
for subresource in subresources_raw:
|
for subresource in subresources_raw:
|
||||||
resource, name = subresource["name"].split("/")
|
resource, name = subresource["name"].split("/", 1)
|
||||||
subresources[resource][name] = subresource
|
subresources[resource][name] = subresource
|
||||||
|
|
||||||
for resource in resources_raw:
|
for resource in resources_raw:
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class AnsibleHelmModule(object):
|
|||||||
kubeconfig = self.params.get("kubeconfig")
|
kubeconfig = self.params.get("kubeconfig")
|
||||||
if kubeconfig:
|
if kubeconfig:
|
||||||
if isinstance(kubeconfig, string_types):
|
if isinstance(kubeconfig, string_types):
|
||||||
with open(kubeconfig) as fd:
|
with open(os.path.expanduser(kubeconfig)) as fd:
|
||||||
kubeconfig_content = yaml.safe_load(fd)
|
kubeconfig_content = yaml.safe_load(fd)
|
||||||
elif isinstance(kubeconfig, dict):
|
elif isinstance(kubeconfig, dict):
|
||||||
kubeconfig_content = kubeconfig
|
kubeconfig_content = kubeconfig
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ options:
|
|||||||
- If set to C(uninstalling), show releases that are currently being uninstalled.
|
- If set to C(uninstalling), show releases that are currently being uninstalled.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
version_added: "2.3.0"
|
version_added: "2.3.0"
|
||||||
get_all_values:
|
get_all_values:
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ options:
|
|||||||
required: false
|
required: false
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
version_added: 2.4.0
|
version_added: 2.4.0
|
||||||
values_files:
|
values_files:
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Specify options to delete pods.
|
- Specify options to delete pods.
|
||||||
- This option has effect only when C(state) is set to I(drain).
|
- This option has effect only when C(state) is set to I(drain).
|
||||||
|
default: {}
|
||||||
suboptions:
|
suboptions:
|
||||||
terminate_grace_period:
|
terminate_grace_period:
|
||||||
description:
|
description:
|
||||||
@@ -114,7 +115,6 @@ EXAMPLES = r"""
|
|||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
state: cordon
|
state: cordon
|
||||||
name: foo
|
name: foo
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
|
|||||||
@@ -38,10 +38,12 @@ options:
|
|||||||
description: List of label selectors to use to filter results
|
description: List of label selectors to use to filter results
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
field_selectors:
|
field_selectors:
|
||||||
description: List of field selectors to use to filter results
|
description: List of field selectors to use to filter results
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ options:
|
|||||||
- Only one of I(name) or I(label_selectors) may be provided.
|
- Only one of I(name) or I(label_selectors) may be provided.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
container:
|
container:
|
||||||
description:
|
description:
|
||||||
- Use to specify the container within a pod to grab the log from.
|
- Use to specify the container within a pod to grab the log from.
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ options:
|
|||||||
description: List of label selectors to use to filter results.
|
description: List of label selectors to use to filter results.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
field_selectors:
|
field_selectors:
|
||||||
description: List of field selectors to use to filter results.
|
description: List of field selectors to use to filter results.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
- kubernetes.core.k8s_name_options
|
- kubernetes.core.k8s_name_options
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ options:
|
|||||||
description: List of label selectors to use to filter results.
|
description: List of label selectors to use to filter results.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
default: []
|
||||||
version_added: 2.0.0
|
version_added: 2.0.0
|
||||||
continue_on_error:
|
continue_on_error:
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ pytest
|
|||||||
pytest-xdist
|
pytest-xdist
|
||||||
pytest-mock
|
pytest-mock
|
||||||
pytest-forked
|
pytest-forked
|
||||||
|
virtualenv
|
||||||
|
pytest-ansible
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: Test helm with in-memory kubeconfig
|
- name: Test helm with in-memory kubeconfig
|
||||||
include_tasks: "from_in_memory_kubeconfig.yml"
|
include_tasks: "from_in_memory_kubeconfig.yml"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_helm_version
|
||||||
|
with_items:
|
||||||
|
- "v3.10.3"
|
||||||
|
|
||||||
- name: Test helm with custom kubeconfig and validate_certs=false
|
- name: Test helm with custom kubeconfig and validate_certs=false
|
||||||
include_tasks: "from_kubeconfig_with_validate_certs.yml"
|
include_tasks: "from_kubeconfig_with_validate_certs.yml"
|
||||||
@@ -8,12 +12,10 @@
|
|||||||
loop_var: test_helm_version
|
loop_var: test_helm_version
|
||||||
with_items:
|
with_items:
|
||||||
- "v3.10.3"
|
- "v3.10.3"
|
||||||
- "v3.8.2"
|
|
||||||
|
|
||||||
- name: Test helm with custom kubeconfig and ca_cert
|
- name: Test helm with custom kubeconfig and ca_cert
|
||||||
include_tasks: "from_kubeconfig_with_cacert.yml"
|
include_tasks: "from_kubeconfig_with_cacert.yml"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_helm_version
|
loop_var: test_helm_version
|
||||||
with_items:
|
with_items:
|
||||||
- "v3.5.1"
|
- "v3.10.3"
|
||||||
- "v3.4.2"
|
|
||||||
|
|||||||
32
tests/integration/targets/k8s_info/tasks/discovery.yml
Normal file
32
tests/integration/targets/k8s_info/tasks/discovery.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
# Testing fix for issue https://github.com/ansible-collections/kubernetes.core/pull/676
|
||||||
|
- vars:
|
||||||
|
kubevirt_release: "v1.1.1"
|
||||||
|
block:
|
||||||
|
- name: Delete existing namespace
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
kind: namespace
|
||||||
|
namespace: kubevirt
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create kubevirt resources
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
state: present
|
||||||
|
apply: true
|
||||||
|
src: "{{ item }}"
|
||||||
|
with_items:
|
||||||
|
- "https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_release }}/kubevirt-operator.yaml"
|
||||||
|
- "https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_release }}/kubevirt-cr.yaml"
|
||||||
|
|
||||||
|
- name: Read kubevirt Deployment
|
||||||
|
k8s_info:
|
||||||
|
kind: Deployment
|
||||||
|
namespace: kubevirt
|
||||||
|
always:
|
||||||
|
- name: Delete existing namespace
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
kind: namespace
|
||||||
|
namespace: kubevirt
|
||||||
|
state: absent
|
||||||
|
wait: true
|
||||||
|
ignore_errors: true
|
||||||
@@ -3,3 +3,4 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- wait
|
- wait
|
||||||
- api-server-caching
|
- api-server-caching
|
||||||
|
- discovery
|
||||||
|
|||||||
@@ -3,16 +3,19 @@ plugins/module_utils/client/discovery.py import-3.7!skip
|
|||||||
plugins/module_utils/client/discovery.py import-3.8!skip
|
plugins/module_utils/client/discovery.py import-3.8!skip
|
||||||
plugins/module_utils/client/discovery.py import-3.9!skip
|
plugins/module_utils/client/discovery.py import-3.9!skip
|
||||||
plugins/module_utils/client/discovery.py import-3.10!skip
|
plugins/module_utils/client/discovery.py import-3.10!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.11!skip
|
||||||
plugins/module_utils/client/resource.py import-3.6!skip
|
plugins/module_utils/client/resource.py import-3.6!skip
|
||||||
plugins/module_utils/client/resource.py import-3.7!skip
|
plugins/module_utils/client/resource.py import-3.7!skip
|
||||||
plugins/module_utils/client/resource.py import-3.8!skip
|
plugins/module_utils/client/resource.py import-3.8!skip
|
||||||
plugins/module_utils/client/resource.py import-3.9!skip
|
plugins/module_utils/client/resource.py import-3.9!skip
|
||||||
plugins/module_utils/client/resource.py import-3.10!skip
|
plugins/module_utils/client/resource.py import-3.10!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.11!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.6!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.6!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.7!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.7!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||||
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||||
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||||
@@ -25,7 +28,6 @@ tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yaml
|
|||||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||||
tests/sanity/refresh_ignore_files shebang!skip
|
|
||||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
|||||||
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||||
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||||
|
plugins/module_utils/version.py pylint!skip
|
||||||
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||||
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||||
@@ -28,7 +29,6 @@ tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yaml
|
|||||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||||
tests/sanity/refresh_ignore_files shebang!skip
|
|
||||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||||
|
|||||||
38
tests/sanity/ignore-2.16.txt
Normal file
38
tests/sanity/ignore-2.16.txt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
plugins/module_utils/client/discovery.py import-3.6!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.7!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.8!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.9!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.10!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.11!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.12!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.6!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.7!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.8!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.9!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.10!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.11!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.12!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.6!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.7!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
|
||||||
|
plugins/module_utils/version.py pylint!skip
|
||||||
|
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||||
|
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||||
|
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||||
|
tests/unit/module_utils/fixtures/definitions.yml yamllint!skip
|
||||||
|
tests/unit/module_utils/fixtures/deployments.yml yamllint!skip
|
||||||
|
tests/unit/module_utils/fixtures/pods.yml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||||
|
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_taint.py validate-modules:return-syntax-error
|
||||||
29
tests/sanity/ignore-2.17.txt
Normal file
29
tests/sanity/ignore-2.17.txt
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
plugins/module_utils/client/discovery.py import-3.9!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.10!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.11!skip
|
||||||
|
plugins/module_utils/client/discovery.py import-3.12!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.9!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.10!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.11!skip
|
||||||
|
plugins/module_utils/client/resource.py import-3.12!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||||
|
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
|
||||||
|
plugins/module_utils/version.py pylint!skip
|
||||||
|
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||||
|
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||||
|
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||||
|
tests/unit/module_utils/fixtures/definitions.yml yamllint!skip
|
||||||
|
tests/unit/module_utils/fixtures/deployments.yml yamllint!skip
|
||||||
|
tests/unit/module_utils/fixtures/pods.yml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||||
|
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||||
|
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_taint.py validate-modules:return-syntax-error
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
|
|
||||||
import itertools
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
# Mapping of Ansible versions to supported Python versions
|
|
||||||
ANSIBLE_VERSIONS = {
|
|
||||||
"2.9": ["3.6", "3.7", "3.8"],
|
|
||||||
"2.10": ["3.6", "3.7", "3.8", "3.9"],
|
|
||||||
"2.11": ["3.6", "3.7", "3.8", "3.9"],
|
|
||||||
"2.12": ["3.6", "3.7", "3.8", "3.9", "3.10"],
|
|
||||||
"2.13": ["3.6", "3.7", "3.8", "3.9", "3.10"],
|
|
||||||
"2.14": ["3.6", "3.7", "3.8", "3.9", "3.10"],
|
|
||||||
"2.15": ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"],
|
|
||||||
}
|
|
||||||
|
|
||||||
IMPORT_SKIPS = [
|
|
||||||
"plugins/module_utils/client/discovery.py",
|
|
||||||
"plugins/module_utils/client/resource.py",
|
|
||||||
"plugins/module_utils/k8sdynamicclient.py",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Adds validate-modules:parameter-type-not-in-doc
|
|
||||||
PARAM_TYPE_SKIPS = [
|
|
||||||
"plugins/modules/k8s.py",
|
|
||||||
"plugins/modules/k8s_scale.py",
|
|
||||||
"plugins/modules/k8s_service.py",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Adds validate-modules:return-syntax-error
|
|
||||||
RETURN_SYNTAX_SKIPS = [
|
|
||||||
"plugins/modules/k8s.py",
|
|
||||||
"plugins/modules/k8s_scale.py",
|
|
||||||
"plugins/modules/k8s_service.py",
|
|
||||||
"plugins/modules/k8s_taint.py",
|
|
||||||
]
|
|
||||||
|
|
||||||
YAML_LINT_SKIPS = [
|
|
||||||
"tests/unit/module_utils/fixtures/definitions.yml",
|
|
||||||
"tests/unit/module_utils/fixtures/deployments.yml",
|
|
||||||
"tests/unit/module_utils/fixtures/pods.yml",
|
|
||||||
"tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml",
|
|
||||||
"tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml",
|
|
||||||
"tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml",
|
|
||||||
"tests/integration/targets/helm/files/test-chart/templates/configmap.yaml",
|
|
||||||
"tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml",
|
|
||||||
"tests/integration/targets/k8s_scale/files/deployment.yaml",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Add shebang!skip
|
|
||||||
SHEBANG_SKIPS = [
|
|
||||||
"tests/sanity/refresh_ignore_files",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Add validate-modules:import-error
|
|
||||||
VALIDATE_IMPORT_SKIPS = [
|
|
||||||
"plugins/modules/k8s.py",
|
|
||||||
"plugins/modules/k8s_cp.py",
|
|
||||||
"plugins/modules/k8s_drain.py",
|
|
||||||
"plugins/modules/k8s_exec.py",
|
|
||||||
"plugins/modules/k8s_info.py",
|
|
||||||
"plugins/modules/k8s_json_patch.py",
|
|
||||||
"plugins/modules/k8s_log.py",
|
|
||||||
"plugins/modules/k8s_rollback.py",
|
|
||||||
"plugins/modules/k8s_scale.py",
|
|
||||||
"plugins/modules/k8s_service.py",
|
|
||||||
"plugins/modules/k8s_taint.py",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def import_skips(*versions):
|
|
||||||
for f in IMPORT_SKIPS:
|
|
||||||
for v in versions:
|
|
||||||
yield f"{f} import-{v}!skip"
|
|
||||||
|
|
||||||
def param_type_skips(ansible_version):
|
|
||||||
if ansible_version not in ("2.9", "2.10"):
|
|
||||||
for f in PARAM_TYPE_SKIPS:
|
|
||||||
yield f"{f} validate-modules:parameter-type-not-in-doc"
|
|
||||||
|
|
||||||
|
|
||||||
def return_syntax_skips(ansible_version):
|
|
||||||
if ansible_version not in ("2.9", "2.10"):
|
|
||||||
for f in RETURN_SYNTAX_SKIPS:
|
|
||||||
yield f"{f} validate-modules:return-syntax-error"
|
|
||||||
else:
|
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
def yaml_lint_skips():
|
|
||||||
for f in YAML_LINT_SKIPS:
|
|
||||||
yield f"{f} yamllint!skip"
|
|
||||||
|
|
||||||
|
|
||||||
def shebang_skips():
|
|
||||||
for f in SHEBANG_SKIPS:
|
|
||||||
yield f"{f} shebang!skip"
|
|
||||||
|
|
||||||
|
|
||||||
def import_boilerplate(path, ansible_version):
|
|
||||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
|
||||||
for f in (p for p in path.glob("**/*.py") if not p.is_symlink()):
|
|
||||||
yield f"{f} future-import-boilerplate!skip"
|
|
||||||
else:
|
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
def metaclass_boilerplate(path, ansible_version):
|
|
||||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
|
||||||
for f in (p for p in path.glob("**/*.py") if not p.is_symlink()):
|
|
||||||
yield f"{f} metaclass-boilerplate!skip"
|
|
||||||
else:
|
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
def unsupported_compile_skips(path, ansible_version):
|
|
||||||
"""This adds rules for compile skips for all unsupported versions of python.
|
|
||||||
|
|
||||||
These aren't needed for Ansible version 2.12+ as that can be managed on a
|
|
||||||
global level in tests/config.yml.
|
|
||||||
"""
|
|
||||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
|
||||||
for f in (p for p in path.glob("**/*.py") if not p.is_symlink()):
|
|
||||||
yield (
|
|
||||||
f"{f} compile-2.6!skip\n"
|
|
||||||
f"{f} compile-2.7!skip\n"
|
|
||||||
f"{f} compile-3.5!skip"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def unsupported_import_skips(path, ansible_version):
|
|
||||||
"""This adds rules for import skips for all unsupported versions of python.
|
|
||||||
|
|
||||||
These aren't needed for Ansible version 2.12+ as that can be managed on a
|
|
||||||
global level in tests/config.yml.
|
|
||||||
"""
|
|
||||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
|
||||||
if ansible_version in ("2.9", "2.10") and path.name == "plugins":
|
|
||||||
pathglob = itertools.chain(
|
|
||||||
path.joinpath("modules").glob("**/*.py"),
|
|
||||||
path.joinpath("module_utils").glob("**/*.py")
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
pathglob = path.glob("**/*.py")
|
|
||||||
for f in (p for p in pathglob if not p.is_symlink()):
|
|
||||||
yield (
|
|
||||||
f"{f} import-2.6!skip\n"
|
|
||||||
f"{f} import-2.7!skip\n"
|
|
||||||
f"{f} import-3.5!skip"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def unsupported_pylint_skips(path, ansible_version):
|
|
||||||
"""This adds rules to skip pylint checks.
|
|
||||||
|
|
||||||
This is only a problem on Ansible version 2.9 and 2.10 with python 3.5,
|
|
||||||
but there's no way to restrict this to a specific version of python.
|
|
||||||
"""
|
|
||||||
if ansible_version in ("2.9", "2.10"):
|
|
||||||
pathglob = itertools.chain(
|
|
||||||
path.joinpath("plugins/modules").glob("**/*.py"),
|
|
||||||
path.joinpath("plugins/module_utils").glob("**/*.py"),
|
|
||||||
path.joinpath("tests").glob("**/*.py"),
|
|
||||||
)
|
|
||||||
for f in (p for p in pathglob if not p.is_symlink()):
|
|
||||||
yield f"{f} pylint!skip"
|
|
||||||
|
|
||||||
|
|
||||||
def unsupported_validate_modules_skips(ansible_version):
|
|
||||||
"""Disable validate-modules test.
|
|
||||||
|
|
||||||
Unfortunately, this is overly broad. Applying a validate-modules:import-error
|
|
||||||
skip fixes ansible 2.9 and python <3.6, but causes validation of the ignores
|
|
||||||
file itself to fail in python 3.6+. The only solution here is to simply
|
|
||||||
skip validate-modules altogether.
|
|
||||||
"""
|
|
||||||
if ansible_version in ("2.9", "2.10"):
|
|
||||||
for f in VALIDATE_IMPORT_SKIPS:
|
|
||||||
yield f"{f} validate-modules!skip"
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
target_dir = Path('.')
|
|
||||||
sanity_dir = target_dir / "tests" / "sanity"
|
|
||||||
plugins = target_dir / "plugins"
|
|
||||||
units = target_dir / "tests" / "unit"
|
|
||||||
integration = target_dir / "tests" / "integration"
|
|
||||||
|
|
||||||
for ansible, python in ANSIBLE_VERSIONS.items():
|
|
||||||
with open(sanity_dir / f"ignore-{ansible}.txt", "w") as fp:
|
|
||||||
ignores = itertools.chain(
|
|
||||||
import_skips(*python),
|
|
||||||
param_type_skips(ansible),
|
|
||||||
yaml_lint_skips(),
|
|
||||||
shebang_skips(),
|
|
||||||
return_syntax_skips(ansible),
|
|
||||||
import_boilerplate(plugins, ansible),
|
|
||||||
import_boilerplate(units, ansible),
|
|
||||||
metaclass_boilerplate(plugins, ansible),
|
|
||||||
metaclass_boilerplate(units, ansible),
|
|
||||||
unsupported_import_skips(plugins, ansible),
|
|
||||||
unsupported_compile_skips(plugins, ansible),
|
|
||||||
unsupported_compile_skips(units, ansible),
|
|
||||||
unsupported_compile_skips(integration, ansible),
|
|
||||||
unsupported_pylint_skips(target_dir, ansible),
|
|
||||||
unsupported_validate_modules_skips(ansible),
|
|
||||||
)
|
|
||||||
for f in filter(None, ignores):
|
|
||||||
fp.write(f + "\n")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user