-
Notifications
You must be signed in to change notification settings - Fork 6
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
Global variable support and Generate env JSON option #24
Changes from 4 commits
cca4db6
0c87717
84a4848
4dd0f23
655a236
548e43e
48f3154
d12b69b
549affb
a66383b
be15f49
a1b1b33
caece11
36d2d4f
ffc95e9
82690f1
c19afee
ce1359c
251ddef
cbe799f
58fbc92
2b505fc
312d5bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,17 @@ Cookies are specified in a `Cookie` header as follows: | |
Cookie:'sessionid=foo;another-cookie=bar' | ||
``` | ||
|
||
### Global Environments variables/commands can be defined in `/l2config.env/<requests_dir>` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Title is a bit clumsy.
Is much simpler. |
||
|
||
The *l2* loads up variables from `l2config.env` and then `l2.env`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again - the overwrite explanation is more complex to the reader/user. Simply say what order in which variables are searched for (nearest first):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either:
or
|
||
If same variable is found in `l2.env` then overwrites the global variable. | ||
Example `l2config.env`: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Screenshot needed to show project structure, and root. |
||
``` | ||
export PHOTO=`base64 aadhaarsmall.jpg` | ||
export AHOST="http://localhost:8001" | ||
``` | ||
|
||
### Environments variables/commands can be defined in `<requests_dir>/l2.env` | ||
|
||
By default, *l2* looks for a `l2.env` file in the same directory as the given | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
graph TD | ||
K["Controller Entry <br/>(controller)"] | ||
A["Parse CLI <br/>(lama2cmd)"] | ||
B["Parser <br/>(parser)"] | ||
B["Parser <br/>(parser)"] | ||
D["Request Executor <br/>(cmdexec)"] | ||
E["Output Format Manager <br/>(outputmanager)"] | ||
F["Error Reporting (TODO)"] | ||
|
@@ -48,7 +48,7 @@ From a high level, how does it work now? | |
2. Else if block is Requestor block | ||
1. Replace variables with values in the following order | ||
1. Try fetch variable from Javascript VM | ||
2. If (1) fails, try fetch variable from `l2.env` | ||
2. If (1) fails, try fetch variable from `l2config.env` and `l2.env` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "overwriting" is an implementation detail. When you talk to users - how does it work?
Always explain in this way. The implementation detail doesn't matter at documentation/explanation level. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay got it |
||
2. Use the processed elements to create an httpie-go request | ||
3. Fetch response | ||
5. If necessary, write the last transaction to `.json` file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ func GetLamaFileAsString(path string) string | |
func LamaFile(inputFile string) (string, string) | ||
``` | ||
|
||
LamaFile takes in a path to an API file. It moves into the API file directory, reads the API contents, loads the \`l2.env\` file if available, and finally substitutes environment vars in the API contents Once done, it reverts back to the original directory, and returns the processed l2 file. | ||
LamaFile takes in a path to an API file. It moves into the API file directory, reads the API contents, loads the \`l2config.env\` global variables file if available in any of parent directory and \`l2.env\` file if available in present directory , and finally substitutes environment vars in the API contents Once done, it reverts back to the original directory, and returns the processed l2 file. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment can make the "overwriting" part more obvious. Sentence is too long now, maybe simplify a bit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
|
||
## func [LoadElfEnv](<https://github.com/HexmosTech/Lama2/blob/master/preprocess/preprocess.go#L97>) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,18 @@ Get [Source File](https://github.com/HexmosTech/Lama2/tree/main/examples/0003_co | |
|
||
## Environment Variables: Switch base URL | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can make the documentation more structured (something like this) Case 1:
|
||
Specify variables in `l2.env` and then load | ||
them up in the API files. Presently, **the `l2.env` file should reside in the same directory as the `.l2` API file.** | ||
Specify global variables in `l2config.env` in parent directory. | ||
**The global variables of `l2config.env` will be overwritten by local `l2.env` variables.** | ||
|
||
Specify variables in `l2.env` and then load them up in the API files. | ||
Presently, **the `l2.env` file should reside in the same directory as the `.l2` API file.** | ||
|
||
**l2config.env** | ||
|
||
``` | ||
export LOCAL="http://localhost:8001" | ||
export REMOTE="http://httpbin.in" | ||
``` | ||
|
||
**l2.env** | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling it "global", I think we should call it something like:
Let's pick one of the above and finalize (or make other suggestions).
Second, I think we should use
git
repo analogy to explain.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the git repo analogy in example.md, should I link it here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analogy should be in the explanation section, not example section. When confused what belongs where, re-read this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes