mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-04-14 12:51:16 +00:00
k8s_*: Group argument_spec accroding to usage (#199)
Partially fix #36 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
@@ -15,8 +15,8 @@ class ModuleDocFragment(object):
|
||||
options:
|
||||
resource_definition:
|
||||
description:
|
||||
- "Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating. NOTE: I(kind), I(api_version), I(name),
|
||||
and I(namespace) will be overwritten by corresponding values found in the provided I(resource_definition)."
|
||||
- Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating.
|
||||
- "NOTE: I(kind), I(api_version), I(name), and I(namespace) will be overwritten by corresponding values found in the provided I(resource_definition)."
|
||||
aliases:
|
||||
- definition
|
||||
- inline
|
||||
|
||||
@@ -83,6 +83,9 @@ COMMON_ARG_SPEC = {
|
||||
'type': 'bool',
|
||||
'default': False,
|
||||
},
|
||||
}
|
||||
|
||||
RESOURCE_ARG_SPEC = {
|
||||
'resource_definition': {
|
||||
'type': list_dict_str,
|
||||
'aliases': ['definition', 'inline']
|
||||
@@ -90,6 +93,9 @@ COMMON_ARG_SPEC = {
|
||||
'src': {
|
||||
'type': 'path',
|
||||
},
|
||||
}
|
||||
|
||||
NAME_ARG_SPEC = {
|
||||
'kind': {},
|
||||
'name': {},
|
||||
'namespace': {},
|
||||
|
||||
@@ -25,7 +25,7 @@ import sys
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import missing_required_lib
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
||||
@@ -78,6 +78,8 @@ class KubernetesRawModule(KubernetesAnsibleModule):
|
||||
@property
|
||||
def argspec(self):
|
||||
argument_spec = copy.deepcopy(COMMON_ARG_SPEC)
|
||||
argument_spec.update(copy.deepcopy(NAME_ARG_SPEC))
|
||||
argument_spec.update(copy.deepcopy(RESOURCE_ARG_SPEC))
|
||||
argument_spec.update(copy.deepcopy(AUTH_ARG_SPEC))
|
||||
argument_spec['merge_type'] = dict(type='list', elements='str', choices=['json', 'merge', 'strategic-merge'])
|
||||
argument_spec['wait'] = dict(type='bool', default=False)
|
||||
|
||||
@@ -21,7 +21,7 @@ __metaclass__ = type
|
||||
|
||||
import copy
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
@@ -142,11 +142,10 @@ class KubernetesAnsibleScaleModule(KubernetesAnsibleModule):
|
||||
|
||||
@property
|
||||
def argspec(self):
|
||||
args = copy.deepcopy(COMMON_ARG_SPEC)
|
||||
args.pop('state')
|
||||
args.pop('force')
|
||||
args = copy.deepcopy(SCALE_ARG_SPEC)
|
||||
args.update(RESOURCE_ARG_SPEC)
|
||||
args.update(NAME_ARG_SPEC)
|
||||
args.update(AUTH_ARG_SPEC)
|
||||
args.update(SCALE_ARG_SPEC)
|
||||
return args
|
||||
|
||||
def scale(self, resource, existing_object, replicas, wait, wait_time):
|
||||
|
||||
@@ -26,40 +26,25 @@ description:
|
||||
- Analogous to `kubectl logs` or `oc logs`
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_name_options
|
||||
options:
|
||||
api_version:
|
||||
description:
|
||||
- Use to specify the API version. in conjunction with I(kind), I(name), and I(namespace) to identify a
|
||||
specific object.
|
||||
- If using I(label_selector), cannot be overridden
|
||||
default: v1
|
||||
aliases:
|
||||
- api
|
||||
- version
|
||||
type: str
|
||||
kind:
|
||||
description:
|
||||
- Use to specify an object model. Use in conjunction with I(api_version), I(name), and I(namespace) to identify a
|
||||
specific object.
|
||||
- If using I(label_selector), cannot be overridden
|
||||
required: no
|
||||
- Use to specify an object model.
|
||||
- Use in conjunction with I(api_version), I(name), and I(namespace) to identify a specific object.
|
||||
- If using I(label_selector), cannot be overridden.
|
||||
type: str
|
||||
default: Pod
|
||||
type: str
|
||||
namespace:
|
||||
description:
|
||||
- Use to specify an object namespace. Use in conjunction with I(api_version), I(kind), and I(name)
|
||||
to identify a specific object.
|
||||
type: str
|
||||
name:
|
||||
description:
|
||||
- Use to specify an object name. Use in conjunction with I(api_version), I(kind) and I(namespace) to identify a
|
||||
specific object.
|
||||
- Only one of I(name) or I(label_selector) may be provided
|
||||
- Use to specify an object name.
|
||||
- Use in conjunction with I(api_version), I(kind) and I(namespace) to identify a specific object.
|
||||
- Only one of I(name) or I(label_selector) may be provided.
|
||||
type: str
|
||||
label_selectors:
|
||||
description:
|
||||
- List of label selectors to use to filter results
|
||||
- Only one of I(name) or I(label_selector) may be provided
|
||||
- Only one of I(name) or I(label_selector) may be provided.
|
||||
type: list
|
||||
elements: str
|
||||
container:
|
||||
@@ -129,7 +114,7 @@ import copy
|
||||
from ansible.module_utils.six import PY2
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, NAME_ARG_SPEC
|
||||
|
||||
|
||||
class KubernetesLogModule(KubernetesAnsibleModule):
|
||||
@@ -142,12 +127,10 @@ class KubernetesLogModule(KubernetesAnsibleModule):
|
||||
@property
|
||||
def argspec(self):
|
||||
args = copy.deepcopy(AUTH_ARG_SPEC)
|
||||
args.update(NAME_ARG_SPEC)
|
||||
args.update(
|
||||
dict(
|
||||
kind=dict(default='Pod'),
|
||||
api_version=dict(default='v1', aliases=['api', 'version']),
|
||||
name=dict(),
|
||||
namespace=dict(),
|
||||
kind=dict(type='str', default='Pod'),
|
||||
container=dict(),
|
||||
label_selectors=dict(type='list', elements='str', default=[]),
|
||||
)
|
||||
|
||||
@@ -22,43 +22,10 @@ description:
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_resource_options
|
||||
- community.kubernetes.k8s_state_options
|
||||
|
||||
options:
|
||||
resource_definition:
|
||||
description:
|
||||
- A partial YAML definition of the Service object being created/updated. Here you can define Kubernetes
|
||||
Service Resource parameters not covered by this module's parameters.
|
||||
- "NOTE: I(resource_definition) has lower priority than module parameters. If you try to define e.g.
|
||||
I(metadata.namespace) here, that value will be ignored and I(metadata) used instead."
|
||||
aliases:
|
||||
- definition
|
||||
- inline
|
||||
type: dict
|
||||
src:
|
||||
description:
|
||||
- "Provide a path to a file containing a valid YAML definition of an object dated. Mutually
|
||||
exclusive with I(resource_definition). NOTE: I(kind), I(api_version), I(resource_name), and I(namespace)
|
||||
will be overwritten by corresponding values found in the configuration read in from the I(src) file."
|
||||
- Reads from the local file system. To read from the Ansible controller's file system, use the file lookup
|
||||
plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to
|
||||
I(resource_definition). See Examples below.
|
||||
type: path
|
||||
state:
|
||||
description:
|
||||
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
|
||||
created, if it does not already exist. If set to C(absent), an existing object will be deleted. If set to
|
||||
C(present), an existing object will be patched, if its attributes differ from those specified using
|
||||
module options and I(resource_definition).
|
||||
default: present
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
type: str
|
||||
force:
|
||||
description:
|
||||
- If set to C(True), and I(state) is C(present), an existing object will be replaced.
|
||||
default: false
|
||||
type: bool
|
||||
merge_type:
|
||||
description:
|
||||
- Whether to override the default patch merge approach with a specific type. By default, the strategic
|
||||
@@ -181,7 +148,7 @@ import traceback
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.raw import KubernetesRawModule
|
||||
|
||||
|
||||
@@ -190,25 +157,10 @@ SERVICE_ARG_SPEC = {
|
||||
'type': 'bool',
|
||||
'default': False,
|
||||
},
|
||||
'state': {
|
||||
'default': 'present',
|
||||
'choices': ['present', 'absent'],
|
||||
},
|
||||
'force': {
|
||||
'type': 'bool',
|
||||
'default': False,
|
||||
},
|
||||
'resource_definition': {
|
||||
'type': 'dict',
|
||||
'aliases': ['definition', 'inline']
|
||||
},
|
||||
'name': {'required': True},
|
||||
'namespace': {'required': True},
|
||||
'merge_type': {'type': 'list', 'elements': 'str', 'choices': ['json', 'merge', 'strategic-merge']},
|
||||
'selector': {'type': 'dict'},
|
||||
'src': {
|
||||
'type': 'path',
|
||||
},
|
||||
'type': {
|
||||
'type': 'str',
|
||||
'choices': [
|
||||
@@ -240,6 +192,8 @@ class KubernetesService(KubernetesRawModule):
|
||||
def argspec(self):
|
||||
""" argspec property builder """
|
||||
argument_spec = copy.deepcopy(AUTH_ARG_SPEC)
|
||||
argument_spec.update(COMMON_ARG_SPEC)
|
||||
argument_spec.update(RESOURCE_ARG_SPEC)
|
||||
argument_spec.update(SERVICE_ARG_SPEC)
|
||||
return argument_spec
|
||||
|
||||
|
||||
@@ -3,3 +3,4 @@ plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||
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:parameter-type-not-in-doc
|
||||
|
||||
@@ -3,3 +3,4 @@ plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||
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:parameter-type-not-in-doc
|
||||
|
||||
Reference in New Issue
Block a user