-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from troykelly/34-update-config-schema
Adding and updating config schema
- Loading branch information
Showing
3 changed files
with
100 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/providers.md | ||
/providers.json | ||
/provider_snippets.md | ||
/config_schema.yaml | ||
|
||
# General | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
json_file="providers.json" # Replace with your actual JSON file path | ||
output_file="config_schema.yaml" # Output file name | ||
|
||
echo "Generating configuration schema from JSON..." | ||
|
||
# Start by writing the static part of the schema | ||
cat > "$output_file" << EOF | ||
schema: | ||
email: email | ||
updatedelay: int? | ||
domains: | ||
- str | ||
certfile: str | ||
keyfile: str | ||
dns: | ||
provider: list( | ||
EOF | ||
|
||
# Append the provider list to the schema | ||
providers=$(jq -r 'keys[]' "$json_file" | paste -sd "|" -) | ||
echo " $providers)?" >> "$output_file" | ||
|
||
# Append the options for each provider | ||
echo " # Provider specific options" >> "$output_file" | ||
for provider in $(jq -r 'keys[]' "$json_file"); do | ||
jq -r --arg provider "$provider" '.[$provider] | keys[]' "$json_file" | | ||
while IFS= read -r key; do | ||
# Append each option with the provider prefix | ||
echo " ${provider}_${key}: str?" >> "$output_file" | ||
done | ||
done | ||
|
||
echo "Configuration schema generated in $output_file" |