Skip to content
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

How can I have an environment-controllable value that defaults to true? #86

Closed
djMax opened this issue Jul 17, 2017 · 3 comments
Closed

Comments

@djMax
Copy link

djMax commented Jul 17, 2017

This is easy with a default of false:

{
   "enable_something": "env:SOME_ENV_VAR|b",
   "meddleware": {
      "something": {    
         "enabled": "config:enable_something"
      }
   }
}

But how can it be arranged to default to true? This is potentially a confit/shortstop thing more than a meddleware thing, though I can see changes to any of them to fix it.

@shaunwarman
Copy link
Member

shaunwarman commented Jul 19, 2017

Hey @djMax

You're right. You'd want to use confit to load your json configuration that uses confit's protocol option to pass in your custom shortstop protocol.

There is a similar setup in the tests here, but you would want to probably take it further and have confit do the work of loading the json and taking advantage of your custom shortstop protocol. Then you can pass that object to meddleware.

Additionally, the shortstop protocol would look very similar to the default env handler in shortstop-handlers.

It's late, but I'll create an example in the AM.

@shaunwarman
Copy link
Member

So here's a simple example using a new shortstop handler:
https://github.com/shaunwarman/custom-confit-shortstop-example

This new handler would need to be passed to confit options like mentioned above and used to resolve your config file. Then this config object can get passed to meddleware at startup.

@djMax
Copy link
Author

djMax commented Jul 27, 2017

Yes, I can definitely see how to do it with a shortstop, but this feels like something that shouldn't require one... Basically there is support for "true" as default, but not false. Weird.

@djMax djMax closed this as completed Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants