Skip to content

Instantly share code, notes, and snippets.

@refs
Created December 7, 2021 21:53
Show Gist options
  • Save refs/c385557e70cf11a59f1d5627cd0e468e to your computer and use it in GitHub Desktop.
Save refs/c385557e70cf11a59f1d5627cd0e468e to your computer and use it in GitHub Desktop.

Config Demo

  • there are no high level differences
    • we got rid of cli flags for extensions
  • admins can still configure an instance using a single ocis.yaml
  • or overwrite global values present in ocis.yaml with extension.yaml (i.e: proxy.yaml)
  • formats supported are
    • json
    • yaml
    • but decoders are easy to extend
  • new dependency on https://nicedoc.io/gookit/config
  • fun note: we're already upstream contributors to their docs
  • we could remove a big dependency: Viper
    • viper's main issue: not thread safe, and we load config asynchronously.
  • shift in paradigm: each extension is responsible for its own config parsing beyond from the first ocis.yaml parsing. There is an inheritance aspect, that we won't dig into.
  • env variables work as usual, functionality was unchanged
  • in general all changes were made backwards compatible! following the spirit of the Go backwards compatibility promise, which is something that we want to stick to. Avoid changing behavior.
  • demo:
  1. prepare an ocis.yaml:
  2. run ocis with it and see changes on logs (faster to see)

ocis.yaml contents:

log:
  pretty: true
  color: true

proxy:
  http:
    addr: localhost:7777
  debug:
    addr: localhost:7776

expectations: all services run and proxy runs on localhost:7777 & localhost:7776

verify with: lsof -iTCP -n -P | grep 7777

  1. add a proxy.yaml with contents:
http:
  addr: localhost:6666
debug:
  addr: localhost:5555
  1. kill already running proxy: bin/ocis kill proxy
  2. run again the proxy: bin/ocis run proxy

it should now run in localhost:6666 and localhost:5555

verify with: lsof -iTCP -n -P | grep 6666

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment