Skip to content

Commit

Permalink
fix: 🐛 Standard/Basic use old api for blue-green (#4602)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwzho committed Apr 7, 2022
1 parent 0478b7f commit f0f1978
Show file tree
Hide file tree
Showing 5 changed files with 592 additions and 219 deletions.
5 changes: 5 additions & 0 deletions src/spring-cloud/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release History
===============
3.1.3
---
* Revert new RBAC requirement for Standard and Basic sku Spring resource for `az spring-cloud app set-deployment` and `az spring-cloud app unset-deployment` commands.

3.1.2
---
* Find min version requirement for Azure CLI Core.
Expand Down Expand Up @@ -28,6 +32,7 @@ Release History
* [BREAKING CHANGE] `az spring-cloud app` command output: Remove "properties.activeDeployment.properties.deploymentSettings.jvmOptions", use "properties.activeDeployment.properties.source.jvmOptions" instead.
* [BREAKING CHANGE] `az spring-cloud app` command output: Remove "properties.activeDeployment.properties.deploymentSettings.runtimeVersion", use "properties.activeDeployment.properties.source.runtimeVersion" instead.
* [BREAKING CHANGE] `az spring-cloud app` command output: Remove "properties.activeDeployment.properties.deploymentSettings.netCoreMainEntryPath", use "properties.activeDeployment.properties.source.netCoreMainEntryPath" instead.
* [BREAKING CHANGE] RBAC change requirement for `az spring-cloud app set-deployment` and `az spring-cloud app unset-deployment` commands.

2.12.3
---
Expand Down
30 changes: 24 additions & 6 deletions src/spring-cloud/azext_spring_cloud/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from time import sleep
from ._stream_utils import stream_logs
from azure.mgmt.core.tools import (parse_resource_id, is_valid_resource_id)
from ._utils import (get_portal_uri, wait_till_end)
from ._utils import (get_portal_uri, get_spring_cloud_sku)
from knack.util import CLIError
from .vendored_sdks.appplatform.v2020_07_01 import models
from .vendored_sdks.appplatform.v2020_11_01_preview import models as models_20201101preview
Expand All @@ -24,6 +24,7 @@
from .vendored_sdks.appplatform.v2020_11_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20201101preview
)
from ._client_factory import (cf_spring_cloud)
from knack.log import get_logger
from azure.cli.core.azclierror import ClientRequestError, FileOperationError, InvalidArgumentValueError
from azure.cli.core.commands.client_factory import get_mgmt_service_client
Expand Down Expand Up @@ -400,19 +401,36 @@ def app_tail_log(cmd, client, resource_group, service, name,


def app_set_deployment(cmd, client, resource_group, service, name, deployment):
active_deployment_collection = models_20220101preview.ActiveDeploymentCollection(
active_deployment_names=[deployment]
)
return client.apps.begin_set_active_deployments(resource_group, service, name, active_deployment_collection)
sku = get_spring_cloud_sku(client, resource_group, service)
if sku.tier == 'Enterprise':
return _set_active_in_preview_api(cmd, client, resource_group, service, name, deployment)
else:
return _set_active_in_lagecy_api(cmd, client, resource_group, service, name, deployment)


def app_unset_deployment(cmd, client, resource_group, service, name):
sku = get_spring_cloud_sku(client, resource_group, service)
if sku.tier == 'Enterprise':
return _set_active_in_preview_api(cmd, client, resource_group, service, name)
else:
return _set_active_in_lagecy_api(cmd, client, resource_group, service, name)


def _set_active_in_preview_api(cmd, client, resource_group, service, name, deployment=None):
active_deployment_collection = models_20220101preview.ActiveDeploymentCollection(
active_deployment_names=[]
active_deployment_names=[x for x in [deployment] if x is not None]
)
return client.apps.begin_set_active_deployments(resource_group, service, name, active_deployment_collection)


def _set_active_in_lagecy_api(cmd, client, resource_group, service, name, deployment=''):
app = models.AppResource(
properties=models.AppResourceProperties(active_deployment_name=deployment)
)
client = cf_spring_cloud(cmd.cli_ctx)
return client.apps.begin_update(resource_group, service, name, app)


def app_append_loaded_public_certificate(cmd, client, resource_group, service, name, certificate_name, load_trust_store):
app_resource = client.apps.get(resource_group, service, name)
certificate_resource = client.certificates.get(resource_group, service, certificate_name)
Expand Down
Loading

0 comments on commit f0f1978

Please sign in to comment.