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

[Containerapp] az containerapp env java-component: Support Java component #7216

Merged
merged 84 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
05c9d44
Merge pull request #1 from Azure/main
ShichaoQiu Oct 10, 2023
add1314
Merge pull request #2 from Azure/main
ShichaoQiu Oct 26, 2023
9834a50
Merge pull request #3 from Azure/main
ShichaoQiu Nov 2, 2023
d662917
Merge pull request #4 from Azure/main
ShichaoQiu Dec 28, 2023
870148d
initial commit for Java components
ShichaoQiu Dec 28, 2023
dedf118
add JavaComponentPreviewClient in _clients.py
ShichaoQiu Jan 10, 2024
ddc31a6
add "az containerapp env java-component list"
ShichaoQiu Jan 10, 2024
6bd2f69
add show and delete command for Java component
ShichaoQiu Jan 10, 2024
e564bfd
use different show and delete method for different java components
ShichaoQiu Jan 22, 2024
a712be3
refine show and delete logic
ShichaoQiu Jan 22, 2024
3841e53
add create and update command
ShichaoQiu Jan 23, 2024
e01e835
refine resource not found error
ShichaoQiu Jan 24, 2024
1881249
refine model
ShichaoQiu Jan 24, 2024
0dcfa41
update client
ShichaoQiu Jan 25, 2024
61d3270
add configuration parameter
ShichaoQiu Jan 25, 2024
0d951e8
fix patch command
ShichaoQiu Jan 25, 2024
766790e
refine logic
ShichaoQiu Jan 25, 2024
31ba758
add bind
ShichaoQiu Jan 26, 2024
9d9dec6
fix bindname bug
ShichaoQiu Jan 26, 2024
302b9d5
Merge pull request #5 from Azure/main
ShichaoQiu Jan 26, 2024
b9bb598
Merge remote-tracking branch 'remotes/origin/shiqiu/javaComponent2024…
ShichaoQiu Jan 26, 2024
656e382
fix comments
ShichaoQiu Jan 26, 2024
7c37f06
fix comments
ShichaoQiu Jan 26, 2024
8f33f1f
fix azdev linter error
ShichaoQiu Jan 29, 2024
28a90c4
fix linter error
ShichaoQiu Jan 29, 2024
1954ff7
fix comments
ShichaoQiu Jan 31, 2024
dc7bf6e
fix comment
ShichaoQiu Jan 31, 2024
9643253
fix comment
ShichaoQiu Jan 31, 2024
84c5691
Merge pull request #6 from Azure/main
ShichaoQiu Jan 31, 2024
b66c373
add test for java component
ShichaoQiu Jan 31, 2024
52d1600
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Jan 31, 2024
6d80d83
fix comment
ShichaoQiu Jan 31, 2024
b277b2f
Merge branch 'Azure:main' into main
ShichaoQiu Feb 1, 2024
888640a
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 1, 2024
8550d3d
fix bug
ShichaoQiu Feb 1, 2024
b0ddbeb
update test
ShichaoQiu Feb 1, 2024
f23b538
refine delete logic
ShichaoQiu Feb 2, 2024
c42a6cd
fix comment
ShichaoQiu Feb 2, 2024
80d31a8
Merge branch 'Azure:main' into main
ShichaoQiu Feb 2, 2024
fcead1b
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 2, 2024
7f17de4
fix test error
ShichaoQiu Feb 3, 2024
0fd48e2
fix test issue
ShichaoQiu Feb 3, 2024
524e00f
fix test error
ShichaoQiu Feb 3, 2024
834716c
fix test error
ShichaoQiu Feb 3, 2024
78c5aa6
fix test error
ShichaoQiu Feb 3, 2024
70a7f45
fix test error
ShichaoQiu Feb 3, 2024
16eea5a
fix comments
ShichaoQiu Feb 4, 2024
82f3cf4
fix comment
ShichaoQiu Feb 4, 2024
f21c4a9
Merge branch 'Azure:main' into main
ShichaoQiu Feb 18, 2024
3d47496
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 18, 2024
e352323
Merge branch 'Azure:main' into main
ShichaoQiu Feb 18, 2024
17fbb89
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 18, 2024
48f1f27
fix test error test_containerapp_addon_binding_e2e
ShichaoQiu Feb 18, 2024
2bb350d
fix test error - test_containerapp_dev_add_on_binding_customized_keys…
ShichaoQiu Feb 18, 2024
7f5e0de
fix test error - test_containerapp_dev_add_on_binding_e2e
ShichaoQiu Feb 18, 2024
f51907e
fix test error - test_containerapp_dev_add_on_binding_none_client_type
ShichaoQiu Feb 18, 2024
89d20a8
fix test error - test_containerapp_dev_service_binding_customized_key…
ShichaoQiu Feb 18, 2024
d621496
fix test error - test_containerapp_dev_service_binding_customized_key…
ShichaoQiu Feb 18, 2024
63b635b
fix test error - test_containerapp_dev_service_binding_none_client_type
ShichaoQiu Feb 18, 2024
7062fa5
fix test error - test_containerapp_managed_service_binding_e2e
ShichaoQiu Feb 18, 2024
261ec2e
fix test error - test_containerapp_dev_add_on_binding_customized_keys…
ShichaoQiu Feb 18, 2024
a0bcf12
fix test error - test_containerapp_dev_service_binding_e2e
ShichaoQiu Feb 19, 2024
c883393
remove binding name validation
ShichaoQiu Feb 19, 2024
b868ee4
update HISTORY.rst
ShichaoQiu Feb 21, 2024
b33e16a
Merge branch 'Azure:main' into main
ShichaoQiu Feb 21, 2024
af7ff01
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 21, 2024
5bdf0fe
Revert "remove binding name validation"
ShichaoQiu Feb 21, 2024
96270f8
add special logic to deal with java component binding name
ShichaoQiu Feb 21, 2024
085e763
update unbind logic
ShichaoQiu Feb 22, 2024
b9b3be8
refine the model definition
ShichaoQiu Feb 22, 2024
b9d210e
fix test - test_containerapp_java_component
ShichaoQiu Feb 22, 2024
556461d
Merge branch 'Azure:main' into main
ShichaoQiu Feb 22, 2024
bf5cd46
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 22, 2024
345dd1b
Merge branch 'Azure:main' into main
ShichaoQiu Feb 22, 2024
8f7f211
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 22, 2024
1a91393
fix test error
ShichaoQiu Feb 22, 2024
a7210ea
Merge branch 'Azure:main' into main
ShichaoQiu Feb 23, 2024
fb9544e
fix comments
ShichaoQiu Feb 23, 2024
6428dd6
Merge remote-tracking branch 'remotes/origin/main' into shiqiu/JavaCo…
ShichaoQiu Feb 23, 2024
35d5587
fix comment
ShichaoQiu Feb 23, 2024
fb8f923
fix comment
ShichaoQiu Feb 23, 2024
5a2c14c
fix comment
ShichaoQiu Feb 26, 2024
fb5b6eb
fix comment
ShichaoQiu Feb 27, 2024
3a2ddd2
fix comment
ShichaoQiu Feb 27, 2024
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
4 changes: 4 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ upcoming
* 'az containerapp env dapr-component resiliency': Add support for Dapr Component Resiliency Circuit Breakers
* 'az containerapp create/update/up': Don't compress jar/war/zip file before upload source code
* 'az containerapp create/update/up': Update source to cloud builder to 20240124.1
* 'az containerapp env java-component': Support list Java components
* 'az containerapp env java-component spring-cloud-config': Support create/update/show/delete Spring Cloud Config
* 'az containerapp env java-component spring-cloud-eureka': Support create/update/show/delete Spring Cloud Eureka
* 'az containerapp create/update': Support bind Java component with --bind

