MCPcopy Create free account
hub / github.com/StackStorm/st2 / main

Function main

st2common/st2common/cmd/validate_config.py:65–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63
64
65def main():
66 _register_cli_opts()
67 cfg.CONF(args=None, version=VERSION_STRING)
68
69 schema_path = os.path.abspath(cfg.CONF.schema_path)
70 config_path = os.path.abspath(cfg.CONF.config_path)
71
72 print('Validating config "%s" against schema in "%s"' % (config_path, schema_path))
73
74 with open(schema_path, "r") as fp:
75 config_schema = yaml.safe_load(fp.read())
76
77 with open(config_path, "r") as fp:
78 config_object = yaml.safe_load(fp.read())
79
80 try:
81 validate_config_against_schema(
82 config_schema=config_schema,
83 config_object=config_object,
84 config_path=config_path,
85 )
86 except Exception as e:
87 print("Failed to validate pack config.\n%s" % six.text_type(e))
88 return FAILURE_EXIT_CODE
89
90 print(
91 'Config "%s" successfully validated against schema in %s.'
92 % (config_path, schema_path)
93 )
94 return SUCCESS_EXIT_CODE

Callers

nothing calls this directly

Calls 3

_register_cli_optsFunction · 0.70
readMethod · 0.45

Tested by

no test coverage detected