-
Notifications
You must be signed in to change notification settings - Fork 1.5k
containerapp - Add --source and --repo to containerapp create/update #6574
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
Changes from all commits
887ecf6
011439a
e9fd59b
89241ca
916259c
1439120
fb7f4fe
d18d6c7
78181aa
d646bd1
56e68d4
1b70cf5
3a809ca
07e1be5
25862fb
5845255
0b2098b
3fd9fde
557f05e
6c3a58e
d1631be
ab167d0
2af684f
a1afa52
8db50ef
7afbb53
2b21611
5b3b66d
d78c952
6341e8a
608438e
e852926
07c199b
6dc0b8c
620e0c0
79dd20d
358b9bb
82547a3
20a266e
bdba046
14d648e
69e7d44
ee0d465
8df8f34
30b571c
b0f79a5
97eeb45
fb5181d
49e1c6c
1b1ac8f
36a8059
236bbe1
8688b0d
83e7404
9e8d76e
dd6abb3
3ea22fe
f23eda9
091beb0
9918a9a
64912b0
47ea3d7
5139b33
f1ac303
648090d
3aaea4f
1200a8c
a2888b1
85c4302
47f563c
ab09b8c
b77faac
04a738c
0badf02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,7 @@ def load_arguments(self, _): | |
| c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help="Name of the workload profile to run the app on.") | ||
| c.argument('secret_volume_mount', help="Path to mount all secrets e.g. mnt/secrets") | ||
| c.argument('termination_grace_period', type=int, options_list=['--termination-grace-period', '--tgp'], help="Duration in seconds a replica is given to gracefully shut down before it is forcefully terminated. (Default: 30)") | ||
| c.argument('source', help="Local directory path containing the application source and Dockerfile for building the container image. Preview: If no Dockerfile is present, a container image is generated using buildpacks. If Docker is not running or buildpacks cannot be used, Oryx will be used to generate the image. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.", is_preview=True) | ||
|
|
||
| with self.argument_context('containerapp create', arg_group='Identity') as c: | ||
| c.argument('user_assigned', nargs='+', help="Space-separated user identities to be assigned.") | ||
|
|
@@ -137,9 +138,22 @@ def load_arguments(self, _): | |
| c.argument('service_type', help="The service information for dev services.") | ||
| c.ignore('service_type') | ||
|
|
||
| with self.argument_context('containerapp create', arg_group='GitHub Repository', is_preview=True) as c: | ||
| c.argument('repo', help='Create an app via GitHub Actions in the format: https://github.com/<owner>/<repository-name> or <owner>/<repository-name>') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| 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. If not provided or not found in the cache (and using --repo), a browser page will be opened to authenticate with Github.') | ||
| c.argument('branch', options_list=['--branch', '-b'], help='Branch in the provided GitHub repository. Assumed to be the GitHub repository\'s default branch if not specified.') | ||
| c.argument('context_path', help='Path in the repository to run docker build. Defaults to "./". Dockerfile is assumed to be named "Dockerfile" and in this directory.') | ||
snehapar9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| c.argument('service_principal_client_id', help='The service principal client ID. Used by GitHub Actions to authenticate with Azure.', options_list=["--service-principal-client-id", "--sp-cid"]) | ||
| c.argument('service_principal_client_secret', help='The service principal client secret. Used by GitHub Actions to authenticate with Azure.', options_list=["--service-principal-client-secret", "--sp-sec"]) | ||
| c.argument('service_principal_tenant_id', help='The service principal tenant ID. Used by GitHub Actions to authenticate with Azure.', options_list=["--service-principal-tenant-id", "--sp-tid"]) | ||
|
|
||
| with self.argument_context('containerapp show') as c: | ||
| c.argument('show_secrets', help="Show Containerapp secrets.", action='store_true') | ||
|
|
||
| # Source | ||
| with self.argument_context('containerapp update') as c: | ||
| c.argument('source', help="Local directory path containing the application source and Dockerfile for building the container image. Preview: If no Dockerfile is present, a container image is generated using buildpacks. If Docker is not running or buildpacks cannot be used, Oryx will be used to generate the image. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.", is_preview=True) | ||
|
|
||
| with self.argument_context('containerapp update', arg_group='Container') as c: | ||
| c.argument('image', options_list=['--image', '-i'], help="Container image, e.g. publisher/image-name:tag.") | ||
| c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help='The friendly name for the workload profile') | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |||||
|
|
||||||
| import re | ||||||
| from azure.cli.core.azclierror import (ValidationError, ResourceNotFoundError, InvalidArgumentValueError, | ||||||
| MutuallyExclusiveArgumentError) | ||||||
| MutuallyExclusiveArgumentError, RequiredArgumentMissingError) | ||||||
| from msrestazure.tools import is_valid_resource_id | ||||||
| from knack.log import get_logger | ||||||
|
|
||||||
|
|
@@ -15,13 +15,31 @@ | |||||
| from ._utils import safe_get, is_registry_msi_system | ||||||
| from ._constants import ACR_IMAGE_SUFFIX, LOG_TYPE_SYSTEM, CONNECTED_ENVIRONMENT_RESOURCE_TYPE, \ | ||||||
| CONNECTED_ENVIRONMENT_TYPE, MANAGED_ENVIRONMENT_RESOURCE_TYPE, MANAGED_ENVIRONMENT_TYPE, CONTAINER_APPS_RP, \ | ||||||
| EXTENDED_LOCATION_RP, CUSTOM_LOCATION_RESOURCE_TYPE | ||||||
| EXTENDED_LOCATION_RP, CUSTOM_LOCATION_RESOURCE_TYPE, MAXIMUM_SECRET_LENGTH | ||||||
| from urllib.parse import urlparse | ||||||
|
|
||||||
| logger = get_logger(__name__) | ||||||
|
|
||||||
|
|
||||||
| # called directly from custom method bc otherwise it disrupts the --environment auto RID functionality | ||||||
| def validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait): | ||||||
| def validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait, source=None, repo=None, yaml=None, environment_type=None): | ||||||
| if source and repo: | ||||||
| raise MutuallyExclusiveArgumentError("Usage error: --source and --repo cannot be used together. Can either deploy from a local directory or a GitHub repository") | ||||||
| if (source or repo) and yaml: | ||||||
| raise MutuallyExclusiveArgumentError("Usage error: --source or --repo cannot be used with --yaml together. Can either deploy from a local directory or provide a yaml file") | ||||||
| if (source or repo) and environment_type == CONNECTED_ENVIRONMENT_TYPE: | ||||||
| raise MutuallyExclusiveArgumentError("Usage error: --source or --repo cannot be used with --environment-type connectedEnvironment together. Please use --environment-type managedEnvironment") | ||||||
| if source or repo: | ||||||
| if not registry_server: | ||||||
| raise RequiredArgumentMissingError('Usage error: --registry-server is required while using --source or --repo') | ||||||
| if ACR_IMAGE_SUFFIX not in registry_server: | ||||||
| raise InvalidArgumentValueError("Usage error: --registry-server: expected an ACR registry (*.azurecr.io) for --source or --repo") | ||||||
| if repo and registry_server and "azurecr.io" in registry_server: | ||||||
| parsed = urlparse(registry_server) | ||||||
| registry_name = (parsed.netloc if parsed.scheme else parsed.path).split(".")[0] | ||||||
| if registry_name and len(registry_name) > MAXIMUM_SECRET_LENGTH: | ||||||
| raise ValidationError(f"--registry-server ACR name must be less than {MAXIMUM_SECRET_LENGTH} " | ||||||
snehapar9 marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for taking a look! Just going to keep it as-is so we are consistent with this validation in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||||||
| "characters when using --repo") | ||||||
| if registry_identity and (registry_pass or registry_user): | ||||||
| raise MutuallyExclusiveArgumentError("Cannot provide both registry identity and username/password") | ||||||
| if is_registry_msi_system(registry_identity) and no_wait: | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.