0.3.47
++++++
Expand Down
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def handle_non_404_exception(e):
def handle_non_404_status_code_exception(e):
import json

if hasattr(e, 'status_code') and e.status_code == 404:
if (hasattr(e, 'status_code') and e.status_code == 404) or (hasattr(e, 'response') and hasattr(e.response, 'status_code') and e.response.status_code == 404):
return e

string_err = str(e)
Expand Down
117 changes: 117 additions & 0 deletions src/containerapp/azext_containerapp/_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,3 +873,120 @@ def list_auth_token(cls, cmd, builder_name, build_name, resource_group_name, loc
}
r = send_raw_request(cmd.cli_ctx, "POST", request_url, body=json.dumps(body_data))
return r.json()


class JavaComponentPreviewClient():
api_version = PREVIEW_API_VERSION

@classmethod
def create(cls, cmd, resource_group_name, environment_name, name, java_component_envelope, no_wait=False):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/javaComponents/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
environment_name,
name,
cls.api_version)

r = send_raw_request(cmd.cli_ctx, "PUT", request_url, body=json.dumps(java_component_envelope))

if no_wait:
return r.json()
elif r.status_code == 201:
operation_url = r.headers.get(HEADER_AZURE_ASYNC_OPERATION)
poll_status(cmd, operation_url)
r = send_raw_request(cmd.cli_ctx, "GET", request_url)

return r.json()

@classmethod
def update(cls, cmd, resource_group_name, environment_name, name, java_component_envelope, no_wait=False):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/javaComponents/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
environment_name,
name,
cls.api_version)

r = send_raw_request(cmd.cli_ctx, "PATCH", request_url, body=json.dumps(java_component_envelope))

