diff options
author | Magnus Ahltorp <map@kth.se> | 2017-07-26 01:34:57 +0200 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2017-07-26 01:48:07 +0200 |
commit | 14d764d08ad3ef925ac23dbd29aa8301e3550e21 (patch) | |
tree | 9a4f3706779c7b0a5c4ea17c06305e1b263ae7a0 | |
parent | 93f7910d08242bc71847cbe0e646a67e1191374a (diff) |
Output optional and defaults to configuration man page
-rw-r--r-- | doc/catlfish-log.cfg.in.5.adoc | 3 | ||||
-rw-r--r-- | doc/catlfish-node.cfg.5.adoc | 20 | ||||
-rwxr-xr-x | tools/compileconfig.py | 5 | ||||
-rw-r--r-- | tools/manpage.py | 9 | ||||
-rw-r--r-- | tools/readconfig.py | 20 |
5 files changed, 33 insertions, 24 deletions
diff --git a/doc/catlfish-log.cfg.in.5.adoc b/doc/catlfish-log.cfg.in.5.adoc index 1cc912f..43559cc 100644 --- a/doc/catlfish-log.cfg.in.5.adoc +++ b/doc/catlfish-log.cfg.in.5.adoc @@ -81,6 +81,9 @@ OPTIONS **storage-quorum-size**: __number-of-nodes__:: // write description here + **storage-sign-quorum-size**: __number-of-nodes__ (default: 0):: +// write description here + **storagenodes**: (list of items):: // write description here diff --git a/doc/catlfish-node.cfg.5.adoc b/doc/catlfish-node.cfg.5.adoc index fabef29..2cbf596 100644 --- a/doc/catlfish-node.cfg.5.adoc +++ b/doc/catlfish-node.cfg.5.adoc @@ -12,13 +12,13 @@ OPTIONS **configurl**: __url__:: // write description here - **ctapiaddress**: __ip-address__:: + **ctapiaddress**: __ip-address__ (optional):: // write description here - **dbbackend**: **permdb**|**fsdb**:: + **dbbackend**: **permdb**|**fsdb** (default: fsdb):: // write description here - **frontendaddress**: __ip-address__:: + **frontendaddress**: __ip-address__ (optional):: // write description here **logadminkey**: __key__:: @@ -48,7 +48,7 @@ OPTIONS **min-delay**: __seconds__::: // write description here - **mergeaddress**: __ip-address__:: + **mergeaddress**: __ip-address__ (optional):: // write description here **nodename**: __nodename__:: @@ -81,22 +81,16 @@ OPTIONS **logpublickey**: __path__::: // write description here - **mergedb**: __path__::: -// write description here - **privatekeys**: __path__::: // write description here **public_cacertfile**: __path__::: // write description here - **publickeys**: __path__::: -// write description here - **verifycert_bin**: __path__::: // write description here - **publichttpaddress**: __ip-address__:: + **publichttpaddress**: __ip-address__ (optional):: // write description here **ratelimits**: :: @@ -105,9 +99,9 @@ OPTIONS **add_chain**: __rate__::: // write description here - **signingaddress**: __ip-address__:: + **signingaddress**: __ip-address__ (optional):: // write description here - **storageaddress**: __ip-address__:: + **storageaddress**: __ip-address__ (optional):: // write description here diff --git a/tools/compileconfig.py b/tools/compileconfig.py index 199e446..a023a6b 100755 --- a/tools/compileconfig.py +++ b/tools/compileconfig.py @@ -10,6 +10,7 @@ import re import base64 from datetime import datetime import manpage +import configschema class Symbol(str): pass @@ -562,8 +563,8 @@ def printnodenames(config): print " ".join(frontendnodenames|storagenodenames|signingnodenames|mergenodenames|statusservernodenames) def gen_manpage(manpagedir): - manpage.rewrite_manpage(manpagedir + "/catlfish-log.cfg.in.5.adoc", globalconfigschema, "Catlfish", "Catlfish Manual", "CATLFISH-LOG.CFG.IN(5)", "catlfish-log.cfg.in - catlfish log configuration") - manpage.rewrite_manpage(manpagedir + "/catlfish-node.cfg.5.adoc", localconfigschema, "Catlfish", "Catlfish Manual", "CATLFISH-NODE.CFG(5)", "catlfish-node.cfg - catlfish node configuration") + manpage.rewrite_manpage(manpagedir + "/catlfish-log.cfg.in.5.adoc", (configschema.globalconfigschema, configschema.globalconfigdefaults, configschema.globalconfigoptionals), "Catlfish", "Catlfish Manual", "CATLFISH-LOG.CFG.IN(5)", "catlfish-log.cfg.in - catlfish log configuration") + manpage.rewrite_manpage(manpagedir + "/catlfish-node.cfg.5.adoc", (configschema.localconfigschema, configschema.localconfigdefaults, configschema.localconfigoptionals), "Catlfish", "Catlfish Manual", "CATLFISH-NODE.CFG(5)", "catlfish-node.cfg - catlfish node configuration") def main(): parser = argparse.ArgumentParser(description="") diff --git a/tools/manpage.py b/tools/manpage.py index 1ea8753..d8ce09f 100644 --- a/tools/manpage.py +++ b/tools/manpage.py @@ -23,7 +23,7 @@ def traverse_schema_part(schema): schema_part = schema.get(k) result = None if isinstance(schema_part, tuple): - (lowleveldatatype, highleveldatatype) = schema_part + (lowleveldatatype, highleveldatatype, extra) = schema_part if isinstance(highleveldatatype, list): formatted_datatype = "|".join(["**"+t+"**" for t in highleveldatatype]) else: @@ -33,6 +33,13 @@ def traverse_schema_part(schema): else: result = "**" + k + "**: " + formatted_datatype + if extra["optional"]: + result += " (optional)" + + default = extra["default"] + if default != None: + result += " (default: %s)" % (default) + tree.add(k, (result, [])) elif isinstance(schema_part, dict): diff --git a/tools/readconfig.py b/tools/readconfig.py index b9a0b07..edfc342 100644 --- a/tools/readconfig.py +++ b/tools/readconfig.py @@ -65,19 +65,23 @@ def verify_and_read_config(filename, publickey_base64): signature = open(filename + ".sig").read() return verify_config(rawconfig, signature, publickey_base64, filename) -def insert_schema_path(schema, path, datatype, highleveldatatype): +def insert_schema_path(schema, path, datatype, highleveldatatype, extra): if len(path) == 1: - schema[path[0]] = (datatype, highleveldatatype) + schema[path[0]] = (datatype, highleveldatatype, extra) else: if path[0] not in schema: schema[path[0]] = {} - insert_schema_path(schema[path[0]], path[1:], datatype, highleveldatatype) + insert_schema_path(schema[path[0]], path[1:], datatype, highleveldatatype, extra) -def transform_schema(in_schema): +def transform_schema((in_schema, defaults, optionals)): + defaults_dict = dict(defaults) schema = {} for (rawpath, datatype, highleveldatatype) in in_schema: path = rawpath.split("/") - insert_schema_path(schema, path, datatype, highleveldatatype) + extra = {} + extra["optional"] = rawpath in optionals + extra["default"] = defaults_dict.get(rawpath) + insert_schema_path(schema, path, datatype, highleveldatatype, extra) return schema def check_config_schema(config, schema): @@ -98,11 +102,11 @@ def check_config_schema_part(term, schema, path=[]): joined_path = render_path(path) problems = [] if isinstance(term, basestring): - (schema_lowlevel, schema_highlevel) = schema + (schema_lowlevel, schema_highlevel, extra) = schema if schema_lowlevel != "string": problems.append("error: expected %s at %s, not a string" % (schema_lowlevel, joined_path,)) elif isinstance(term, int): - (schema_lowlevel, schema_highlevel) = schema + (schema_lowlevel, schema_highlevel, extra) = schema if schema_lowlevel != "integer": problems.append("error: expected %s at %s, not an integer" % (schema_lowlevel, joined_path,)) elif isinstance(term, dict): @@ -152,7 +156,7 @@ def common_read_config(f, filename, localconfig=True): optionals = configschema.globalconfigoptionals config = yaml.load(f, yaml.SafeLoader) insert_defaults(config, configdefaults) - check_config_schema(config, schema) + check_config_schema(config, (schema, configdefaults, optionals)) return errorhandlify(config, filename, optionals) def read_config(filename, localconfig=True): |