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

Remove managed identities for first release #54

Merged
merged 1 commit into from
Mar 24, 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
39 changes: 0 additions & 39 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,45 +264,6 @@
az containerapp env dapr-component remove -g MyResourceGroup --dapr-component-name MyDaprComponentName --name MyEnvironment
"""

# Identity Commands
helps['containerapp identity'] = """
type: group
short-summary: Commands to manage managed identities.
"""

helps['containerapp identity assign'] = """
type: command
short-summary: Assign managed identity to a container app.
long-summary: Managed identities can be user-assigned or system-assigned.
examples:
- name: Assign system identity.
text: |
az containerapp identity assign
- name: Assign user identity.
text: |
az containerapp identity assign --identities myAssignedId
- name: Assign system and user identity.
text: |
az containerapp identity assign --identities [system] myAssignedId
"""

helps['containerapp identity remove'] = """
type: command
short-summary: Remove a managed identity from a container app.
examples:
- name: Remove system identity.
text: |
az containerapp identity remove --identities [system]
- name: Remove system and user identity.
text: |
az containerapp identity remove --identities [system] myAssignedId
"""

helps['containerapp identity show'] = """
type: command
short-summary: Show managed identities of a container app.
"""

# Ingress Commands
helps['containerapp ingress'] = """
type: group
Expand Down
7 changes: 0 additions & 7 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ 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 scale') as c:
Expand Down Expand Up @@ -113,12 +112,6 @@ def load_arguments(self, _):
with self.argument_context('containerapp env show') as c:
c.argument('name', name_type, help='Name of the Container Apps Environment.')

with self.argument_context('containerapp identity') as c:
c.argument('identities', nargs='+', help="Space-separated identities. Use '[system]' to refer to the system assigned identity.")

with self.argument_context('containerapp identity assign') as c:
c.argument('identities', nargs='+', help="Space-separated identities. Use '[system]' to refer to the system assigned identity. Default is '[system]'.")

with self.argument_context('containerapp github-action add') as c:
c.argument('repo_url', help='The GitHub repository to which the workflow file will be added. In the format: https://github.com/<owner>/<repository-name>')
c.argument('token', help='A Personal Access Token with write access to the specified repository. For more information: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line')
Expand Down
5 changes: 0 additions & 5 deletions src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ def load_command_table(self, _):
g.custom_command('set', 'create_or_update_dapr_component')
g.custom_command('remove', 'remove_dapr_component')

with self.command_group('containerapp identity') as g:
g.custom_command('assign', 'assign_managed_identity', supports_no_wait=True, exception_handler=ex_handler_factory())
g.custom_command('remove', 'remove_managed_identity', supports_no_wait=True, exception_handler=ex_handler_factory())
g.custom_show_command('show', 'show_managed_identity')

with self.command_group('containerapp github-action') as g:
g.custom_command('add', 'create_or_update_github_action', exception_handler=ex_handler_factory())
g.custom_show_command('show', 'show_github_action', exception_handler=ex_handler_factory())
Expand Down
29 changes: 1 addition & 28 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ def create_containerapp(cmd,
startup_command=None,
args=None,
tags=None,
no_wait=False,
assign_identity=None):
no_wait=False):
_validate_subscription_registered(cmd, "Microsoft.App")

if yaml:
Expand All @@ -310,9 +309,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 @@ -378,28 +374,6 @@ def create_containerapp(cmd,
config_def["registries"] = [registries_def] if registries_def is not None else None
config_def["dapr"] = dapr_def

# Identity actions
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]']

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

if assign_user_identities:
identity_def["userAssignedIdentities"] = {}
subscription_id = get_subscription_id(cmd.cli_ctx)

for r in assign_user_identities:
r = _ensure_identity_resource_id(subscription_id, resource_group_name, r)
identity_def["userAssignedIdentities"][r] = {} # pylint: disable=unsupported-assignment-operation

scale_def = None
if min_replicas is not None or max_replicas is not None:
scale_def = ScaleModel
Expand Down Expand Up @@ -433,7 +407,6 @@ def create_containerapp(cmd,

containerapp_def = ContainerAppModel
containerapp_def["location"] = location
containerapp_def["identity"] = identity_def
containerapp_def["properties"]["managedEnvironmentId"] = managed_env
containerapp_def["properties"]["configuration"] = config_def
containerapp_def["properties"]["template"] = template_def
Expand Down