mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-30 19:34:43 +00:00
Re-enable support for turbo mode (#169)
Re-enable support for turbo mode SUMMARY This re-enables the ability to add turbo mode. It also adds a few more tests to cover some cases that had been broken in turbo mode previously. Testing with turbo mode is not currently enabled, and would fail until ansible-collections/cloud.common#69 can be merged and a new cloud.common release is done. This also does not add cloud.common to the collection dependencies until a decision has been made about how enabling/disabling turbo mode will work when cloud.common is already installed. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Abhijeet Kasurde <None> Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net> Reviewed-by: None <None>
This commit is contained in:
3
changelogs/fragments/169-reenable-turbo-mode.yaml
Normal file
3
changelogs/fragments/169-reenable-turbo-mode.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- re-enable turbo mode for collection. The default is initially set to off (https://github.com/ansible-collections/kubernetes.core/pull/169).
|
||||||
@@ -36,12 +36,30 @@
|
|||||||
path: ~/.kube/config
|
path: ~/.kube/config
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Try to create namespace without default kube config
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
name: testing
|
||||||
|
kind: Namespace
|
||||||
|
ignore_errors: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: No default kube config should fail
|
||||||
|
assert:
|
||||||
|
that: result is not successful
|
||||||
|
|
||||||
- name: Using custom config location should succeed
|
- name: Using custom config location should succeed
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
name: testing
|
name: testing
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
kubeconfig: ~/.kube/customconfig
|
kubeconfig: ~/.kube/customconfig
|
||||||
|
|
||||||
|
- name: Using an env var to set config location should succeed
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
name: testing
|
||||||
|
kind: Namespace
|
||||||
|
environment:
|
||||||
|
K8S_AUTH_KUBECONFIG: ~/.kube/customconfig
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Return kubeconfig
|
- name: Return kubeconfig
|
||||||
copy:
|
copy:
|
||||||
@@ -365,6 +383,38 @@
|
|||||||
register: k8s_info_testing6
|
register: k8s_info_testing6
|
||||||
failed_when: not k8s_info_testing6.resources or k8s_info_testing6.resources[0].status.phase != "Active"
|
failed_when: not k8s_info_testing6.resources or k8s_info_testing6.resources[0].status.phase != "Active"
|
||||||
|
|
||||||
|
- name: Create large configmap data
|
||||||
|
command: dd if=/dev/urandom bs=500K count=1
|
||||||
|
register: cmap_data
|
||||||
|
|
||||||
|
- name: Create configmap with large value
|
||||||
|
k8s:
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: testmap
|
||||||
|
namespace: testing
|
||||||
|
data:
|
||||||
|
testkey: "{{ cmap_data.stdout | b64encode }}"
|
||||||
|
wait: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
||||||
|
|
||||||
|
- name: Retrieve configmap
|
||||||
|
k8s_info:
|
||||||
|
kind: ConfigMap
|
||||||
|
namespace: testing
|
||||||
|
name: testmap
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.resources[0].data.testkey == "{{ cmap_data.stdout | b64encode }}"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Delete all namespaces
|
- name: Delete all namespaces
|
||||||
k8s:
|
k8s:
|
||||||
|
|||||||
@@ -3,4 +3,22 @@ from __future__ import (absolute_import, division, print_function)
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule # noqa: F401
|
import os
|
||||||
|
|
||||||
|
from ansible.module_utils.common.validation import check_type_bool
|
||||||
|
|
||||||
|
try:
|
||||||
|
enable_turbo_mode = check_type_bool(os.environ.get("ENABLE_TURBO_MODE"))
|
||||||
|
except TypeError:
|
||||||
|
enable_turbo_mode = False
|
||||||
|
|
||||||
|
if enable_turbo_mode:
|
||||||
|
try:
|
||||||
|
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import (
|
||||||
|
AnsibleTurboModule as AnsibleModule,
|
||||||
|
) # noqa: F401
|
||||||
|
AnsibleModule.collection_name = "kubernetes.core"
|
||||||
|
except ImportError:
|
||||||
|
from ansible.module_utils.basic import AnsibleModule # noqa: F401
|
||||||
|
else:
|
||||||
|
from ansible.module_utils.basic import AnsibleModule # noqa: F401
|
||||||
|
|||||||
3
requirements.yml
Normal file
3
requirements.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
collections:
|
||||||
|
- name: cloud.common
|
||||||
|
version: ">=2.0.4"
|
||||||
Reference in New Issue
Block a user