Skip to content

Commit 34640e4

Browse files
feat(get-facts): count dovecot custom directives (#207)
Dovecot upgrade to 2.4 will change config file syntax. This fact will help to estimate the impact of such breaking change.
1 parent e136d14 commit 34640e4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

imageroot/actions/get-facts/50facts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def main():
2525
facts.update(get_mailbox_settings_facts())
2626
facts.update(get_master_users_facts())
2727
facts.update(get_queue_settings_facts())
28+
facts.update(get_custom_config_facts())
2829
json.dump(facts, sys.stdout)
2930

3031
def get_addresses_facts():
@@ -243,6 +244,18 @@ def get_master_users_facts():
243244
"master_users_count": len(odata.get("master_users", [])),
244245
}
245246

247+
def get_custom_config_facts():
248+
with subprocess.Popen(["podman", "exec", "dovecot", "ash", "-c",
249+
"""grep -E '^[[:space:]]*[A-Za-z0-9_.-]+([[:space:]]|$)' /etc/dovecot/local.conf.d/*.conf | grep -v '[{}]' | wc -l"""
250+
], stdout=subprocess.PIPE) as proc:
251+
# Extract the line count from grep|wc output
252+
try:
253+
odata = json.load(proc.stdout)
254+
except json.JSONDecodeError:
255+
return {"get_custom_config_facts_error": True}
256+
return {
257+
"dovecot_custom_config_count": odata
258+
}
246259

247260
if __name__ == "__main__":
248261
main()

0 commit comments

Comments
 (0)