Kreya icon indicating copy to clipboard operation
Kreya copied to clipboard

Is it possible to infer the environment name within the template?

Open iancullinane opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

I have two environments, local and production. Production has a proper url (eg www.product.com and in local production it is a vm so the address would be 172.18.1.100 and it may have a port. I would like to be able to switch production and dev with these addresses.

Describe the solution you'd like

I wanted to use some kind of if in scriban that can lookup which environment I am in and set a user variable accordingly.

Describe alternatives you've considered

I tried looking around for was default variables are available but couldn't find them. Nor did I see some place to print them. Are there default variables that can be accessed? I also don't see a way to print things that may be relevant in scripting, but I admit my xp is low with the languages and tooling.

iancullinane avatar Feb 09 '24 16:02 iancullinane

No, currently not. But you could simply put the environment name into the environment data like so:

{
  "name": "Production"
}

This would be available as {{ env.name }} in Scriban. Please note that we currently do not provide a way to access environment data in Scripting (=Tests), but this is on our roadmap.

CommonGuy avatar Feb 12 '24 12:02 CommonGuy

This has been implemented and was released with the newest beta release. It will be included in the next stable version.

CommonGuy avatar Mar 13 '24 14:03 CommonGuy

Kreya 1.14 has been released

CommonGuy avatar Apr 18 '24 07:04 CommonGuy