-
Notifications
You must be signed in to change notification settings - Fork 97
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
fix: render mfe-ports for unmounted mfes when these exist #241
base: release
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
{%- set unmounted_mfes = [] %} | ||
{%- for app_name, app in iter_mfes() %} | ||
{%- if not iter_mounts(MOUNTS, app_name)|list %} | ||
{%- set _ = unmounted_mfes.append((app_name, app)) %} | ||
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. shouldn't append be enough by itself? Is it necessary to set the output to _? 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. The |
||
{%- endif %} | ||
{%- endfor %} | ||
{% if unmounted_mfes|length > 0 %} | ||
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. nit: |
||
mfe: | ||
ports: | ||
{%- for app_name, app in iter_mfes() %} | ||
{%- if not iter_mounts(MOUNTS, app_name)|list %} | ||
- {{ app["port"] }}:8002 # {{ app_name }} | ||
{%- endif %} | ||
{%- endfor %} | ||
ports: | ||
{%- for app_name, app in unmounted_mfes %} | ||
- {{ app["port"] }}:8002 # {{ app_name }} | ||
{%- endfor %} | ||
{% endif %} | ||
|
||
|
||
{%- for app_name, app in iter_mfes() %} | ||
{%- set mounts = iter_mounts(MOUNTS, app_name)|list %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we simplify this declaration with the following?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's giving error:
Error: Template syntax error: expected token ',', got 'for'
. Because of,
inapp_name, app
. I've also tried withiter_mfes().items()
. Got same error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. In which case, I suggest to expose a
unmounted_mfes
variable via the ENV_TEMPLATE_VARIABLES filter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to applied using the below code.
That leads us to this template:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have re-arranged the code in the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of this pattern, as it moves too much declarative code to the Jinja templates. This is not a great practice. Instead, I suggest:
and then in the templates: