Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cfengine_cli/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ def _lint_block_type(node: Node, state: State, location: str, syntax_data: Synta
f"Error: Bundle type must be one of ({', '.join(syntax_data.BUILTIN_BUNDLE_TYPES)}), not '{_text(node)}' {location}",
node,
)
if node.type == "promise_block_type" and _text(node) != "agent":
raise ValidationError(
f"Error: Promise type must be 'agent', not '{_text(node)}' {location}",
node,
)


def _lint_block_name(node: Node, state: State, location: str, syntax_data: SyntaxData):
Expand Down
11 changes: 11 additions & 0 deletions tests/lint/004_block_type.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle common my_bundle
{
vars:
"x" string => "value";
}

promise agent my_promise_type
{
path => "/bin/true";
interpreter => "/bin/bash";
}
11 changes: 11 additions & 0 deletions tests/lint/004_block_type.expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

bundle notavalidtype my_bundle
^-----------^
Error: Bundle type must be one of (agent, common, edit_line, edit_xml, monitor, server), not 'notavalidtype' at tests/lint/004_block_type.x.cf:1:8


promise server my_promise_type
^----^
Error: Promise type must be 'agent', not 'server' at tests/lint/004_block_type.x.cf:7:9
FAIL: tests/lint/004_block_type.x.cf (2 errors)
Failure, 2 errors in total.
11 changes: 11 additions & 0 deletions tests/lint/004_block_type.x.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bundle notavalidtype my_bundle
{
reports:
"Hello";
}

promise server my_promise_type
{
path => "/bin/true";
interpreter => "/bin/bash";
}
5 changes: 0 additions & 5 deletions tests/lint/004_bundle_type.cf

This file was deleted.

6 changes: 0 additions & 6 deletions tests/lint/004_bundle_type.expected.txt

This file was deleted.

5 changes: 0 additions & 5 deletions tests/lint/004_bundle_type.x.cf

This file was deleted.

Loading