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

[PROPOSAL] Templated uri for mask randomInUri #57

Closed
youen opened this issue Sep 6, 2021 · 0 comments · Fixed by #58
Closed

[PROPOSAL] Templated uri for mask randomInUri #57

youen opened this issue Sep 6, 2021 · 0 comments · Fixed by #58

Comments

@youen
Copy link
Collaborator

youen commented Sep 6, 2021

Problem

Conditional random choice is not easy. All possibilities have to be choice and the template switch to the valid choice.

For example to choice name by gender :

- selector:
      jsonpath: "name_F"
    mask:
      add : ""
- selector:
      jsonpath: "name_F"
    mask:
      randomChoiceInURI : "file://names_F.txt"
- selector:
      jsonpath: "name_M"
    mask:
      add : ""
- selector:
      jsonpath: "name_M"
    mask:
      randomChoiceInURI : "file://names_M.txt"
- selector:
      jsonpath: "name"
    mask:
      template: |-
        {{if .gender "F"}}{{.name_ F}}{{else}}{{.name_M}}{{end}}
# Remove temporaries fields
- selector:
      jsonpath: "name_F"
    mask:
      remove : true
- selector:
      jsonpath: "name_M"
    mask:
      remove : true

This is a pain for a two categories choice and is unusable for hundred categories choice.

Solution

This issue propose to use template in uri path.

For example :

- selector:
      jsonpath: "name"
    mask:
      randomChoiceInUri: "file://names_{{.gender}}.txt
@youen youen changed the title [PROPOSAL] Template uri for mask randomInUri [PROPOSAL] Templated uri for mask randomInUri Sep 6, 2021
@youen youen linked a pull request Sep 28, 2021 that will close this issue
@youen youen closed this as completed Sep 28, 2021
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 a pull request may close this issue.

1 participant