Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow_preview parameter to azure_rm_aksversion_info #1456

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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