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

Update azure Policy key under addonProfiles matching Azure Portal casing #8495

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ If there is no rush to release a new version, please just add a description of t

To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.

13.0.0b9
+++++++
* `az aks enable-addons`: Fix azure policy key under addonProfiles

Pending
+++++++
* Vendor new SDK and bump API version to 2024-10-02-preview.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,87 @@ def test_aks_create_with_safeguards(self, resource_group, resource_group_locatio
],
)

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(
random_name_length=17, name_prefix="clitest", location="westcentralus"
)
def test_aks_create_with_azurepolicy(self, resource_group, resource_group_location):
aks_name = self.create_random_name("cliakstest", 16)
self.kwargs.update(
{
"resource_group": resource_group,
"name": aks_name,
"ssh_key_value": self.generate_ssh_keys(),
}
)

create_cmd = (
"aks create --resource-group={resource_group} --name={name} --ssh-key-value={ssh_key_value} "
"--enable-addons azure-policy "
)
self.cmd(
create_cmd,
checks=[
self.check("provisioningState", "Succeeded"),
# Case-insensitive check for azurePolicy and enabled=True
self.assertTrue(any(k.lower() == "azurepolicy" and v.get("enabled") for k, v in result.get("addonProfiles", {}).items())),
],
)

list_cmd = (
"aks addon list --resource-group={resource_group} --name={name} -o json"
)
addon_list = self.cmd(list_cmd).get_output_in_json()

assert len(addon_list) > 0

for addon in addon_list:
if addon["name"] == "azure-policy":
assert addon["enabled"]
else:
assert not addon["enabled"]

disable_cmd = (
"aks aks --resource-group={resource_group} --name={name} "
"--disable-addons azure-policy "
)
self.cmd(
disable_cmd,
checks=[
self.check("provisioningState", "Succeeded"),
# Case-insensitive check for azurePolicy and enabled=True
self.assertTrue(any(k.lower() == "azurepolicy" and v.get("enabled") for k, v in result.get("addonProfiles", {}).items())),
],
)
addon_list = self.cmd(list_cmd).get_output_in_json()

assert len(addon_list) > 0

for addon in addon_list:
assert not addon["enabled"]

update_cmd = (
"aks aks --resource-group={resource_group} --name={name} "
"--enable-addons azure-policy "
)
self.cmd(
update_cmd,
checks=[
self.check("provisioningState", "Succeeded"),
# Case-insensitive check for azurePolicy and enabled=True
self.assertTrue(any(k.lower() == "azurepolicy" and v.get("enabled") for k, v in result.get("addonProfiles", {}).items()))
],
)
addon_list = self.cmd(list_cmd).get_output_in_json()

assert len(addon_list) > 0

for addon in addon_list:
if addon["name"] == "azure-policy":
assert addon["enabled"]
else:
assert not addon["enabled"]

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(
random_name_length=17, name_prefix="clitest", location="westcentralus"
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "13.0.0b8"
VERSION = "13.0.0b9"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down
Loading