mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-07 13:32:37 +00:00
This is a backport of PR #1090 as merged into main (e6076e5).
SUMMARY
Ensure compatibility with Helm v4 for modules helm_plugin and helm_plugin_info
Partially addresses #1038
ISSUE TYPE
Feature Pull Request
COMPONENT NAME
helm_plugin
helm_plugin_info
helm_info
helm_pull
helm_registry_auth
helm
helm_template
Reviewed-by: Bikouo Aubin
Reviewed-by: Matthew Johnson
This commit is contained in:
@@ -20,7 +20,7 @@ author:
|
||||
- Yuriy Novostavskiy (@yurnov)
|
||||
|
||||
requirements:
|
||||
- "helm (https://github.com/helm/helm/releases) >= 3.8.0, <4.0.0"
|
||||
- "helm (https://github.com/helm/helm/releases) >= 3.8.0"
|
||||
|
||||
description:
|
||||
- Helm registry authentication module allows you to login C(helm registry login) and logout C(helm registry logout) from a Helm registry.
|
||||
@@ -75,6 +75,14 @@ options:
|
||||
- Path to the CA certificate SSL file for verify registry server certificate.
|
||||
required: false
|
||||
type: path
|
||||
plain_http:
|
||||
description:
|
||||
- Use insecure HTTP connections for C(helm registry login).
|
||||
- Requires Helm >= 3.18.0
|
||||
required: false
|
||||
type: bool
|
||||
default: False
|
||||
version_added: 6.4.0
|
||||
binary_path:
|
||||
description:
|
||||
- The path of a helm binary to use.
|
||||
@@ -148,6 +156,7 @@ def arg_spec():
|
||||
key_file=dict(type="path", required=False),
|
||||
cert_file=dict(type="path", required=False),
|
||||
ca_file=dict(type="path", required=False),
|
||||
plain_http=dict(type="bool", default=False),
|
||||
)
|
||||
|
||||
|
||||
@@ -160,6 +169,7 @@ def login(
|
||||
key_file,
|
||||
cert_file,
|
||||
ca_file,
|
||||
plain_http,
|
||||
):
|
||||
login_command = command + " registry login " + host
|
||||
|
||||
@@ -177,6 +187,8 @@ def login(
|
||||
|
||||
if ca_file is not None:
|
||||
login_command += " --ca-file=" + ca_file
|
||||
if plain_http:
|
||||
login_command += " --plain-http"
|
||||
|
||||
return login_command
|
||||
|
||||
@@ -194,8 +206,8 @@ def main():
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
# Validate Helm version >=3.0.0,<4.0.0
|
||||
module.validate_helm_version()
|
||||
# Validate Helm version >=3.8.0
|
||||
module.validate_helm_version(version="3.8.0")
|
||||
|
||||
changed = False
|
||||
|
||||
@@ -207,6 +219,19 @@ def main():
|
||||
key_file = module.params.get("key_file")
|
||||
cert_file = module.params.get("cert_file")
|
||||
ca_file = module.params.get("ca_file")
|
||||
plain_http = module.params.get("plain_http")
|
||||
|
||||
helm_version = module.get_helm_version()
|
||||
|
||||
if plain_http:
|
||||
if LooseVersion(helm_version) < LooseVersion("3.18.0"):
|
||||
module.warn(
|
||||
"plain_http option requires helm >= 3.18.0, current version is {0}".format(
|
||||
helm_version
|
||||
)
|
||||
)
|
||||
# reset option
|
||||
plain_http = False
|
||||
|
||||
helm_cmd = module.get_helm_binary()
|
||||
|
||||
@@ -215,7 +240,15 @@ def main():
|
||||
changed = True
|
||||
elif state == "present":
|
||||
helm_cmd = login(
|
||||
helm_cmd, host, insecure, username, password, key_file, cert_file, ca_file
|
||||
helm_cmd,
|
||||
host,
|
||||
insecure,
|
||||
username,
|
||||
password,
|
||||
key_file,
|
||||
cert_file,
|
||||
ca_file,
|
||||
plain_http,
|
||||
)
|
||||
changed = True
|
||||
|
||||
@@ -238,7 +271,6 @@ def main():
|
||||
command=helm_cmd,
|
||||
)
|
||||
|
||||
helm_version = module.get_helm_version()
|
||||
if LooseVersion(helm_version) >= LooseVersion("3.18.0") and state == "absent":
|
||||
# https://github.com/ansible-collections/kubernetes.core/issues/944
|
||||
module.warn(
|
||||
|
||||
Reference in New Issue
Block a user