Skip to content

ENT-8193: Added validfiledata policy function - #6267

Open
victormlg wants to merge 1 commit into
cfengine:masterfrom
victormlg:isvaliddata
Open

ENT-8193: Added validfiledata policy function#6267
victormlg wants to merge 1 commit into
cfengine:masterfrom
victormlg:isvaliddata

Conversation

@victormlg

@victormlg victormlg commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Comment thread libpromises/evalfunction.c
@victormlg
victormlg force-pushed the isvaliddata branch 2 times, most recently from 845b012 to a638a1c Compare August 6, 2026 11:40
@victormlg

Copy link
Copy Markdown
Contributor Author

Started pipeline:

Build Status

Changelog: Title
Ticket: ENT-8193
Signed-off-by: Victor Moene <victor.moene@northern.tech>
@victormlg

Copy link
Copy Markdown
Contributor Author

Build Status

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you try reusing ValidateDataGeneric?

@victormlg

Copy link
Copy Markdown
Contributor Author

Did you try reusing ValidateDataGeneric?

I think ValidateDataGeneric only supports Json

bundle agent generate_files(template, data)
{
vars:
"content" string => string_mustache("$(template[mustache])", @(data));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
[...]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread libpromises/evalfunction.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants