riok / Kreya

Kreya is a GUI client for gRPC and REST APIs with innovative features for environments, authorizations and more.
https://kreya.app
279 stars 5 forks source link

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

Closed iancullinane closed 2 months ago

iancullinane commented 4 months ago

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.

CommonGuy commented 4 months ago

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 commented 3 months ago

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

CommonGuy commented 2 months ago

Kreya 1.14 has been released