Skip to content

Commit d909f88

Browse files
committed
[AKS] : allow updating only --bootstrap-container-registry-resource-id
1 parent 90ddf06 commit d909f88

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8388,8 +8388,10 @@ def update_bootstrap_profile(self, mc: ManagedCluster) -> ManagedCluster:
83888388

83898389
bootstrap_artifact_source = self.context.get_bootstrap_artifact_source()
83908390
bootstrap_container_registry_resource_id = self.context.get_bootstrap_container_registry_resource_id()
8391-
if hasattr(mc, "bootstrap_profile") and bootstrap_artifact_source is not None:
8392-
if bootstrap_artifact_source != CONST_ARTIFACT_SOURCE_CACHE and bootstrap_container_registry_resource_id:
8391+
if hasattr(mc, "bootstrap_profile"):
8392+
if bootstrap_artifact_source is None and mc.bootstrap_profile is not None:
8393+
bootstrap_artifact_source = mc.bootstrap_profile.artifact_source # backfill from existing mc
8394+
if (bootstrap_artifact_source is None or bootstrap_artifact_source != CONST_ARTIFACT_SOURCE_CACHE) and bootstrap_container_registry_resource_id:
83938395
raise MutuallyExclusiveArgumentError(
83948396
"Cannot specify --bootstrap-container-registry-resource-id when "
83958397
"--bootstrap-artifact-source is not Cache."

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11111,6 +11111,63 @@ def test_update_bootstrap_profile(self):
1111111111
with self.assertRaises(MutuallyExclusiveArgumentError):
1111211112
dec_mc_6 = dec_6.update_bootstrap_profile(mc_6)
1111311113

11114+
dec_7 = AKSManagedClusterUpdateDecorator(
11115+
self.cmd,
11116+
self.client,
11117+
{
11118+
"bootstrap_container_registry_resource_id": acr_id_1,
11119+
},
11120+
ResourceType.MGMT_CONTAINERSERVICE,
11121+
)
11122+
mc_7 = self.models.ManagedCluster(location="test_location")
11123+
dec_7.context.attach_mc(mc_7)
11124+
with self.assertRaises(MutuallyExclusiveArgumentError):
11125+
dec_mc_7 = dec_7.update_bootstrap_profile(mc_7)
11126+
11127+
dec_8 = AKSManagedClusterUpdateDecorator(
11128+
self.cmd,
11129+
self.client,
11130+
{
11131+
"bootstrap_container_registry_resource_id": acr_id_1,
11132+
},
11133+
ResourceType.MGMT_CONTAINERSERVICE,
11134+
)
11135+
mc_8 = self.models.ManagedCluster(
11136+
location="test_location",
11137+
bootstrap_profile=self.models.ManagedClusterBootstrapProfile(
11138+
artifact_source="Direct",
11139+
),
11140+
)
11141+
dec_8.context.attach_mc(mc_8)
11142+
with self.assertRaises(MutuallyExclusiveArgumentError):
11143+
dec_mc_8 = dec_8.update_bootstrap_profile(mc_8)
11144+
11145+
dec_9 = AKSManagedClusterUpdateDecorator(
11146+
self.cmd,
11147+
self.client,
11148+
{
11149+
"bootstrap_container_registry_resource_id": acr_id_2,
11150+
},
11151+
ResourceType.MGMT_CONTAINERSERVICE,
11152+
)
11153+
mc_9 = self.models.ManagedCluster(
11154+
location="test_location",
11155+
bootstrap_profile=self.models.ManagedClusterBootstrapProfile(
11156+
artifact_source="Cache",
11157+
container_registry_id=acr_id_1,
11158+
),
11159+
)
11160+
dec_9.context.attach_mc(mc_9)
11161+
dec_mc_9 = dec_9.update_bootstrap_profile(mc_9)
11162+
ground_truth_mc_9 = self.models.ManagedCluster(
11163+
location="test_location",
11164+
bootstrap_profile=self.models.ManagedClusterBootstrapProfile(
11165+
artifact_source="Cache",
11166+
container_registry_id=acr_id_2,
11167+
),
11168+
)
11169+
self.assertEqual(dec_mc_9, ground_truth_mc_9)
11170+
1111411171
def test_update_mc_profile_default(self):
1111511172
import inspect
1111611173

0 commit comments

Comments
 (0)