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

Rename WorkloadIAM to EntraWorkloadIAM #273

Merged
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: 2 additions & 2 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .partner_extensions.AzureMLKubernetes import AzureMLKubernetes
from .partner_extensions.DataProtectionKubernetes import DataProtectionKubernetes
from .partner_extensions.Dapr import Dapr
from .partner_extensions.WorkloadIAM import WorkloadIAM
from .partner_extensions.EntraWorkloadIAM import EntraWorkloadIAM
from .partner_extensions.DefaultExtension import (
DefaultExtension,
user_confirmation_factory,
Expand All @@ -52,7 +52,7 @@ def ExtensionFactory(extension_name):
"microsoft.azureml.kubernetes": AzureMLKubernetes,
"microsoft.dapr": Dapr,
"microsoft.dataprotection.kubernetes": DataProtectionKubernetes,
"microsoft.workloadiam": WorkloadIAM,
"microsoft.entraworkloadiam": EntraWorkloadIAM,
}

# Return the extension if we find it in the map, else return the default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
CONFIG_SETTINGS_HELM_JOIN_TOKEN = 'workload-iam-local-authority.localAuthorityArgs.joinToken'


class WorkloadIAM(DefaultExtension):
class EntraWorkloadIAM(DefaultExtension):

def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file,
plan_name, plan_publisher, plan_product):
"""
Create method for ExtensionType 'microsoft.workloadiam'.
Create method for ExtensionType 'microsoft.entraworkloadiam'.
"""

# Ensure that the values provided by the user for generic values of Arc extensions are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import unittest

from azure.cli.core.azclierror import InvalidArgumentValueError
from azext_k8s_extension.partner_extensions.WorkloadIAM import (
WorkloadIAM,
from azext_k8s_extension.partner_extensions.EntraWorkloadIAM import (
EntraWorkloadIAM,
CONFIG_SETTINGS_USER_TRUST_DOMAIN,
CONFIG_SETTINGS_USER_LOCAL_AUTHORITY,
CONFIG_SETTINGS_USER_TENANT_ID,
Expand All @@ -23,7 +23,7 @@

from unittest.mock import patch

class TestWorkloadIAM(unittest.TestCase):
class TestEntraWorkloadIAM(unittest.TestCase):

def test_workload_iam_create_with_instance_name_too_long(self):
"""
Expand All @@ -33,7 +33,7 @@ def test_workload_iam_create_with_instance_name_too_long(self):
instance_name = "workload-iam-extra-long-instance-name"

with self.assertRaises(InvalidArgumentValueError) as context:
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name=instance_name, cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand Down Expand Up @@ -72,13 +72,13 @@ def mock_extension_init(_self, *, extension_type, auto_upgrade_minor_version, re
assert(configuration_settings[CONFIG_SETTINGS_HELM_TENANT_ID] == mock_tenant_id)


with patch('azext_k8s_extension.partner_extensions.WorkloadIAM.Extension.__init__',
with patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.Extension.__init__',
new=mock_extension_init), \
patch('azext_k8s_extension.partner_extensions.WorkloadIAM.WorkloadIAM.get_join_token',
patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.EntraWorkloadIAM.get_join_token',
return_value=mock_join_token):

# Test & assert
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
_, name, _ = workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand Down Expand Up @@ -118,13 +118,13 @@ def mock_extension_init(_self, *, extension_type, auto_upgrade_minor_version, re
assert(configuration_settings[CONFIG_SETTINGS_HELM_TENANT_ID] == mock_tenant_id)


with patch('azext_k8s_extension.partner_extensions.WorkloadIAM.Extension.__init__',
with patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.Extension.__init__',
new=mock_extension_init), \
patch('azext_k8s_extension.partner_extensions.WorkloadIAM.WorkloadIAM.get_join_token',
patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.EntraWorkloadIAM.get_join_token',
return_value='BAD_JOIN_TOKEN'):

# Test & assert
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
_, name, _ = workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand Down Expand Up @@ -162,13 +162,13 @@ def mock_extension_init(_self, *, extension_type, auto_upgrade_minor_version, re
assert(configuration_settings[CONFIG_SETTINGS_HELM_TENANT_ID] == mock_tenant_id)


with patch('azext_k8s_extension.partner_extensions.WorkloadIAM.Extension.__init__',
with patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.Extension.__init__',
new=mock_extension_init), \
patch('azext_k8s_extension.partner_extensions.WorkloadIAM.WorkloadIAM.get_join_token',
patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.EntraWorkloadIAM.get_join_token',
return_value='BAD_JOIN_TOKEN'):

# Test & assert
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
_, name, _ = workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand All @@ -193,7 +193,7 @@ def test_workload_iam_create_with_trust_domain_local_authority_no_tenant_id(self
}

with self.assertRaises(InvalidArgumentValueError) as context:
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand All @@ -214,7 +214,7 @@ def test_workload_iam_create_with_wrong_scope_fails(self):
bad_scope = 'namespace'

with self.assertRaises(InvalidArgumentValueError) as context:
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope=bad_scope, auto_upgrade_minor_version=None,
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_workload_iam_create_with_not_enough_settings_fails(self):
}

with self.assertRaises(InvalidArgumentValueError) as context:
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand All @@ -268,7 +268,7 @@ def test_workload_iam_create_with_not_enough_settings_fails(self):
}

with self.assertRaises(InvalidArgumentValueError) as context:
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
workload_iam.Create(cmd=None, client=None, resource_group_name=None,
cluster_name=None, name='workload-iam', cluster_type=None, cluster_rp=None,
extension_type=None, scope='cluster', auto_upgrade_minor_version=None,
Expand Down Expand Up @@ -304,10 +304,10 @@ def __init__(self):

self.result = MockResult()

with patch('azext_k8s_extension.partner_extensions.WorkloadIAM.get_default_cli',
with patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.get_default_cli',
return_value=MockCLI()):
# Test & assert
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
join_token = workload_iam.get_join_token(mock_trust_domain_name, mock_local_authority_name)
self.assertEqual(join_token, mock_join_token)

Expand Down Expand Up @@ -344,10 +344,10 @@ def __init__(self):

self.result = MockResult()

with patch('azext_k8s_extension.partner_extensions.WorkloadIAM.get_default_cli',
with patch('azext_k8s_extension.partner_extensions.EntraWorkloadIAM.get_default_cli',
return_value=MockCLI()):
# Test & assert
workload_iam = WorkloadIAM()
workload_iam = EntraWorkloadIAM()
cmd_str = " ".join(cmd)
self.assertRaisesRegex(CLIError,
f"Error while generating a join token. Command: {cmd_str}",
Expand Down