ashald / EnvFile

EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
MIT License
542 stars 129 forks source link

Set env variable to IP address #77

Closed tejoha closed 5 years ago

tejoha commented 5 years ago

This extension allows to set env variables dynamicly to the IP address of a Network Interface of the computer.

How it works?

  1. Set the value of your env variable to {{ip|defaultValue}}. The defaultValue will used if the IP address could not be determined. E.g. selected Network Interface is deactivated . Example for .env:
     host={{ip|localhost}}
     database={{ip|127.0.0.1}}
     VERSION=1.0
  2. Configure the EnvFile Plugin in normal way
  3. Activate the dynamic IP setting
  4. Choose one of the Network Interface of your Computer. The IP address is determined later from this interface. Note: If a Network Interface has multiple IP Addresses the first will be used
  5. Add your env file unbenannt
ashald commented 5 years ago

Thank you for your contribution! This indeed sounds like a great feature.

I've been thinking about it for a while and I'm a little bit concerned about adding it as a global setting as on the screenshot above, next to "enable substitution" etc. How do you like an idea of adding it as another "env provider type"? Currently "yaml", ".env" and so on are just datasource "plugins" that work with the extension points that EnvFile plugin exposes on its own. Current interface won't be enough for the functionality provided in this PR but I'd be positive on expanding it sufficiently for this. I could imagine table looking like:

Enabled Type Name Source
.env test.env File
yaml vars.yaml File
IP host MyNetworkAdapterName
tejoha commented 5 years ago

Thanks for your feedback. It sounds a great Idea! I like this! I will realise this (in July/August).

tejoha commented 5 years ago

Update: Working on it