Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
added validators
Browse files Browse the repository at this point in the history
  • Loading branch information
felbinger authored Jan 2, 2023
1 parent 1d413a1 commit d42f455
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
12 changes: 5 additions & 7 deletions deb/opt/vyatta-node_exporter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ def generate(node_exporter):
return None

# merge web/listen-address with subelement web/listen-address/port
if 'web' in node_exporter:
# {'listen-address': {'0.0.0.0': {'port': '8080'}}
if 'listen-address' in node_exporter['web']:
address = list(node_exporter['web']['listen-address'].keys())[0]
port = node_exporter['web']['listen-address'][address].get("port", 9100)
node_exporter['web']['listen-address'] = f"{address}:{port}"
del node_exporter['web']['listen-address']['port']
# {'web': {'listen-address': {'0.0.0.0': {'port': '8080'}}}
if 'web' in node_exporter and 'listen-address' in node_exporter['web']:
address = list(node_exporter['web']['listen-address'].keys())[0]
port = node_exporter['web']['listen-address'][address].get("port", 9100)
node_exporter['web']['listen-address'] = f"{address}:{port}"

with open('/opt/vyatta-node_exporter/config.j2', 'r') as tmpl, open(config_file, 'w') as out:
template = Template(tmpl.read()).render(data=node_exporter)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
type: txt
help: Output format of log messages. One of: [logfmt, json] (default: logfmt)
val_help: logfmt; Prometheus logging format (default)
val_help: json; JSON
allowed: echo "logfmt json"
syntax:expression: exec "${vyos_libexec_dir}/validate-value --regex \'^(logfmt|json)$\' --value \'$VAR(@)\'"; "Invalid value"
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
type: txt
help: Only log messages with the given severity or above. One of: [debug, info, warn, error] (default: info)
val_help: debug; Debug
val_help: info; Info (default)
val_help: warn; Warning
val_help: error; Error
allowed: echo "debug info warn error"
syntax:expression: exec "${vyos_libexec_dir}/validate-value --regex \'^(debug|info|warn|error)$\' --value \'$VAR(@)\'"; "Invalid value"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
type: txt
help: Path under which to expose metrics.
default: "/metrics"
help: Path under which to expose metrics. (default: "/metrics")
syntax:expression: exec "${vyos_libexec_dir}/validate-value --regex \'^/.*$\' --value \'$VAR(@)\'"; "Invalid value"

0 comments on commit d42f455

Please sign in to comment.