Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xxx.toml 配置文件是否支持dest目录路径动态从etcdv3 获取 #871

Open
zhenliangliang opened this issue Mar 18, 2023 · 3 comments

Comments

@zhenliangliang
Copy link

我使用配置文件 在[template] dest = "/tmp/{{getv "/nginx/path/server_name" }}" 动态从etcd获取目标路径值,但无法成功,chatgpt说可以实现,这个能支持吗

@zhenliangliang
Copy link
Author

我使用配置文件 在[template] dest = "/tmp/{{getv "/nginx/path/server_name" }}" 动态从etcd获取目标路径值,但无法成功,chatgpt说可以实现,这个能支持吗

报错信息:ERROR open /tmp/{{getv "/nginx/path/.server_name" }}236432004: no such file or directory

@hubo1016
Copy link
Contributor

不要听AI跟你胡说八道,他又不背KPI。confd的template文件和template resource文件是分离的,只有template文件当中可以使用go template语法,而dest是template resource的一部分。你可以尝试将文件输出到固定的位置,在template第一行额外附加一个目标路径例如# dest="/tmp/{{getv "/nginx/path/server_name" }}"或者其他适合处理的格式,然后写一个reload脚本,读取第一行里面的路径之后把文件复制过去,如果需要的话删掉第一行。

@wuceyang
Copy link

在nginx配置文件中,使用循环来生成server{}代码块也是一样的啊,不用动态生成文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants