shalb / cluster.dev

Cloud-native infrastructure templating. Creating cloud installers for SaaS. Replication of complex cloud-native infrastructures.
https://docs.cluster.dev/
GNU Affero General Public License v3.0
401 stars 36 forks source link

Add path functions to templating #203

Closed romanprog closed 1 year ago

romanprog commented 1 year ago

What would you like to add Proposal functions list: For example project files placed in directory /home/user/cdev/staging/ Local stack template path: /home/user/cdev/staging/infra-template/ Remote template: github.com/shalb/cdev-aws-eks/

Function: projectPath (only for project level templating), returns absolute path to project dir: /home/user/cdev/staging/ Function templatePath (only for stack templates), returns absolute path to current template dir. For local template: /home/user/cdev/staging/infra-template/, for remote template /home/user/cdev/staging/.cluster.dev/templates/github.com_shalb_cdev-aws-eks/ (cache tmp dir) Function relativeProjectPath (absolutePath), argument - absolute path. Returns the relative file path from the project directory:

relativeProjectPath "/home/user/cdev/common-files/api.json"

returns ../common-files/api.json

Function relativeUnitPath (absolutePath), argument - absolute path. Returns the relative file path from the unit working directory:

relativeProjectPath "/home/user/cdev/common-files/api.json"

returns ../../../../common-files/api.json

romanprog commented 1 year ago

Added in v0.7.16 https://github.com/shalb/cluster.dev/releases/tag/v0.7.16