Skip to content
Closed
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
236 changes: 236 additions & 0 deletions src/cfengine_cli/builtin_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
DEPRECATED_PROMISE_TYPES = ["defaults", "guest_environments"]
ALLOWED_BUNDLE_TYPES = ["agent", "common", "monitor", "server", "edit_line", "edit_xml"]
BUILTIN_PROMISE_TYPES = {
"access",
"build_xpath",
"classes",
"commands",
"databases",
"defaults",
"delete_attribute",
"delete_lines",
"delete_text",
"delete_tree",
"field_edits",
"files",
"guest_environments",
"insert_lines",
"insert_text",
"insert_tree",
"measurements",
"meta",
"methods",
"packages",
"processes",
"replace_patterns",
"reports",
"roles",
"services",
"set_attribute",
"set_text",
"storage",
"users",
"vars",
}
BUILTIN_FUNCTIONS = {
"accessedbefore",
"accumulated",
"ago",
"and",
"basename",
"bundlesmatching",
"bundlestate",
"callstack_callers",
"callstack_promisers",
"canonify",
"canonifyuniquely",
"cf_version_after",
"cf_version_at",
"cf_version_before",
"cf_version_between",
"cf_version_maximum",
"cf_version_minimum",
"changedbefore",
"classesmatching",
"classfiltercsv",
"classfilterdata",
"classify",
"classmatch",
"concat",
"countclassesmatching",
"countlinesmatching",
"data_expand",
"data_readstringarray",
"data_readstringarrayidx",
"data_regextract",
"data_sysctlvalues",
"datastate",
"difference",
"dirname",
"diskfree",
"escape",
"eval",
"every",
"execresult",
"execresult_as_data",
"expandrange",
"file_hash",
"fileexists",
"filesexist",
"filesize",
"filestat",
"filter",
"findfiles",
"findfiles_up",
"findlocalgroups",
"findlocalusers",
"findprocesses",
"format",
"getacls",
"getbundlemetatags",
"getclassmetatags",
"getenv",
"getfields",
"getgid",
"getgroupinfo",
"getgroups",
"getindices",
"getuid",
"getuserinfo",
"getusers",
"getvalues",
"getvariablemetatags",
"grep",
"groupexists",
"hash",
"hash_to_int",
"hashmatch",
"host2ip",
"hostinnetgroup",
"hostrange",
"hostsseen",
"hostswithclass",
"hostswithgroup",
"hubknowledge",
"ifelse",
"int",
"intersection",
"ip2host",
"iprange",
"irange",
"is_type",
"isconnectable",
"isdir",
"isexecutable",
"isgreaterthan",
"isipinsubnet",
"islessthan",
"islink",
"isnewerthan",
"isnewerthantime",
"isplain",
"isreadable",
"isvariable",
"join",
"lastnode",
"laterthan",
"ldaparray",
"ldaplist",
"ldapvalue",
"length",
"lsdir",
"makerule",
"maparray",
"mapdata",
"maplist",
"max",
"mean",
"mergedata",
"min",
"network_connections",
"none",
"not",
"now",
"nth",
"on",
"or",
"packagesmatching",
"packageupdatesmatching",
"parseintarray",
"parsejson",
"parserealarray",
"parsestringarray",
"parsestringarrayidx",
"parseyaml",
"peerleader",
"peerleaders",
"peers",
"processexists",
"product",
"randomint",
"read_module_protocol",
"readcsv",
"readdata",
"readenvfile",
"readfile",
"readintarray",
"readintlist",
"readjson",
"readrealarray",
"readreallist",
"readstringarray",
"readstringarrayidx",
"readstringlist",
"readtcp",
"readyaml",
"regarray",
"regcmp",
"regex_replace",
"regextract",
"registryvalue",
"regldap",
"regline",
"reglist",
"remoteclassesmatching",
"remotescalar",
"returnszero",
"reverse",
"rrange",
"search_up",
"selectservers",
"shuffle",
"some",
"sort",
"splayclass",
"splitstring",
"storejson",
"strcmp",
"strftime",
"string",
"string_downcase",
"string_head",
"string_length",
"string_mustache",
"string_replace",
"string_reverse",
"string_split",
"string_tail",
"string_trim",
"string_upcase",
"sublist",
"sum",
"sysctlvalue",
"translatepath",
"type",
"unique",
"url_get",
"usemodule",
"userexists",
"useringroup",
"validdata",
"validjson",
"variablesmatching",
"variablesmatching_as_data",
"variance",
"version_compare",
}
9 changes: 5 additions & 4 deletions src/cfengine_cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
from cfengine_cli.profile import profile_cfengine, generate_callstack
from cfengine_cli.dev import dispatch_dev_subcommand
from cfengine_cli.lint import lint_single_arg, lint_folder
from cfengine_cli.lint import lint_folder, lint_single_arg, set_strict
from cfengine_cli.shell import user_command
from cfengine_cli.paths import bin
from cfengine_cli.version import cfengine_cli_version_string
Expand Down Expand Up @@ -94,7 +94,8 @@ def format(names, line_length) -> int:
return 0


def _lint(files) -> int:
def _lint(files, strict) -> int:
set_strict(strict)

if not files:
return lint_folder(".")
Expand All @@ -107,8 +108,8 @@ def _lint(files) -> int:
return errors


def lint(files) -> int:
errors = _lint(files)
def lint(files, strict) -> int:
errors = _lint(files, strict)
if errors == 0:
print("Success, no errors found.")
else:
Expand Down
Loading
Loading