-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment management and configuration #147
Comments
While working with APIs, we often need different setups for local machine, the development server, or the production API. Environments let us customize requests using variables so we can easily switch between different setups without changing requests. We don't need to remember all those values once they are in Postwoman. We can download environments, save them as JSON files, and upload them later. We can create, share, duplicate, export, and delete an environment. We can also import an environment as a single JSON file. Environment and global variables are always stored as strings. If we’re storing objects/arrays, be sure to JSON.stringify() them before storing, and JSON.parse() them while retrieving. Closely related to #139 |
Can i assign this to me and start working ? |
What is the value of saving the environment as text? |
JSON is prescribed as a standard format. For easy parsing key value pairs, filtering and iterating through arrays, etc. |
@Nachiappa how's your progress on this? |
Imo, one of the weaknesses of postman is that all variables are stored as strings... Even if they are objects or arrays or integers. {"foo":{"bar":"baz.com","qux":"http://"}} By storing environments as native objects, they could be referenced as: {{foo.qux}}{{foo.bar}} If all environments are stored as string, anything that is not a string must be preprocessed (i.e. using prescripts in postman) Additionally, storing objects would enable a templating engine like nunjucks to be used for variable handling in requests (mildly useful) and in post body (very useful) |
I have started to store the environment variables as an value in indexeddb . Hopefully I'll able to complete by tomorrow and provide you a status. Is that fine? |
Are there screenshots of how this feature should be implemented? Should it be like Heroku's platform with key-value pairs or like postman where we'll have something like pw.setEnvironmentVariable("a", "b") ? |
@liyasthomas this issue looks to be somewhat stale. mind if i take over on this one? |
@terranblake yeah sure! You can work on this 🚀 |
I think this should be combined with #188 |
This issue is overloaded anyway. It should probably be closed. |
Is what I would like to approach with the following plan.
I think the import/export functionality can be addressed separately, or as needed once I make progress on the basics for the environment. The plan would be the following (Steps delineate a planned PR):
|
@jgroom33 I think this issue and #188 are different in that #188 sounds more like a feature for chaining requests/response together to make a workflow. I interpreted this issue as a discussion for an implementation of a "global" environment that could be used between requests, but not dependent on a previous/next request existing. e.g. I want to specify the same token across all requests, or some garbage like that |
I was thinking that an editable cache could be used to set vars. With that implementation, there would be a json with responses and anything the user wants to specify. But that wouldn't address the requirement of loading a set of vars from a file. |
@jgroom33 i think loading a set of variables from a file should be moved to a separate issue entirely. A simple environment can be implemented without the need for import/export functionality and should reduce the scope of this issue. |
I second @terranblake 's opinion 👍 |
I agree that loading the vars from a file is a good separate issue. Where does that file get loaded to? Loading it into a UI space that only handles env vars is not as flexible as loading it into a general cache. |
Taking a stab at this one tonight. Probably going to skip the stripped down version of |
this is powerful: https://mozilla.github.io/nunjucks/ and is used by this: https://github.com/eykrehbein/strest |
Some storage reference options: |
using nunjucks also allows things like this: A common set of libraries can be implemented to handle:
|
@jgroom33 awesome suggestion on nunjucks 🔥 @terranblake get around nunjucks and see if it meets our requirements. async support is there 🙌🏼 |
@jgroom33 I like the suggestion for nunjucks. It looks like it has a lot of the same features as the language that I'm suggesting Liquid. I don't see a downside to using either, other than that the liquid language is still actively maintained, whereas nunjucks looks to be not as actively maintained. Based on personal preference I would suggest liquid, but I think both would be great options |
Looks like liquid is written in Ruby. So if you want to write any custom filters or methods, you'll need to use that language. |
liquid allows you to register custom filters using the JS lib that I normally use |
@terranblake ping! |
I am just unpinning this issue for now, due to inactivity and so I can pin the IE support issue as its more critical and help is needed. |
I guess env management isn't supported yet, is it? is it under development or just "paused"? |
Pre-request env management is supported. Fully-fledged Environment management and configuration development is kinda paused. |
Well actually yes. But once an env is set, it is stored to app's current state. And needs to manually change them for another env var. Well this sucks. |
I think the approach (UI, mainly) used in Postman is quite good, but I will prefer env values to be global by default but also having the ability to choose en values for each collection. I think that's better understood by example: let's say I'm working on some request for service Does it make sense to someone else? |
IMO, This should be implemented:
@luixal the first bullet should solve your requirement. |
I'm not sure about loading env vars from file. Why if you are you using just a hosted version in browser? Maybe importing vars from file to an environment would be enough. I agree about storing env vars as an object and allowing nested vars. Not sure about the "Allow using each variable", what do you mean @jgroom33 ? |
updated to include your recommend |
Just created a PR for environment management #591 |
#591 solves this, hence closing |
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
Postwoman should have an environment setup so that we can manage the variables between multiple requests and also it should support import/export functionalities
Describe alternatives you've considered
N/A
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: