dotnet / tye

Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
MIT License
5.28k stars 520 forks source link

Expand variable substitution in tye.yaml #597

Open areller opened 4 years ago

areller commented 4 years ago

What should we add or change to make your life better?

Expand syntax for variable substitution in tye.yaml Example:

name: example
variables:
  - name: somebin
    value: /usr/bin/somebin
services:
  - name: service-1
     executable: "${somebin} --path ${workdir}/someproject --port ${service:bindings[0]:port}"
     bindings:
       - protocol: http
          port: 8080

I know that this was already proposed and is supported in the connectionString field, but that was in the context of service discovery. I think that there are other contexts where it can be useful.

These kind of variables will be resolved entirely during the tye.yaml build/parse process (before the host starts)

Why is this important to you?

I was trying to run a legacy project (.NET Framework, IIS) project and I came up with a config that looks like this

name: iis
ingress:
  - name: ingress
    bindings:
      - port: 81
    rules:
      - host: mysite1
        service: iis-webapi1
services:
  - name: iis-webapi1
    executable: 'C:\Program Files\IIS Express\iisexpress.exe'
    args: '/path:C:\Users\areller\source\repos\iis-project\iis-website /port:9001'
    bindings:
      - protocol: http
        port: 9001

this is verbose, hard for modification and can't be shared among other people. with variables, it can become:

name: iis
variables:
  - name: iis_path
    value: 'C:\Program Files\IIS Express\iisexpress.exe'
ingress:
  - name: ingress
    bindings:
      - port: 81
    rules:
      - host: mysite1
        service: iis-webapi1
services:
  - name: iis-webapi1
    executable: ${iis_path}
    args: '/path:${workdir}\iis-website /port:${service:bindings[0]:port}'
    bindings:
      - protocol: http
        port: 9001
tebeco commented 4 years ago

look like a great idea that would be somehow "equivalent" to helm variables

Does this already recognize EnvVar or would that also be an idea to add to it ? Kinda like MsBuild "transform" EnvVar to an equivalent Property

eg: displaying secrets.json in VS <Content link="..." ...="$(AppData)/Microsoft/UserSecrets/$(UserSecretId)/secrets.json />

areller commented 4 years ago

Some fields already support env var substitution (ex: the project field) but some don't (ex: the args field), and the env var substitution syntax looks like this: something_%somevar%