Skip to content

Commit

Permalink
tools/keyfile_to_yaml: display the generated YAML
Browse files Browse the repository at this point in the history
Dump the state YAML to the stdout after loading the keyfile.
  • Loading branch information
daniloegea committed Apr 5, 2024
1 parent 7afe56f commit d77302e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tools/keyfile_to_yaml.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "state.h"
#include <stdio.h>

#include <types.h>
Expand All @@ -22,13 +23,26 @@ int main(int argc, char** argv) {
np_state = netplan_state_new();

netplan_state_import_parser_results(np_state, npp, &error);
if (!error) printf("keyfile %s loaded\n", argv[1]);
if (error) goto exit_state;

int stdout_fd = fileno(stdout);
netplan_state_dump_yaml(np_state, stdout_fd, &error);
if (error) {
printf("state_dump_yaml failed\n");
goto exit_state;
}

netplan_state_clear(&np_state);
netplan_parser_clear(&npp);
if (error) netplan_error_clear(&error);
return 0;

exit_state:
netplan_state_clear(&np_state);

exit_parser:
netplan_parser_clear(&npp);
if (error) netplan_error_clear(&error);

return 0;
return 1;
}

0 comments on commit d77302e

Please sign in to comment.