Last active
August 15, 2024 09:57
-
-
Save nivb52/87313a8a569e6e5ab2a3cf6622fedce6 to your computer and use it in GitHub Desktop.
Working with Confd 2
This file contains hidden or 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
| confd --version | |
| find -name "confd" -type d | | |
| while IFS= read -r dir; do | |
| echo "$dir"; | |
| export SERVICE_NAME=`echo "$dir" | cut -d "/" -f 2 ` | |
| mkdir -p "$dir"/conf.d; | |
| mkdir -p "$dir"/templates; | |
| cp "$dir"/*.tmpl "$dir"/templates; | |
| cp "$dir"/*.toml "$dir"/conf.d; | |
| echo "==== Service Name: $SERVICE_NAME ========" | |
| sed "s|/service/config|$dir|" "$dir"/production.toml > "$dir"/conf.d/production.toml | |
| sed "s|/service/api|$dir|" "$dir"/swagger.toml > "$dir"/conf.d/swagger.toml | |
| cat "$dir"/conf.d/production.toml | |
| sleep 4 | |
| #confd -onetime -log-level debug -confdir "$dir" -config-file "$dir"/conf.d/production.toml -backend etcd -node http://YOUR-END-POINT/etcd -prefix / | |
| confd -onetime -log-level debug -confdir "$dir" -config-file "$dir"/conf.d/production.toml -backend file -file ./exported.yaml -prefix / | |
| sleep 3 | |
| done | |
| ##etcdtool -p "http://YOUR-END-POINT/etcd" -d export --format YAML /configuration/ > exported.yaml | |
| #etcdtool -p "http://localhost:2379/etcd" -d import --format YAML --yes --replace /configuration/"${product}" filename.yaml |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some more helper functions
// command of confd
confd -onetime -log-level debug -confdir ./confd -config-file ./confd/conf.d/production.toml -backend file -file ~/Downloads/exported.yaml -prefix /configuration// to a file
// copy only the errors
// clean errors from output (no erro file needed): // not sure maybe 1st line is missed
clean errors from errors file :
global rewgex:
simple:
===========================================
101 other regex (not for shell) :
sed info:
https://www.tutorialspoint.com/unix/unix-regular-expressions.htm