if no_wait:
return
elif r.status_code == 202:
operation_url = r.headers.get(HEADER_LOCATION)
response = poll_results(cmd, operation_url)
if response is None:
raise ResourceNotFoundError("Could not find the Java component")
else:
return response

return r.json()

@classmethod
def delete(cls, cmd, resource_group_name, environment_name, name, no_wait=False):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/javaComponents/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
environment_name,
name,
cls.api_version)

r = send_raw_request(cmd.cli_ctx, "DELETE", request_url)

if no_wait:
return # API doesn't return JSON (it returns no content)
elif r.status_code in [200, 201, 202, 204]:
if r.status_code == 202:
operation_url = r.headers.get(HEADER_LOCATION)
poll_results(cmd, operation_url)
logger.warning('Java component successfully deleted')

@classmethod
def show(cls, cmd, resource_group_name, environment_name, name):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/javaComponents/{}?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
environment_name,
name,
cls.api_version)

r = send_raw_request(cmd.cli_ctx, "GET", request_url)

return r.json()

@classmethod
def list(cls, cmd, resource_group_name, environment_name):
java_component_list = []

management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/javaComponents?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
environment_name,
cls.api_version)

r = send_raw_request(cmd.cli_ctx, "GET", request_url)
r = r.json()

for component in r["value"]:
ShichaoQiu marked this conversation as resolved.
Show resolved Hide resolved
java_component_list.append(component)

return java_component_list
4 changes: 4 additions & 0 deletions src/containerapp/azext_containerapp/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
CONNECTED_CLUSTER_TYPE = "connectedClusters"
AZURE_FILE_STORAGE_TYPE = "azureFile"
NFS_AZURE_FILE_STORAGE_TYPE = "nfsAzureFile"
JAVA_COMPONENT_RESOURCE_TYPE = "javaComponents"

MAXIMUM_SECRET_LENGTH = 20
MAXIMUM_CONTAINER_APP_NAME_LENGTH = 32
Expand Down Expand Up @@ -128,3 +129,6 @@

DEFAULT_CONNECTED_CLUSTER_EXTENSION_NAME = "containerapp-ext"
DEFAULT_CONNECTED_CLUSTER_EXTENSION_NAMESPACE = "containerapp-ns"

