Skip to content

Commit

Permalink
Added user-assigned and system-assigned to containerapp create. (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: Haroon Feisal <haroonfeisal@microsoft.com>
  • Loading branch information
runefa and Haroon Feisal authored Apr 11, 2022
1 parent a1929c8 commit df5cc99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
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

0 comments on commit df5cc99

Please sign in to comment.