Debian Codegraph @

ansible_collections/community/okd/plugins/modules/openshift_registry_info.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2021, Red Hat
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 from __future__ import absolute_import, division, print_function
8
9 __metaclass__ = type
10
11 # STARTREMOVE (downstream)
12 DOCUMENTATION = r"""
13
14 module: openshift_registry_info
15
16 short_description: Display information about the integrated registry.
17
18 version_added: "2.2.0"
19
20 author:
21 - Aubin Bikouo (@abikouo)
22
23 description:
24 - This module exposes information about the integrated registry.
25 - Use C(check) to verify your local client can access the registry.
26 - If the adminstrator has not configured a public hostname for the registry then
27 this command may fail when run outside of the server.
28 - Analogous to C(oc registry info).
29
30 extends_documentation_fragment:
31 - kubernetes.core.k8s_auth_options
32
33 options:
34 check:
35 description:
36 - Attempt to contact the integrated registry using local client.
37 type: bool
38 default: False
39
40 requirements:
41 - python >= 3.6
42 - kubernetes >= 12.0.0
43 - docker-image-py
44 """
45
46 EXAMPLES = r"""
47 # Get registry information
48 - name: Read integrated registry information
49 community.okd.openshift_registry_info:
50
51 # Read registry integrated information and attempt to contact using local client.
52 - name: Attempt to contact integrated registry using local client
53 community.okd.openshift_registry_info:
54 check: true
55 """
56
57
58 RETURN = r"""
59 internal_hostname:
60 description:
61 - The internal registry hostname.
62 type: str
63 returned: success
64 public_hostname:
65 description:
66 - The public registry hostname.
67 type: str
68 returned: success
69 check:
70 description:
71 - Whether the local client can contact or not the registry.
72 type: dict
73 returned: success
74 contains:
75 reached:
76 description: Whether the registry has been reached or not.
77 returned: success
78 type: str
79 msg:
80 description: message describing the ping operation.
81 returned: always
82 type: str
83 """
84 # ENDREMOVE (downstream)
85
86 import copy
87
88 from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
89 AUTH_ARG_SPEC,
90 )
91
92
93 def argument_spec():
94 args = copy.deepcopy(AUTH_ARG_SPEC)
95 args.update(dict(check=dict(type="bool", default=False)))
96 return args
97
98
99 def main():
100 from ansible_collections.community.okd.plugins.module_utils.openshift_registry import (
101 OpenShiftRegistry,
102 )
103
104 module = OpenShiftRegistry(argument_spec=argument_spec(), supports_check_mode=True)
105 module.run_module()
106
107
108 if __name__ == "__main__":
109 main()