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

priority field cannot be a template variable #78

Open
arlake228 opened this issue Nov 13, 2019 · 1 comment
Open

priority field cannot be a template variable #78

arlake228 opened this issue Nov 13, 2019 · 1 comment
Assignees

Comments

@arlake228
Copy link
Contributor

Currently it is impossible to se a template variable for the priority field since it is an integer in the psconfig schema, which is checked prior to variable expansion. For example, when it sees {% jq 8 %} it fails.

For stuff in test specs, archiver specs, etc the base psconfig only cares that they are JSON objects and defers to pscheduler on validating the contents of those object. That means this is a non-issue for those fields since the base psconfig schema has nothing to say about their type. Once the jq temaplate variables are expanded, they correctly let jq determine the quoting.

We need to update the psconfig schema to allow for priority to be an integer or a string. We also need to determine how we wan to validate that field by either defining a pattern in the schema too match jq variables or some type of post expansion step.

{
  "Powstream_Spec": {
    "_meta": {
      "display-name": "New Powstream Between RRZE-H",
      "priority": 8
    },
    "group": "owdPu_group",
    "test": "owd4_i5_d2",
    "priority": "{% jq 8 %}"
  }
}
psconfig validate psc-json-issue.json
Loading template ...... OK
Validating JSON schema ...... FAIL
pSConfig JSON is not valid. Encountered the following validation errors:
   Node: /tasks/Powstream_Spec/priority
   Error: Expected integer - got string.
@arlake228 arlake228 added this to the sprint-20191209 milestone Nov 13, 2019
@arlake228 arlake228 self-assigned this Nov 13, 2019
@mfeit-internet2
Copy link
Member

I think this was discussed verbally or on Slack at some point, but just to close the loop:

The JSON in the template obviously needs a string so this stuff can be specified (e.g., "priority": "{% jq 8 %}") but forces the returned value to be interpreted as a string "priority": "8").

My recommendation would be to treat strings that are entirely a jq substitution ("{% jq ... %}") as a value that's of the returned type. This would make "{% jq 8 %}" and "{% jq \"eight\" %}" behave as one would expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

2 participants