Skip to content

Commit 1d6a111

Browse files
committed
yanglint UPDATE data validation type now operational datastore
There is no use-case for fully validating state data and generating errors.
1 parent 06bc76d commit 1d6a111

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

tests/yanglint/interactive/data_merge.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ test data_merge_basic {Data is merged and the node is added} {
1111
test data_merge_validation_failed {Data is merged but validation failed.} {
1212
-setup $ly_setup -cleanup $ly_cleanup -body {
1313
ly_cmd "load modmerge"
14-
ly_cmd "data $ddir/modmerge.xml"
15-
ly_cmd "data $ddir/modmerge2.xml"
16-
ly_cmd "data -m $ddir/modmerge2.xml $ddir/modmerge.xml"
17-
ly_cmd_err "data -m $ddir/modmerge.xml $ddir/modmerge2.xml" "Merged data are not valid"
14+
ly_cmd "data -t config $ddir/modmerge.xml"
15+
ly_cmd "data -t config $ddir/modmerge2.xml"
16+
ly_cmd "data -m -t config $ddir/modmerge2.xml $ddir/modmerge.xml"
17+
ly_cmd_err "data -m -t config $ddir/modmerge.xml $ddir/modmerge2.xml" "Merged data are not valid"
1818
}}
1919

2020
test data_merge_dataconfig {The merge option has effect only for 'data' and 'config' TYPEs} {

tools/lint/cmd_data.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cmd_data_help_type(void)
4949
{
5050
printf(" -t TYPE, --type=TYPE\n"
5151
" Specify data tree type in the input data file(s):\n"
52-
" data - Complete datastore with status data (default type).\n"
52+
" data - Complete (operational) datastore with state data (default).\n"
5353
" config - Configuration datastore (without status data).\n"
5454
" get - Result of the NETCONF <get> operation.\n"
5555
" getconfig - Result of the NETCONF <get-config> operation.\n"
@@ -180,7 +180,7 @@ cmd_data_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc)
180180
uint8_t data_type_set = 0;
181181

182182
yo->data_parse_options = YL_DEFAULT_DATA_PARSE_OPTIONS;
183-
yo->data_validate_options = YL_DEFAULT_DATA_VALIDATE_OPTIONS;
183+
yo->data_validate_options = YL_DEFAULT_DATA_VALIDATE_OPTIONS | LYD_VALIDATE_OPERATIONAL;
184184

185185
if ((rc = parse_cmdline(cmdline, &argc, &yo->argv))) {
186186
return rc;
@@ -219,14 +219,14 @@ cmd_data_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc)
219219
}
220220
}
221221
break;
222-
case 'O': /* --operational */
222+
case 'O': /* --operational */
223223
if (yo->data_operational.path) {
224224
YLMSG_E("The operational datastore (-O) cannot be set multiple times.");
225225
return 1;
226226
}
227227
yo->data_operational.path = optarg;
228228
break;
229-
case 'R': /* --reply-rpc */
229+
case 'R': /* --reply-rpc */
230230
if (yo->reply_rpc.path) {
231231
YLMSG_E("The PRC of the reply (-R) cannot be set multiple times.");
232232
return 1;

tools/lint/main_ni.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ help(int shortout)
136136

137137
printf(" -t TYPE, --type=TYPE\n"
138138
" Specify data tree type in the input data file(s):\n"
139-
" data - Complete datastore with status data (default type).\n"
140-
" config - Configuration datastore (without status data).\n"
139+
" data - Complete (operational) datastore with state data (default).\n"
140+
" config - Configuration datastore (without state data).\n"
141141
" get - Data returned by the NETCONF <get> operation.\n"
142142
" getconfig - Data returned by the NETCONF <get-config> operation.\n"
143143
" edit - Config content of the NETCONF <edit-config> operation.\n"

tools/lint/yl_opt.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ yl_opt_erase(struct yl_opt *yo)
9898

9999
free_cmdline(yo->argv);
100100

101-
*yo = (const struct yl_opt) {
102-
0
103-
};
101+
memset(yo, 0, sizeof *yo);
104102
yo->interactive = interactive;
105103
}
106104

@@ -177,6 +175,10 @@ yl_opt_update_out_format(const char *arg, struct yl_opt *yo)
177175
int
178176
yl_opt_update_data_type(const char *arg, struct yl_opt *yo)
179177
{
178+
/* reset to default */
179+
yo->data_parse_options = YL_DEFAULT_DATA_PARSE_OPTIONS;
180+
yo->data_validate_options = YL_DEFAULT_DATA_VALIDATE_OPTIONS;
181+
180182
if (!strcasecmp(arg, "config")) {
181183
yo->data_parse_options |= LYD_PARSE_NO_STATE;
182184
yo->data_validate_options |= LYD_VALIDATE_NO_STATE;
@@ -197,7 +199,8 @@ yl_opt_update_data_type(const char *arg, struct yl_opt *yo)
197199
} else if (!strcasecmp(arg, "nc-notif")) {
198200
yo->data_type = LYD_TYPE_NOTIF_NETCONF;
199201
} else if (!strcasecmp(arg, "data")) {
200-
/* default option */
202+
/* default option but uses a specific validation flag */
203+
yo->data_validate_options |= LYD_VALIDATE_OPERATIONAL;
201204
} else if (!strcasecmp(arg, "ext")) {
202205
yo->data_ext = 1;
203206
} else {

0 commit comments

Comments
 (0)