ENT-8193: Added validfiledata policy function - #6267
Conversation
9e45cd8 to
9703b8e
Compare
845b012 to
a638a1c
Compare
Changelog: Title Ticket: ENT-8193 Signed-off-by: Victor Moene <victor.moene@northern.tech>
larsewi
left a comment
There was a problem hiding this comment.
Did you try reusing ValidateDataGeneric?
I think |
| bundle agent generate_files(template, data) | ||
| { | ||
| vars: | ||
| "content" string => string_mustache("$(template[mustache])", @(data)); |
There was a problem hiding this comment.
Seems a bit overly complicated to use mustache templates here. Is it not easier to just write the content directly? It may be a little bit more code, but easier to read / understand when debugging this in the future.
Also I'd prefer using the test directory variables from default.sub.cf instead of polluting the /tmp/ directory.
There was a problem hiding this comment.
It just seemed easier to maintain to me: instead of maintaining a hard coded string for each filetype, we have one general data container and one mustache for each filetype. Also, it doesn't pollute the folder with a lot of redundant files:
validfiledata.cf.json
validfiledata.cf.x.json
validfiledata.cf.yaml
valifiledata.cf.x.yaml
validfiledata.cf.csv
validfiledata.cf.x.csv
[...]
There was a problem hiding this comment.
What I meant is that you write these files to the /tmp/ directory. While you could use $(G.testdir) instead, which gets cleaned up by the test framework if the test passes.
depends_on: NorthernTechHQ/libntech#288