kubernetes: PEP8 compliancy and doc fixes (#30914)

This PR includes:
- PEP8 compliancy fixes
- Documentation fixes
pull/31085/head
Dag Wieers 7 years ago committed by ansibot
parent 74f950936a
commit fde4244d04

@ -1,54 +1,51 @@
#!/usr/bin/python #!/usr/bin/python
# Copyright 2015 Google Inc. All Rights Reserved.
# Copyright: (c) 2015, Google Inc. All Rights Reserved.
# 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)
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: kubernetes module: kubernetes
version_added: "2.1" version_added: "2.1"
short_description: Manage Kubernetes resources. short_description: Manage Kubernetes resources
description: description:
- This module can manage Kubernetes resources on an existing cluster using - This module can manage Kubernetes resources on an existing cluster using
the Kubernetes server API. Users can specify in-line API data, or the Kubernetes server API. Users can specify in-line API data, or
specify an existing Kubernetes YAML file. Currently, this module, specify an existing Kubernetes YAML file.
Only supports HTTP Basic Auth - Currently, this module
Only supports 'strategic merge' for update, http://goo.gl/fCPYxT (1) Only supports HTTP Basic Auth
SSL certs are not working, use 'validate_certs=off' to disable (2) Only supports 'strategic merge' for update, http://goo.gl/fCPYxT
SSL certs are not working, use C(validate_certs=off) to disable.
options: options:
api_endpoint: api_endpoint:
description: description:
- The IPv4 API endpoint of the Kubernetes cluster. - The IPv4 API endpoint of the Kubernetes cluster.
required: true required: true
default: null aliases: [ endpoint ]
aliases: ["endpoint"]
inline_data: inline_data:
description: description:
- The Kubernetes YAML data to send to the API I(endpoint). This option is - The Kubernetes YAML data to send to the API I(endpoint). This option is
mutually exclusive with C('file_reference'). mutually exclusive with C('file_reference').
required: true required: true
default: null
file_reference: file_reference:
description: description:
- Specify full path to a Kubernets YAML file to send to API I(endpoint). - Specify full path to a Kubernets YAML file to send to API I(endpoint).
This option is mutually exclusive with C('inline_data'). This option is mutually exclusive with C('inline_data').
required: false
default: null
patch_operation: patch_operation:
description: > description:
- Specify patch operation for Kubernetes resource update. For details, see the description of PATCH operations at - Specify patch operation for Kubernetes resource update.
- For details, see the description of PATCH operations at
U(https://github.com/kubernetes/kubernetes/blob/release-1.5/docs/devel/api-conventions.md#patch-operations). U(https://github.com/kubernetes/kubernetes/blob/release-1.5/docs/devel/api-conventions.md#patch-operations).
default: Strategic Merge Patch default: Strategic Merge Patch
aliases: ["patch_strategy"] choices: [ JSON Patch, Merge Patch, Strategic Merge Patch ]
choices: ["JSON Patch", "Merge Patch", "Strategic Merge Patch"] aliases: [ patch_strategy ]
version_added: 2.4 version_added: 2.4
certificate_authority_data: certificate_authority_data:
description: description:
@ -56,40 +53,37 @@ options:
standard PEM format or base64 encoded PEM data. Note that certificate standard PEM format or base64 encoded PEM data. Note that certificate
verification is broken until ansible supports a version of verification is broken until ansible supports a version of
'match_hostname' that can match the IP address against the CA data. 'match_hostname' that can match the IP address against the CA data.
required: false
default: null
state: state:
description: description:
- The desired action to take on the Kubernetes data. - The desired action to take on the Kubernetes data.
required: true required: true
default: "present" choices: [ absent, present, replace, update ]
choices: ["present", "absent", "update", "replace"] default: present
url_password: url_password:
description: description:
- The HTTP Basic Auth password for the API I(endpoint). This should be set - The HTTP Basic Auth password for the API I(endpoint). This should be set
unless using the C('insecure') option. unless using the C('insecure') option.
default: null aliases: [ password ]
aliases: ["password"]
url_username: url_username:
description: description:
- The HTTP Basic Auth username for the API I(endpoint). This should be set - The HTTP Basic Auth username for the API I(endpoint). This should be set
unless using the C('insecure') option. unless using the C('insecure') option.
default: "admin" default: admin
aliases: ["username"] aliases: [ username ]
insecure: insecure:
description: description:
- "Reverts the connection to using HTTP instead of HTTPS. This option should - Reverts the connection to using HTTP instead of HTTPS. This option should
only be used when execuing the M('kubernetes') module local to the Kubernetes only be used when execuing the M('kubernetes') module local to the Kubernetes
cluster using the insecure local port (locahost:8080 by default)." cluster using the insecure local port (locahost:8080 by default).
validate_certs: validate_certs:
description: description:
- Enable/disable certificate validation. Note that this is set to - Enable/disable certificate validation. Note that this is set to
C(false) until Ansible can support IP address based certificate C(false) until Ansible can support IP address based certificate
hostname matching (exists in >= python3.5.0). hostname matching (exists in >= python3.5.0).
required: false type: bool
default: false default: 'no'
author:
author: "Eric Johnson (@erjohnso) <erjohnso@google.com>" - Eric Johnson (@erjohnso) <erjohnso@google.com>
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -158,9 +152,9 @@ import json
try: try:
import yaml import yaml
has_lib_yaml = True HAS_LIB_YAML = True
except ImportError: except ImportError:
has_lib_yaml = False HAS_LIB_YAML = False
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
@ -334,27 +328,27 @@ def k8s_update_resource(module, url, data, patch_operation):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
http_agent=dict(default=USER_AGENT), http_agent=dict(type='str', default=USER_AGENT),
url_username=dict(type='str', default='admin', aliases=['username']),
url_username=dict(default="admin", aliases=["username"]), url_password=dict(type='str', default='', no_log=True, aliases=['password']),
url_password=dict(default="", no_log=True, aliases=["password"]), force_basic_auth=dict(type='bool', default=True),
force_basic_auth=dict(default="yes"), validate_certs=dict(type='bool', default=False),
validate_certs=dict(default=False, type='bool'), certificate_authority_data=dict(type='str'),
certificate_authority_data=dict(required=False), insecure=dict(type='bool', default=False),
insecure=dict(default=False, type='bool'), api_endpoint=dict(type='str', required=True),
api_endpoint=dict(required=True), patch_operation=dict(type='str', default='Strategic Merge Patch', aliases=['patch_strategy'],
patch_operation=dict(default='Strategic Merge Patch', aliases=['patch_strategy'], choices=['JSON Patch', 'Merge Patch', 'Strategic Merge Patch']), choices=['JSON Patch', 'Merge Patch', 'Strategic Merge Patch']),
file_reference=dict(required=False), file_reference=dict(type='str'),
inline_data=dict(required=False), inline_data=dict(type='str'),
state=dict(default="present", choices=["present", "absent", "update", "replace"]) state=dict(type='str', default='present', choices=['absent', 'present', 'replace', 'update'])
), ),
mutually_exclusive = (('file_reference', 'inline_data'), mutually_exclusive=(('file_reference', 'inline_data'),
('url_username', 'insecure'), ('url_username', 'insecure'),
('url_password', 'insecure')), ('url_password', 'insecure')),
required_one_of = (('file_reference', 'inline_data'),), required_one_of=(('file_reference', 'inline_data')),
) )
if not has_lib_yaml: if not HAS_LIB_YAML:
module.fail_json(msg="missing python library: yaml") module.fail_json(msg="missing python library: yaml")
decode_cert_data(module) decode_cert_data(module)
@ -393,7 +387,7 @@ def main():
# make sure the data is a list # make sure the data is a list
if not isinstance(data, list): if not isinstance(data, list):
data = [ data ] data = [data]
for item in data: for item in data:
namespace = "default" namespace = "default"

@ -175,7 +175,6 @@ lib/ansible/modules/cloud/webfaction/webfaction_domain.py
lib/ansible/modules/cloud/webfaction/webfaction_site.py lib/ansible/modules/cloud/webfaction/webfaction_site.py
lib/ansible/modules/clustering/consul_kv.py lib/ansible/modules/clustering/consul_kv.py
lib/ansible/modules/clustering/consul_session.py lib/ansible/modules/clustering/consul_session.py
lib/ansible/modules/clustering/kubernetes.py
lib/ansible/modules/clustering/pacemaker_cluster.py lib/ansible/modules/clustering/pacemaker_cluster.py
lib/ansible/modules/database/misc/kibana_plugin.py lib/ansible/modules/database/misc/kibana_plugin.py
lib/ansible/modules/database/misc/riak.py lib/ansible/modules/database/misc/riak.py

Loading…
Cancel
Save