Skip to content

Commit

Permalink
allow turbo mode, but disabled by default
Browse files Browse the repository at this point in the history
Depends-On: ansible-collections/cloud.common#73

Expose a new parameter called enable_session_cache to enable the
feature.
  • Loading branch information
goneri committed Jul 28, 2021
1 parent f5a8194 commit a72c9e6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/add_enable_session_cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- add ``enable_session_cache`` parameter to turn on the session cache. The option is disabled by default.
2 changes: 2 additions & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ authors:
- willthames (https://github.com/willthames)
- mmazur (https://github.com/mmazur)
- jamescassell (https://github.com/jamescassell)
dependencies:
cloud.common: '>=2.0.1'
description: Kubernetes Collection for Ansible.
documentation: ''
homepage: ''
Expand Down
21 changes: 21 additions & 0 deletions plugins/doc_fragments/k8s_turbo_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2018, Red Hat | Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Options for selecting or identifying a specific K8s object

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


class ModuleDocFragment(object):

DOCUMENTATION = r'''
options:
enable_session_cache:
description:
- Enable the caching of the HTTP sessions.
type: bool
default: false
'''
8 changes: 7 additions & 1 deletion plugins/module_utils/ansiblemodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
__metaclass__ = type


from ansible.module_utils.basic import AnsibleModule # noqa: F401
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
7 changes: 7 additions & 0 deletions plugins/module_utils/args_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,10 @@ def list_dict_str(value):
}
}
}

TURBO_ARG_SPEC = {
'enable_session_cache': {
'type': 'bool',
'default': False,
},
}
1 change: 1 addition & 0 deletions plugins/modules/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def argspec():
argument_spec.update(copy.deepcopy(RESOURCE_ARG_SPEC))
argument_spec.update(copy.deepcopy(AUTH_ARG_SPEC))
argument_spec.update(copy.deepcopy(WAIT_ARG_SPEC))
argument_spec.update(copy.deepcopy(TURBO_ARG_SPEC))
argument_spec['merge_type'] = dict(type='list', elements='str', choices=['json', 'merge', 'strategic-merge'])
argument_spec['validate'] = dict(type='dict', default=None, options=validate_spec())
argument_spec['append_hash'] = dict(type='bool', default=False)
Expand Down

0 comments on commit a72c9e6

Please sign in to comment.