Skip to content

Commit

Permalink
Report failures in 'fields_edit' promises that don't find a match
Browse files Browse the repository at this point in the history
Ticket: ENT-5291
Changelog: None
  • Loading branch information
vpodzime committed Jun 5, 2020
1 parent d00b997 commit 763595e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cf-agent/files_editline.c
Expand Up @@ -1361,6 +1361,7 @@ static bool EditColumns(EvalContext *ctx, Item *file_start, Item *file_end, cons
return false;
}

bool found_match = false;
for (ip = file_start; ip != file_end; ip = ip->next)
{
if (ip->name == NULL)
Expand All @@ -1374,6 +1375,7 @@ static bool EditColumns(EvalContext *ctx, Item *file_start, Item *file_end, cons
}
else
{
found_match = true;
Log(LOG_LEVEL_VERBOSE, "Matched line '%s'", ip->name);
}

Expand Down Expand Up @@ -1405,6 +1407,14 @@ static bool EditColumns(EvalContext *ctx, Item *file_start, Item *file_end, cons
RlistDestroy(columns);
}

if (!found_match)
{
RecordFailure(ctx, pp, a,
"No matched line to edit fields of for pattern '%s' in '%s'",
pp->promiser, edcontext->filename);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
}

return retval;
}

Expand Down

0 comments on commit 763595e

Please sign in to comment.