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

如何使用环境变量嵌套 #1000

Open
spursy opened this issue Jan 8, 2024 · 1 comment
Open

如何使用环境变量嵌套 #1000

spursy opened this issue Jan 8, 2024 · 1 comment

Comments

@spursy
Copy link

spursy commented Jan 8, 2024

  • 获取全局变量:${vars.*}
  • 获取当前机器中的环境变量:${env(环境变量)}

如下:

vars: #公共全局变量
  region: cn-hongkong
  service:
     test: "test-role"
     prod: "prod-role"

机器中的环境变量是 test 或 prod,我如何根据机器中的环境变量获取全局环境变量中对应的 role?

@zxypro1
Copy link

zxypro1 commented Jan 8, 2024

目前vars还不支持嵌套写法。可以尝试维护两个test,prod文件,内容就是role字符串,然后使用${file}语法读取。比如:

...
  role: ${file(env('ENV'))}
...

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

2 participants