-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fixes #9021: Patch the agent to output needed data for jinja2 templating #1081
Conversation
Still testing, please wait before merging. |
FNCALL_OPTION_NONE, FNCALL_CATEGORY_IO, SYNTAX_STATUS_NORMAL), | ||
FnCallTypeNew("datastate", CF_DATA_TYPE_CONTAINER, DATASTATE_ARGS, &FnCallDatastate, "Construct a container of the variable and class state", | ||
FNCALL_OPTION_NONE, FNCALL_CATEGORY_UTILS, SYNTAX_STATUS_NORMAL), | ||
+ FnCallTypeNew("dumpdatastate", CF_DATA_TYPE_CONTEXT, FILESTAT_ARGS, &FnCallDumpDatastate, "Dump the current datatstae() into the given file", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here: datastate()*
+ FILE *fout; | ||
+ if ((fout = fopen(path, "w")) == NULL) | ||
+ { | ||
+ Log(LOG_LEVEL_ERR, "Cannot open the destination file '%s'. (fopen: %s)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's useful in error messages to know where this error is coming from. Could you prefix it with "dumpdatastate(): " maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure!
+ ARG_UNUSED const FnCall *fp, | ||
+ ARG_UNUSED const Rlist *args) | ||
+{ | ||
+ char *path = RlistScalarValue(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need free-ing at the end of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the data is in args, which is freed by FnCallDestroy in a parent function.
+ JsonElement *state = DefaultTemplateData(ctx, NULL); | ||
+ JsonWrite(writer, state, 0); | ||
+ | ||
+ WriterClose(writer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also fclose() the FILE handle above? If not we should close it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure!
Commit modified |
3ef5527
to
49fb019
Compare
Looks good to me |
OK, merging this PR |
https://www.rudder-project.org/redmine/issues/9021