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

Add apms parameter for Spring Cloud Gateway #6804

Merged
merged 5 commits into from
Oct 30, 2023
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
4 changes: 4 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Release History
===============
1.15.1
---
* Add arguments `--apms` for Spring Cloud Gateway.

1.15.0
---
* Add arguments `--type` and `--git-sub-path` in `spring application-accelerator customized-accelerator create` and `spring application-accelerator customized-accelerator update` for accelerator fragment support.
Expand Down
4 changes: 3 additions & 1 deletion src/spring/azext_spring/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def prepare_logs_argument(c):
c.argument('api_doc_location', arg_group='API metadata', help="Location of additional documentation for the APIs available on the Gateway instance.")
c.argument('api_version', arg_group='API metadata', help="Version of APIs available on this Gateway instance.")
c.argument('server_url', arg_group='API metadata', help="Base URL that API consumers will use to access APIs on the Gateway instance.")
c.argument('apm_types', nargs='*',
c.argument('apm_types', nargs='*', arg_group='APM',
help="Space-separated list of APM integrated with Gateway. Allowed values are: " + ', '.join(list(ApmType)))
c.argument('properties', nargs='*',
help='Non-sensitive properties for environment variables. Format "key[=value]" and separated by space.')
Expand All @@ -901,6 +901,8 @@ def prepare_logs_argument(c):
c.argument('certificate_names', arg_group='Client Certificate Authentication', help="Comma-separated list of certificate names in Azure Spring Apps.")
c.argument('addon_configs_json', arg_group='Add-on Configurations', help="JSON string of add-on configurations.")
c.argument('addon_configs_file', arg_group='Add-on Configurations', help="The file path of JSON string of add-on configurations.")
c.argument('apms', arg_group='APM', nargs='*',
help="Space-separated list of APM reference names in Azure Spring Apps to integrate with Gateway.")

for scope in ['spring gateway custom-domain',
'spring api-portal custom-domain']:
Expand Down
11 changes: 6 additions & 5 deletions src/spring/azext_spring/_validators_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
InvalidArgumentValueError,
MutuallyExclusiveArgumentError)
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.core.exceptions import ResourceNotFoundError
from knack.log import get_logger
from .vendored_sdks.appplatform.v2023_09_01_preview.models import (ApmReference, CertificateReference)
from .vendored_sdks.appplatform.v2023_09_01_preview.models._app_platform_management_client_enums import (ApmType, ConfigurationServiceGeneration)
Expand Down Expand Up @@ -351,14 +350,15 @@ def validate_acs_create(namespace):
raise ArgumentUsageError("--application-configuration-service-generation can only be set when enable application configuration service.")


def validate_gateway_update(namespace):
def validate_gateway_update(cmd, namespace):
_validate_sso(namespace)
validate_cpu(namespace)
validate_memory(namespace)
validate_instance_count(namespace)
_validate_gateway_apm_types(namespace)
_validate_gateway_envs(namespace)
_validate_gateway_secrets(namespace)
validate_apm_reference(cmd, namespace)


def validate_api_portal_update(namespace):
Expand Down Expand Up @@ -531,9 +531,10 @@ def validate_apm_reference(cmd, namespace):

result = []
for apm_name in apm_names:
resource_id = '{}/apms/{}'.format(service_resource_id, apm_name)
apm_reference = ApmReference(resource_id=resource_id)
result.append(apm_reference)
if apm_name != "":
resource_id = '{}/apms/{}'.format(service_resource_id, apm_name)
apm_reference = ApmReference(resource_id=resource_id)
result.append(apm_reference)

namespace.apms = result

Expand Down
10 changes: 10 additions & 0 deletions src/spring/azext_spring/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def gateway_update(cmd, client, resource_group, service,
certificate_names=None,
addon_configs_json=None,
addon_configs_file=None,
apms=None,
no_wait=False
):
gateway = client.gateways.get(resource_group, service, DEFAULT_NAME)
Expand Down Expand Up @@ -95,13 +96,16 @@ def gateway_update(cmd, client, resource_group, service,

addon_configs = _update_addon_configs(gateway.properties.addon_configs, addon_configs_json, addon_configs_file)

apms = _update_apms(client, resource_group, service, gateway.properties.apms, apms)

model_properties = models.GatewayProperties(
public=assign_endpoint if assign_endpoint is not None else gateway.properties.public,
https_only=https_only if https_only is not None else gateway.properties.https_only,
sso_properties=sso_properties,
api_metadata_properties=api_metadata_properties,
cors_properties=cors_properties,
apm_types=update_apm_types,
apms=apms,
environment_variables=environment_variables,
client_auth=client_auth,
addon_configs=addon_configs,
Expand Down Expand Up @@ -273,6 +277,12 @@ def _update_client_auth(client, resource_group, service, existing, enable_certif
return client_auth


def _update_apms(client, resource_group, service, existing, apms):
if apms is None:
return existing
return apms


def _update_addon_configs(existing, addon_configs_json, addon_configs_file):
if addon_configs_file is None and addon_configs_json is None:
return existing
Expand Down
Loading