JAVA_COMPONENT_CONFIG = "SpringCloudConfig"
JAVA_COMPONENT_EUREKA = "SpringCloudEureka"
134 changes: 134 additions & 0 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,3 +1188,137 @@
--image imageName \\
--workload-profile-name my-wlp
"""

# Java Components Commands
helps['containerapp env java-component'] = """
type: group
short-summary: Commands to manage Java components within the environment.
"""

helps['containerapp env java-component list'] = """
type: command
short-summary: List all Java components within the environment.
examples:
- name: List all Java components within an environment.
text: |
az containerapp env java-component list -g MyResourceGroup --environment MyEnvironment
"""

helps['containerapp env java-component spring-cloud-config'] = """
type: group
short-summary: Commands to manage the Spring Cloud Config for the Container Apps environment.
"""

helps['containerapp env java-component spring-cloud-config create'] = """
type: command
short-summary: Command to create the Spring Cloud Config.
examples:
- name: Create a Spring Cloud Config.
text: |
az containerapp env java-component spring-cloud-config create -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment \\
--configuration PropertyName1=Value1 PropertyName2=Value2
"""

helps['containerapp env java-component spring-cloud-config delete'] = """
type: command
short-summary: Command to delete the Spring Cloud Config.
examples:
- name: Delete a Spring Cloud Config.
text: |
az containerapp env java-component spring-cloud-config delete -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment
"""

helps['containerapp env java-component spring-cloud-config show'] = """
type: command
short-summary: Command to show the Spring Cloud Config.
ShichaoQiu marked this conversation as resolved.
Show resolved Hide resolved
examples:
- name: Show a Spring Cloud Config.
text: |
az containerapp env java-component spring-cloud-config show -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment
"""

helps['containerapp env java-component spring-cloud-config update'] = """
type: command
short-summary: Command to update the Spring Cloud Config.
examples:
- name: Delete all configurations of the Spring Cloud Config.
text: |
az containerapp env java-component spring-cloud-config update -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment \\
--configuration
- name: Update a Spring Cloud Config with custom configurations.
text: |
az containerapp env java-component spring-cloud-config update -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment \\
--configuration PropertyName1=Value1 PropertyName2=Value2
"""

helps['containerapp env java-component spring-cloud-eureka'] = """
type: group
short-summary: Commands to manage the Spring Cloud Eureka for the Container Apps environment.
"""

helps['containerapp env java-component spring-cloud-eureka create'] = """
type: command
short-summary: Command to create the Spring Cloud Eureka.
examples:
- name: Create a Spring Cloud Eureka with default configuration.
text: |
az containerapp env java-component spring-cloud-eureka create -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment
- name: Create a Spring Cloud Eureka with custom configurations.
text: |
az containerapp env java-component spring-cloud-eureka create -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment \\
--configuration PropertyName1=Value1 PropertyName2=Value2
"""

helps['containerapp env java-component spring-cloud-eureka delete'] = """
type: command
short-summary: Command to delete the Spring Cloud Eureka.
examples:
- name: Delete a Spring Cloud Eureka.
text: |
az containerapp env java-component spring-cloud-eureka delete -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment
"""

helps['containerapp env java-component spring-cloud-eureka show'] = """
type: command
short-summary: Command to show the Spring Cloud Eureka.
examples:
- name: Show a Spring Cloud Eureka.
text: |
az containerapp env java-component spring-cloud-eureka show -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment
"""

helps['containerapp env java-component spring-cloud-eureka update'] = """
type: command
short-summary: Command to update the Spring Cloud Eureka.
examples:
- name: Delete all configurations of the Spring Cloud Eureka.
text: |
az containerapp env java-component spring-cloud-eureka update -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment \\
--configuration
- name: Update a Spring Cloud Eureka with custom configurations.
text: |
az containerapp env java-component spring-cloud-eureka update -g MyResourceGroup \\
-n MyJavaComponentName \\
--environment MyEnvironment \\
--configuration PropertyName1=Value1 PropertyName2=Value2
"""
8 changes: 7 additions & 1 deletion src/containerapp/azext_containerapp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,4 +539,10 @@
ManagedServiceIdentity = {
"type": None, # 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssigned,UserAssigned'
"userAssignedIdentities": None # {string: UserAssignedIdentity}
}
}

JavaComponent = {
"properties": {
"componentType": None
}
}
12 changes: 9 additions & 3 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def load_arguments(self, _):

# Springboard
with self.argument_context('containerapp create', arg_group='Service Binding', is_preview=True) as c:
c.argument('service_bindings', nargs='*', options_list=['--bind'], help="Space separated list of services(bindings) to be connected to this app. e.g. SVC_NAME1[:BIND_NAME1] SVC_NAME2[:BIND_NAME2]...")
c.argument('service_bindings', nargs='*', options_list=['--bind'], help="Space separated list of services, bindings or Java components to be connected to this app. e.g. SVC_NAME1[:BIND_NAME1] SVC_NAME2[:BIND_NAME2]...")
c.argument('customized_keys', action=AddCustomizedKeys, nargs='*', help='The customized keys used to change default configuration names. Key is the original name, value is the customized name.')
c.argument('service_type', help="The service information for dev services.")
c.ignore('service_type')
Expand All @@ -53,9 +53,9 @@ def load_arguments(self, _):

# Springboard
with self.argument_context('containerapp update', arg_group='Service Binding', is_preview=True) as c:
c.argument('service_bindings', nargs='*', options_list=['--bind'], help="Space separated list of services(bindings) to be connected to this app. e.g. SVC_NAME1[:BIND_NAME1] SVC_NAME2[:BIND_NAME2]...")
c.argument('service_bindings', nargs='*', options_list=['--bind'], help="Space separated list of services, bindings or Java components to be connected to this app. e.g. SVC_NAME1[:BIND_NAME1] SVC_NAME2[:BIND_NAME2]...")
c.argument('customized_keys', action=AddCustomizedKeys, nargs='*', help='The customized keys used to change default configuration names. Key is the original name, value is the customized name.')
c.argument('unbind_service_bindings', nargs='*', options_list=['--unbind'], help="Space separated list of services(bindings) to be removed from this app. e.g. BIND_NAME1...")
c.argument('unbind_service_bindings', nargs='*', options_list=['--unbind'], help="Space separated list of services, bindings or Java components to be removed from this app. e.g. BIND_NAME1...")
ShichaoQiu marked this conversation as resolved.
Show resolved Hide resolved

with self.argument_context('containerapp env', arg_group='Virtual Network') as c:
c.argument('infrastructure_resource_group', options_list=['--infrastructure-resource-group', '-i'], help='Name for resource group that will contain infrastructure resources. If not provided, a resource group name will be generated.', is_preview=True)
Expand Down Expand Up @@ -289,3 +289,9 @@ def load_arguments(self, _):
with self.argument_context('containerapp github-action add') as c:
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)

with self.argument_context('containerapp env java-component') as c:
c.argument('java_component_name', options_list=['--name', '-n'], help="The Java component name.")
c.argument('environment_name', options_list=['--environment'], help="The environment name.")
c.argument('resource_group_name', arg_type=resource_group_name_type, id_part=None)
c.argument('configuration', nargs="*", help="Java component configuration. Configuration must be in format \"<propertyName>=<value> <propertyName>=<value> ...\".")
Loading
Loading