Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -8388,8 +8388,10 @@ def update_bootstrap_profile(self, mc: ManagedCluster) -> ManagedCluster:

bootstrap_artifact_source = self.context.get_bootstrap_artifact_source()
bootstrap_container_registry_resource_id = self.context.get_bootstrap_container_registry_resource_id()
if hasattr(mc, "bootstrap_profile") and bootstrap_artifact_source is not None:
if bootstrap_artifact_source != CONST_ARTIFACT_SOURCE_CACHE and bootstrap_container_registry_resource_id:
if hasattr(mc, "bootstrap_profile"):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new or update an existing live test case to cover this scenario

if bootstrap_artifact_source is None and mc.bootstrap_profile is not None:
bootstrap_artifact_source = mc.bootstrap_profile.artifact_source # backfill from existing mc
if (bootstrap_artifact_source is None or bootstrap_artifact_source != CONST_ARTIFACT_SOURCE_CACHE) and bootstrap_container_registry_resource_id:
raise MutuallyExclusiveArgumentError(
"Cannot specify --bootstrap-container-registry-resource-id when "
"--bootstrap-artifact-source is not Cache."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11111,6 +11111,63 @@ def test_update_bootstrap_profile(self):
with self.assertRaises(MutuallyExclusiveArgumentError):
dec_mc_6 = dec_6.update_bootstrap_profile(mc_6)

dec_7 = AKSManagedClusterUpdateDecorator(
self.cmd,
self.client,
{
"bootstrap_container_registry_resource_id": acr_id_1,
},
ResourceType.MGMT_CONTAINERSERVICE,
)
mc_7 = self.models.ManagedCluster(location="test_location")
dec_7.context.attach_mc(mc_7)
with self.assertRaises(MutuallyExclusiveArgumentError):
dec_mc_7 = dec_7.update_bootstrap_profile(mc_7)

dec_8 = AKSManagedClusterUpdateDecorator(
self.cmd,
self.client,
{
"bootstrap_container_registry_resource_id": acr_id_1,
},
ResourceType.MGMT_CONTAINERSERVICE,
)
mc_8 = self.models.ManagedCluster(
location="test_location",
bootstrap_profile=self.models.ManagedClusterBootstrapProfile(
artifact_source="Direct",
),
)
dec_8.context.attach_mc(mc_8)
with self.assertRaises(MutuallyExclusiveArgumentError):
dec_mc_8 = dec_8.update_bootstrap_profile(mc_8)

dec_9 = AKSManagedClusterUpdateDecorator(
self.cmd,
self.client,
{
"bootstrap_container_registry_resource_id": acr_id_2,
},
ResourceType.MGMT_CONTAINERSERVICE,
)
mc_9 = self.models.ManagedCluster(
location="test_location",
bootstrap_profile=self.models.ManagedClusterBootstrapProfile(
artifact_source="Cache",
container_registry_id=acr_id_1,
),
)
dec_9.context.attach_mc(mc_9)
dec_mc_9 = dec_9.update_bootstrap_profile(mc_9)
ground_truth_mc_9 = self.models.ManagedCluster(
location="test_location",
bootstrap_profile=self.models.ManagedClusterBootstrapProfile(
artifact_source="Cache",
container_registry_id=acr_id_2,
),
)
self.assertEqual(dec_mc_9, ground_truth_mc_9)

def test_update_mc_profile_default(self):
import inspect

Expand Down Expand Up @@ -11197,13 +11254,18 @@ def test_update_mc_profile_default(self):
blob_csi_driver=None,
snapshot_controller=None,
)
bootstrap_profile_1 = self.models.ManagedClusterBootstrapProfile(
artifact_source=None,
container_registry_id=None,
)
ground_truth_mc_1 = self.models.ManagedCluster(
location="test_location",
agent_pool_profiles=[ground_truth_agent_pool_profile_1],
network_profile=ground_truth_network_profile_1,
identity=ground_truth_identity_1,
identity_profile=ground_truth_identity_profile_1,
storage_profile=ground_truth_storage_profile_1,
bootstrap_profile=bootstrap_profile_1,
)
self.assertEqual(dec_mc_1, ground_truth_mc_1)

Expand Down
Loading