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 spring cloud gateway cli #8037

Merged
merged 15 commits into from
Oct 16, 2024
Prev Previous commit
Next Next commit
Gateway cli
  • Loading branch information
Wenhao Zhang committed Sep 29, 2024
commit dc0c56f55bc0d371b6a2f58a3b06d822146815bb
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
@@ -364,7 +364,7 @@ def load_arguments(self, _):
c.argument('configuration', nargs="*", help="Java component configuration. Configuration must be in format \"<propertyName>=<value>\" \"<propertyName>=<value>\"...")
c.argument('min_replicas', type=int, help="Minimum number of replicas to run for the Java component.")
c.argument('max_replicas', type=int, help="Maximum number of replicas to run for the Java component.")
c.argument('route_yaml', options_list=['--route-yaml', '--yaml'], help="Path to a .yaml file with the configuration of a Spring Cloud Gateway route.")
c.argument('route_yaml', options_list=['--route-yaml', '--yaml'], help="Path to a .yaml file with the configuration of a Spring Cloud Gateway route. For an example, see https://aka.ms/gateway-for-spring-routes-yaml")
Copy link
Contributor

@Greedygre Greedygre Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried https://aka.ms/gateway-for-spring-routes-yaml
But seems it doesn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link will point to our SCG doc, we will release the doc after the cli released, and make the link available.


with self.argument_context('containerapp job logs show') as c:
c.argument('follow', help="Print logs in real time if present.", arg_type=get_three_state_flag())
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@ def load_command_table(self, args):
g.custom_show_command('show', 'show_admin_for_spring')
g.custom_command('delete', 'delete_admin_for_spring', confirmation=True, supports_no_wait=True)

with self.command_group('containerapp env java-component gateway-for-spring') as g:
with self.command_group('containerapp env java-component gateway-for-spring', is_preview=True) as g:
g.custom_command('create', 'create_gateway_for_spring', supports_no_wait=True)
g.custom_command('update', 'update_gateway_for_spring', supports_no_wait=True)
g.custom_show_command('show', 'show_gateway_for_spring')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list command is consistent with other Java components at the Java component level.

14 changes: 7 additions & 7 deletions src/containerapp/azext_containerapp/java_component_decorator.py
Original file line number Diff line number Diff line change
@@ -186,37 +186,37 @@ def process_loaded_scg_route(self):

# Check if the loaded YAML is a dictionary
if not isinstance(yaml_scg_routes, dict):
raise ValidationError('Invalid YAML provided. Please ensure the route is defined correctly.')
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

# Ensure that 'springCloudGatewayRoutes' is present and is a list (can be empty)
routes = yaml_scg_routes.get('springCloudGatewayRoutes')
if routes is None:
return []

if not isinstance(routes, list):
raise ValidationError('The "springCloudGatewayRoutes" field must be a list.')
raise ValidationError('The "springCloudGatewayRoutes" field must be a list. Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

# Loop through each route and validate the required fields
for route in routes:
if not isinstance(route, dict):
raise ValidationError('Each route must be a dictionary.')
raise ValidationError('Each route must be a dictionary. Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

# Ensure each route has 'id' and 'uri' fields
if 'id' not in route or not route['id']:
raise ValidationError(f'Route is missing required "id" field: {route}')
raise ValidationError(f'Route is missing required "id" field: {route} Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

if 'uri' not in route or not route['uri']:
raise ValidationError(f'Route is missing required "uri" field: {route}')
raise ValidationError(f'Route is missing required "uri" field: {route} Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

# Ensure predicates and filters are lists; set to empty lists if not provided
if 'predicates' not in route:
route['predicates'] = []
elif not isinstance(route['predicates'], list):
raise ValidationError(f'The "predicates" field must be a list in route {route["id"]}.')
raise ValidationError(f'The "predicates" field must be a list in route {route["id"]}. Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

if 'filters' not in route:
route['filters'] = []
elif not isinstance(route['filters'], list):
raise ValidationError(f'The "filters" field must be a list in route {route["id"]}.')
raise ValidationError(f'The "filters" field must be a list in route {route["id"]}. Please see https://aka.ms/gateway-for-spring-routes-yaml for a valid Gateway for Spring routes YAML spec.')

return yaml_scg_routes.get('springCloudGatewayRoutes')
Loading