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

Added user-assigned and system-assigned to containerapp create. #62

Merged
merged 1 commit into from
Apr 11, 2022
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
7 changes: 5 additions & 2 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ def load_arguments(self, _):
c.argument('transport', arg_type=get_enum_type(['auto', 'http', 'http2']), help="The transport protocol used for ingress traffic.")

with self.argument_context('containerapp create') as c:
c.argument('assign_identity', nargs='+', help="Space-separated identities. Use '[system]' to refer to the system assigned identity.")
c.argument('traffic_weights', nargs='*', options_list=['--traffic-weight'], help="A list of revision weight(s) for the container app. Space-separated values in 'revision_name=weight' format. For latest revision, use 'latest=weight'")

with self.argument_context('containerapp create', arg_group='Identity') as c:
c.argument('user_assigned', nargs='+', help="Space-separated user identities to be assigned.")
c.argument('system_assigned', help="Boolean indicating whether to assign system-assigned identity.")

with self.argument_context('containerapp scale') as c:
c.argument('min_replicas', type=int, help="The minimum number of replicas.")
c.argument('max_replicas', type=int, help="The maximum number of replicas.")
Expand Down Expand Up @@ -115,7 +118,7 @@ def load_arguments(self, _):

with self.argument_context('containerapp identity') as c:
c.argument('user_assigned', nargs='+', help="Space-separated user identities.")
c.argument('system_assigned', help="System-assigned identity.")
c.argument('system_assigned', help="Boolean indicating whether to assign system-assigned identity.")

with self.argument_context('containerapp identity remove') as c:
c.argument('user_assigned', nargs='*', help="Space-separated user identities. If no user identities are specified, all user identities will be removed.")
Expand Down
13 changes: 7 additions & 6 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def create_containerapp(cmd,
args=None,
tags=None,
no_wait=False,
assign_identity=None):
system_assigned=False,
user_assigned=None):
_validate_subscription_registered(cmd, "Microsoft.App")

if yaml:
Expand All @@ -310,9 +311,6 @@ def create_containerapp(cmd,
if managed_env is None:
raise RequiredArgumentMissingError('Usage error: --environment is required if not using --yaml')

if assign_identity is None:
assign_identity = []

# Validate managed environment
parsed_managed_env = parse_resource_id(managed_env)
managed_env_name = parsed_managed_env['name']
Expand Down Expand Up @@ -382,8 +380,11 @@ def create_containerapp(cmd,
identity_def = ManagedServiceIdentityModel
identity_def["type"] = "None"

assign_system_identity = '[system]' in assign_identity
assign_user_identities = [x for x in assign_identity if x != '[system]']
assign_system_identity = system_assigned
if user_assigned:
assign_user_identities = [x.lower() for x in user_assigned]
else:
assign_user_identities = []

if assign_system_identity and assign_user_identities:
identity_def["type"] = "SystemAssigned, UserAssigned"
Expand Down