Skip to content

Commit

Permalink
[Containerapp] 'az containerapp create/update': Support --max-inactiv…
Browse files Browse the repository at this point in the history
…e-revisions (#7229)
  • Loading branch information
njuCZ authored Jan 31, 2024
1 parent 78969ac commit 84af13e
Show file tree
Hide file tree
Showing 7 changed files with 12,558 additions and 2,628 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ upcoming
* 'az containerapp add-on' : support for add-on weaviate create and delete commands
* Upgrade api-version to 2023-11-02-preview
* 'az containerapp create/update/up': support --build-env-vars to set environment variables for build
* 'az containerapp create/update': support --max-inactive-revisions

0.3.46
++++++
Expand Down
2 changes: 2 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def load_arguments(self, _):
c.argument('artifact', help="Local path to the application artifact for building the container image. See the supported artifacts here: https://aka.ms/SourceToCloudSupportedArtifacts.", is_preview=True)
c.argument('build_env_vars', nargs='*', help="A list of environment variable(s) for the build. Space-separated values in 'key=value' format.",
validator=validate_build_env_vars, is_preview=True)
c.argument('max_inactive_revisions', type=int, help="Max inactive revisions a Container App can have.", is_preview=True)

# Springboard
with self.argument_context('containerapp create', arg_group='Service Binding', is_preview=True) as c:
Expand All @@ -48,6 +49,7 @@ def load_arguments(self, _):
c.argument('artifact', help="Local path to the application artifact for building the container image. See the supported artifacts here: https://aka.ms/SourceToCloudSupportedArtifacts.", is_preview=True)
c.argument('build_env_vars', nargs='*', help="A list of environment variable(s) for the build. Space-separated values in 'key=value' format.",
validator=validate_build_env_vars, is_preview=True)
c.argument('max_inactive_revisions', type=int, help="Max inactive revisions a Container App can have.", is_preview=True)

# Springboard
with self.argument_context('containerapp update', arg_group='Service Binding', is_preview=True) as c:
Expand Down
8 changes: 8 additions & 0 deletions src/containerapp/azext_containerapp/containerapp_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ def construct_payload(self):
self.set_up_extended_location()
self.set_up_source()
self.set_up_repo()
if self.get_argument_max_inactive_revisions() is not None:
safe_set(self.containerapp_def, "properties", "configuration", "maxInactiveRevisions", value=self.get_argument_max_inactive_revisions())

def validate_arguments(self):
super().validate_arguments()
Expand Down Expand Up @@ -967,6 +969,8 @@ def get_argument_service_principal_client_secret(self):
def get_argument_service_principal_tenant_id(self):
return self.get_param("service_principal_tenant_id")

def get_argument_max_inactive_revisions(self):
return self.get_param("max_inactive_revisions")

# decorator for preview update
class ContainerAppPreviewUpdateDecorator(ContainerAppUpdateDecorator):
Expand Down Expand Up @@ -1008,6 +1012,8 @@ def construct_payload(self):
self.set_up_service_bindings()
self.set_up_unbind_service_bindings()
self.set_up_source()
if self.get_argument_max_inactive_revisions() is not None:
safe_set(self.new_containerapp, "properties", "configuration", "maxInactiveRevisions", value=self.get_argument_max_inactive_revisions())

def set_up_source(self):
from ._up_utils import (_validate_source_artifact_args)
Expand Down Expand Up @@ -1172,6 +1178,8 @@ def set_up_unbind_service_bindings(self):
new_template["serviceBinds"] = [binding for binding in new_template["serviceBinds"] if
binding["name"] != item]

def get_argument_max_inactive_revisions(self):
return self.get_param("max_inactive_revisions")

# decorator for preview list
class ContainerAppPreviewListDecorator(BaseContainerAppDecorator):
Expand Down
12 changes: 8 additions & 4 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def create_containerapp(cmd,
context_path=None,
service_principal_client_id=None,
service_principal_client_secret=None,
service_principal_tenant_id=None):
service_principal_tenant_id=None,
max_inactive_revisions=None):
raw_parameters = locals()

containerapp_create_decorator = ContainerAppPreviewCreateDecorator(
Expand Down Expand Up @@ -495,7 +496,8 @@ def update_containerapp_logic(cmd,
secret_volume_mount=None,
source=None,
artifact=None,
build_env_vars=None):
build_env_vars=None,
max_inactive_revisions=None):
raw_parameters = locals()

containerapp_update_decorator = ContainerAppPreviewUpdateDecorator(
Expand Down Expand Up @@ -545,7 +547,8 @@ def update_containerapp(cmd,
secret_volume_mount=None,
source=None,
artifact=None,
build_env_vars=None):
build_env_vars=None,
max_inactive_revisions=None):
_validate_subscription_registered(cmd, CONTAINER_APPS_RP)

return update_containerapp_logic(cmd=cmd,
Expand Down Expand Up @@ -580,7 +583,8 @@ def update_containerapp(cmd,
secret_volume_mount=secret_volume_mount,
source=source,
artifact=artifact,
build_env_vars=build_env_vars)
build_env_vars=build_env_vars,
max_inactive_revisions=max_inactive_revisions)


def show_containerapp(cmd, name, resource_group_name, show_secrets=False):
Expand Down
Loading

0 comments on commit 84af13e

Please sign in to comment.