feat: add transient import preview and commit functionality with tests

This commit is contained in:
Wikid82
2025-11-24 18:14:59 +00:00
parent a698dff33a
commit af5a0b4ef8
4 changed files with 285 additions and 32 deletions

View File

@@ -4,7 +4,12 @@ if [ "$1" = "version" ]; then
exit 0
fi
if [ "$1" = "adapt" ]; then
echo '{"apps":{"http":{"servers":{"srv0":{"routes":[{"match":[{"host":["example.com"]}],"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:8080"}]}]}]}}}}}'
# Read the domain from the input Caddyfile (stdin or --config file)
DOMAIN="example.com"
if [ "$2" = "--config" ]; then
DOMAIN=$(cat "$3" | head -1 | tr -d '\n')
fi
echo "{\"apps\":{\"http\":{\"servers\":{\"srv0\":{\"routes\":[{\"match\":[{\"host\":[\"$DOMAIN\"]}],\"handle\":[{\"handler\":\"reverse_proxy\",\"upstreams\":[{\"dial\":\"localhost:8080\"}]}]}]}}}}}"
exit 0
fi
exit 1