Skip to content

Commit

Permalink
Add allow_preview parameter to azure_rm_aksversion_info (#1456)
Browse files Browse the repository at this point in the history
* Add allow_preview parameters, check retruen ubernetes version info

* Fix sanity error
  • Loading branch information
Fred-sun authored Feb 29, 2024
1 parent 1a4a7a8 commit 4566e05
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions plugins/modules/azure_rm_aksversion_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
description:
- Get the upgrade versions available for a managed Kubernetes cluster version.
type: str
allow_preview:
description:
- Whether Kubernetes version is currently in preview.
- If I(allow_preview=True), returns the current preview status of the current Kubernetes version.
- If I(allow_preview=False), returns the Kubernetes version in a non-current preview state.
- If no set C(allow_preview), returns all the avaiable Kubernetes version.
type: bool
extends_documentation_fragment:
- azure.azcollection.azure
Expand All @@ -38,6 +45,10 @@
'''

EXAMPLES = '''
- name: Get current preview versions for AKS in location eastus
azure_rm_aksversion_info:
location: eastus
allow_preview: true
- name: Get available versions for AKS in location eastus
azure_rm_aksversion_info:
location: eastus
Expand All @@ -63,7 +74,8 @@ def __init__(self):

self.module_args = dict(
location=dict(type='str', required=True),
version=dict(type='str')
version=dict(type='str'),
allow_preview=dict(type='bool')
)

self.results = dict(
Expand All @@ -73,6 +85,7 @@ def __init__(self):

self.location = None
self.version = None
self.allow_preview = None

super(AzureRMAKSVersion, self).__init__(
derived_arg_spec=self.module_args,
Expand Down Expand Up @@ -104,7 +117,14 @@ def get_all_versions(self, location, version):
response = self.containerservice_client.container_services.list_orchestrators(self.location, resource_type='managedClusters')
orchestrators = response.orchestrators
for item in orchestrators:
result[item.orchestrator_version] = [x.orchestrator_version for x in item.upgrades] if item.upgrades else []
if self.allow_preview is None:
result[item.orchestrator_version] = [x.orchestrator_version for x in item.upgrades] if item.upgrades else []
elif self.allow_preview:
if item.is_preview:
result[item.orchestrator_version] = [x.orchestrator_version for x in item.upgrades] if item.upgrades else []
else:
if not item.is_preview:
result[item.orchestrator_version] = [x.orchestrator_version for x in item.upgrades] if item.upgrades else []
if version:
return result.get(version) or []
else:
Expand Down

0 comments on commit 4566e05

Please sign in to comment.