Skip to content

Modify hello to be an enumration and add a backend#9

Open
cminyard wants to merge 10 commits intoclicon:masterfrom
MontaVista-OpenSourceTechnology:hello-backend
Open

Modify hello to be an enumration and add a backend#9
cminyard wants to merge 10 commits intoclicon:masterfrom
MontaVista-OpenSourceTechnology:hello-backend

Conversation

@cminyard
Copy link

This is a set of changes to make the "hello" example a little more useful. It shows a lot more of the things I expect you would be using when using clixon.

I don't think this is perfect, and I have a lot of questions still. But something like this would be extremely helpful for new users.

cminyard added 7 commits May 22, 2024 17:08
Add a backend, this will print out information about the transaction,
but that's it.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Add validation of the data, keep a local state and return the proper
state information.

Signed-off-by: Corey Minyard <minyard@acm.org>
Use the existence of a file for the status for the hello world backend.

Signed-off-by: Corey Minyard <minyard@acm.org>
This lets us demonstrate changing the value.  The /tmp/world file
contains a "to" value.

Signed-off-by: Corey Minyard <minyard@acm.org>
Because it's changed...

Signed-off-by: Corey Minyard <minyard@acm.org>
Make the versions match.

Signed-off-by: Corey Minyard <minyard@acm.org>
To see what's in them.  The standard functions don't print the prefix or
flags.

Signed-off-by: Corey Minyard <minyard@acm.org>
@olofhagsand
Copy link
Member

Nice initiative!

Handle body nodes more cleanly.

Signed-off-by: Corey Minyard <minyard@acm.org>
Copy link
Member

@olofhagsand olofhagsand left a comment

Choose a reason for hiding this comment

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

Thanks for improving the hello application.
Could you please add a README to describe the purpose and usage?
Your additions seem to be a better illustration of the commit/transaction semantics?
I could still see the use of a minimal application just to exercise the config+build system (the previous hello was not that either).
Could you also please have a look at https://github.com/clicon/clixon/blob/master/CONTRIBUTING.md#c-style especially in an example its good to be normative in style.

int rv;

printf("*****hello validate*****\n");
printf("src:\n");
Copy link
Member

Choose a reason for hiding this comment

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

This will show up on the backend's stdout. This is limiting to a debug case where you run the backend in the foreground.
I would add that as a log instead so you could steer the prints to syslog/stderr/stdout as described here: https://clixon-docs.readthedocs.io/en/latest/backend.html#command-line-options.
Logging XML can be done with the macro clixon_log_xml(). Or debug with clixon_debug_xml().

if (strcmp(xml_name(vec), "hello") != 0)
return 0;
/*
* It would be nice to be able to use nscache_xxx() for this.
Copy link
Member

Choose a reason for hiding this comment

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

The cache is built on-demand. Yes, you should be able to use such a function. It is not so nice to have this in the example code.
Maybe we could add such a function in the lib if there is nothing appropriate.
The function I think could be used here is xml2ns()

Add a lot of comments, replace hand-coded xml functions with standard
one, use clixon_debug() instead of printf in a lot of places, and
comment out the printing of the XML trees by default.

Also show an example of both parsing the source and target trees or
parsing the add,delete,change vectors.

Signed-off-by: Corey Minyard <minyard@acm.org>
@cminyard
Copy link
Author

cminyard commented Jun 5, 2024

I updated this to address the comments and to add even more useful information and examples.

You aren't supposed to delete the old ones, just add new ones.

Signed-off-by: Corey Minyard <corey@minyard.net>
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 this pull request may close these issues.

2 participants