Ignore strict rules during validation, e.g. path/file existence.
+ .. option:: --type=<worker|policy-loader>
+
+ Which type of Lua script to generate.
+
+ * ``worker`` generates a script for the daemon (default)
+ * ``policy-loader`` generates a script for the one-shot policy loader,
+ which generates a rule database based on ``views``, ``local-data``,
+ and ``forward`` configuration
+
.. option:: <input_file>
File with the declarative configuration in YAML or JSON format.
self.input_file: str = namespace.input_file
self.output_file: Optional[str] = namespace.output_file
self.strict: bool = namespace.strict
+ self.type: str = namespace.type
@staticmethod
def register_args_subparser(
action="store_false",
dest="strict",
)
+ convert.add_argument(
+ "--type", help="The type of Lua script to generate", choices=["worker", "policy-loader"], default="worker"
+ )
convert.add_argument(
"input_file",
type=str,
try:
parsed = try_to_parse(data)
set_global_validation_context(Context(Path(Path(self.input_file).parent), self.strict))
- lua = KresConfig(parsed).render_lua()
+
+ if self.type == "worker":
+ lua = KresConfig(parsed).render_lua()
+ elif self.type == "policy-loader":
+ lua = KresConfig(parsed).render_lua_policy()
+ else:
+ raise ValueError(f"Invalid self.type={self.type}")
+
reset_global_validation_context()
except (DataParsingError, DataValidationError) as e:
print(e, file=sys.stderr)