獲得了位于templates文件夾之外的配置文件列表,我們將其輸入到如下的helm圖表中:
├── configs
│?? ├── AllEnvironments
│?? │?? ├── Infrastructure
│?? │?? └── Services
│?? │?? ├── ConfigFile1
│?? │?? ├── ConfigFile2
│?? ├── Apps
│?? │?? ├── App1
│?? │?? ├── App2
│?? │?? └── App3
│?? ├── ManagementEnvironments
│?? │?? ├── Database
│?? │?? │?? ├── DbFile1
│?? │?? │?? └── DbFile2
│?? │?? ├── Infrastructure
│?? ├── TestEnvironments
│?? │?? ├── Pipeline
│?? │?? │?? └── Pipeline1
│?? │?? ├── Database
│?? │?? │?? ├── Pipeline2
│?? ├── Console
│?? │?? ├── Console1
│?? │?? ├── Console2
到目前為止,它對我們有益 . 現在我們需要解析文件夾并獲取配置文件中不以環境結尾的所有文件夾的列表 . 因此,在這種情況下,基本上包括應用程序和控制臺 .
執行以下操作時,我會重復應用3次,因為許多文件都在其下面,而控制臺則是2次 .
我想獲得一個文件夾列表,這些文件夾不會僅以環境結束一次 .
我試著看看Go模板和一些掌舵圖工具包,但我沒有Go的經驗,這似乎是要求實現這一點,我可能會接下來的幾天 . 但是現在我被困住了,所以任何幫助都會受到贊賞 .
{{- range $path, $bytes := $.Files.Glob "configs/**" }}
{{- if not (or (dir $path | regexFind "configs.*Environments.*") (dir $path | regexFind "configs$")) }}
{{ base (dir $path) }}
{{- end }}
{{- end }}