outofcoffee / imposter

Scriptable, multipurpose mock server. Run standalone mock servers, or embed mocks within your tests.

Home Page:https://imposter.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where to set what

hilsonp opened this issue · comments

Imposter is really flexible and that is the best way to cope with all different use cases.

I usually struggle finding where to set what.
I usually go through the doc,
then try to sniff the file imposter seeks with a strace -fvttTyy -s 256 -o /tmp/strace.txt imposter up ~imposter/mocks/myapi-v1
then browse the github issues,
then, I end-up in the code, trying to find some clues.

Would it be possible to have in the documentation le list of places from where imposter inherit his configuration (cli, ENV variables, global config file(s), mock(s) config file(s), ...).
Then, for each of them (probably some are just synonyms), list all the different configuration variables).

This is not urgent but I went through the loop several times and thought I would suggest it.

For example, I'm trying to find where I could setup the listenPort in a configuration file.
The point is that all our mock configuration/declaration is made in git and I'm trying to avoir any CLI parameter by putting them all in configuration files.

In a previous issue, you also told me that the version could be pinned thanks to the ".imposter.yaml file in the config directory". The point is that the configuration directory may be the imposter configuration directory or the directory where the mock -config.yaml is stored (as this is named the CONFIG_DIR here https://github.com/gatehill/imposter-cli).

note: my user is imposter

[imposter@myhost ~]$ ls -la ~imposter/.imposter/
total 12
drwxr-xr-x 5 imposter sites 107 Jun 12 15:46 .
drwx------ 7 imposter sites 185 Jun 12 15:53 ..
-rw-r--r-- 1 imposter sites  28 Jun  8 12:32 config.yaml
drwx------ 2 imposter sites  60 Jun 12 15:48 engines
drwx------ 2 imposter sites   6 Jun  8 12:30 ext
drwx------ 2 imposter sites   6 Jun  8 09:10 filecache
-rwxr-xr-x 1 imposter sites  34 Jun  8 12:09 .imposter.env
-rw-r--r-- 1 imposter sites  51 Jun 12 15:48 prefs.json



[imposter@myhost ~]$ ls -la ~imposter/mocks/myapi-v1/
total 24
drwxr-xr-x 3 imposter sites 4096 Jun 12 17:18 .
drwxr-xr-x 6 imposter sites  153 Jun  8 16:01 ..
-rw-r--r-- 1 imposter sites   34 Jun 12 17:16 .imposter.yaml
-rw-r----- 1 imposter sites  628 Jun  8 15:44 myapi-v1-config.yaml

[imposter@myhost ~]$ cat ~imposter/mocks/myapi-v1/.imposter.yaml
listenPort: 8082
version: 3.22.0

[imposter@myhost ~]$ imposter up ~imposter/mocks/myapi-v1
DEBU[0000] engine binary '3.22.1' already present
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
17:19:37 INFO  i.g.i.Imposter - Starting mock engine 3.22.1
17:19:37 DEBUG i.g.i.c.u.ConfigUtil - Loading configuration file: /home/sites/imposter/mocks/myapi-v1/myapi-v1-config.yaml
17:19:39 INFO  i.g.i.Imposter - Mock engine up and running on http://localhost:8080
INFO[0003] watching for changes to: /home/sites/imposter/mocks/myapi-v1
^C
INFO[0007] stopping mock engine
DEBU[0007] shutting down

My idea being to be able to set "CLI parameter" in the configuration files.

  1. first in the global configuration file ~/.imposter/config.yaml
  2. then superseeded by mock configuration file (eg: ~imposter/mocks/myapi-v1/.imposter.yaml or as part of ~imposter/mocks/myapi-v1/myapi-v1-config.yaml)