Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Fix: Do not substitute strings without brackets #45

Merged
merged 1 commit into from
Jul 24, 2023
Merged

Conversation

ghen
Copy link
Contributor

@ghen ghen commented Jul 23, 2023

Fix to pass through strings without brackets, e.g. $abc -> $abc.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

Signed-off-by: Eugene Yarshevich <yarshevich@gmail.com>
@ghen ghen requested a review from chrishumanitec July 23, 2023 15:44
return src
}

// EDGE CASE: Captures "$$" sequences and empty templates "${}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Score placeholders follow the Humanitec syntax: https://developer.humanitec.com/platform-orchestrator/reference/placeholders/

This does not support $$ for escaping the placeholder, rather $\{.

There is a further problem here that if I escape $${shared.my-var} it will turn into ${shared.my-var} and so be interpreted as a valid placeholder by Humanitec which it should not. It should still be escaped for Humanitec to deal with in the delta.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$$ -> $ is supported right now in all our CLI tools. If we remove this functionality, it may break existing setups, where someone is already using $$. We are solving a concrete issue in this PR. Lets stick to it and do not add new breaking changes. We can address all other improvements in separate PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the second point still stands. You should not unescape yet. What you need to do is convert it into $\{ so that Humanitec does not read it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not the case. Several placeholders in Humanitec does not have their counterparts in Score resources, and this construct is used exactly to pass through the placeholder as is, so Humanitec would handle it properly. For example, $${pod.status.hostIP}.

Note, that similar mechanism is used in score-compose to reference environment variables that should not be substituted by the CLI tool, but they are known to compose CLI tool.

We can change this behaviour, but again, this would be a breaking change and it does not relate to the issue we are addressing in this PR. A concrete issue is that we want to ignore $abc and only react to ${abc} (with brackets).

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's open a second issue to straighten up escaping more generally.

Copy link
Contributor

@chrishumanitec chrishumanitec left a comment

Choose a reason for hiding this comment

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

Let's open anopther issue to fix espacing properly.

LGTM

@ghen ghen merged commit daa17bf into main Jul 24, 2023
3 checks passed
@ghen ghen deleted the feature/templates-fix branch July 24, 2023 19:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants