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

[ADDED] Ability to drop partial wildcard tokens in some subject transforms #4152

Merged
merged 4 commits into from May 14, 2023

Conversation

jnmoyne
Copy link
Contributor

@jnmoyne jnmoyne commented May 12, 2023

  • Tests added
  • Branch rebased on top of current main (git pull --rebase origin main)
  • Changes squashed to a single commit (described here)
  • Build is green in Travis CI
  • You have certified that the contribution is your original work and that you license the work to the project under the Apache 2 license

Changes proposed in this pull request:

There is currently a blanket requirement that subject transforms destinations MUST use ALL of the partial wildcards defined in the source of the transform. This is because the subject transformed defined for imports must be 'reversible' and therefore the destination transform must use all of the partial wildcard tokens defined in the source of the transform.

This reversing of a transform is only used for transforms used by imports, where in any case it doesn't make sense to use any transform other than Wildcard.

This PR:

  • relaxes this requirement to only apply when the transform is used by an import, adding the ability to drop a wildcard token in transforms other than as part of an import.
  • Improves transform reverse to support both legacy style wildcards $X and the new transform function {{Wildcard(X)}}- Improves reversible transform checking to only allow the use of wildcards in the destination.

…MUST use ALL of the partial wildcards defined in the source of the transform, to only apply for subject transforms used for imports between accounts.

Improves transform reverse to support both legacy style wildcards $X and the new transform function {{Wildcard(X)}}
Improves reversible transform checking to only allow the use of wildcards in the destination.

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
@jnmoyne jnmoyne requested a review from a team as a code owner May 12, 2023 00:17
…n array variable even if that variable's value is nil)

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
… have been allowed in the first place as imported streams and services need to be reversible)

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
@@ -69,7 +69,9 @@ type SubjectTransformer interface {
TransformTokenizedSubject(tokens []string) string
}

func NewSubjectTransform(src, dest string) (*subjectTransform, error) {
func NewSubjectTransform(src, dest string, strict bool) (*subjectTransform, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend leaving original and adding in new call that the old one calls with default of false.

func NewSubjectTransform(src, dest string) (*subjectTransform, error) {
  return NewSubjectTransformWithStrict(src, dest, false)
}

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

LGTM

@jnmoyne jnmoyne merged commit e07ccf9 into dev May 14, 2023
2 checks passed
@jnmoyne jnmoyne deleted the jnm/reverse_transforms branch May 14, 2023 21:02
jnmoyne added a commit to nats-io/nats-architecture-and-design that referenced this pull request May 16, 2023
jnmoyne added a commit to nats-io/nats-architecture-and-design that referenced this pull request Jun 18, 2023
…n the transform (#218)

* Update to reflect the new changes from nats-io/nats-server#4152

* PR feedback

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>

* Include per cluster Core NATS subject weighted mappings.

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>

---------

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants