Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

Figure out the right way to do configuration #4

Open
parkr opened this issue Aug 22, 2016 · 0 comments
Open

Figure out the right way to do configuration #4

parkr opened this issue Aug 22, 2016 · 0 comments

Comments

@parkr
Copy link
Owner

parkr commented Aug 22, 2016

Sometimes, out of laziness, I threw it in the package itself. We have a few options:

  • Add a Handler to every package which has all the fields necessary. Put all the actual event handlers on this object so it requires instantiation in order to use it
package chlog

// Just a default handler
var DefaultHandler = &Handler{} // modify me!

// then pull it into the hook handler
package main

func newJekyllHandler() *hooks.GlobalHandler {
  chlog.DefaultHandler.AddRepo("jekyll/jekyll") // or whatever, but key is you modify this package-wide handler
  return &hooks.GlobalHandler{
        Context:       newContext(),
        EventHandlers: map[hooks.EventType][]hooks.EventHandler{
          hooks.CreateEvent: {chlog.DefaultHandler.CreateReleaseOnTagHandler},
        },
    }
}
  • Do an exported variable that is an instance of the baseline Handler. The importing main package then just uses this
func newJekyllHandler() *hooks.GlobalHandler {
  chlogHandler := chlog.NewHandler()
  chlogHandler.AddRepo("jekyll/jekyll") // or whatever, but key is you make the handler
  return &hooks.GlobalHandler{
        Context:       newContext(),
        EventHandlers: map[hooks.EventType][]hooks.EventHandler{
          hooks.CreateEvent: {chlogHandler.CreateReleaseOnTagHandler},
        },
    }
}
  • Do configuration in JSON or something that offers us configuration of the handlers on a per-repo basis, like
{
  "jekyll/jekyll": {
    "lgtm": { "quorum": 2 },
    "affinity": {},
  },
  "jekyll/jekyll-help" : {
    "deprecate": {
      "message": "Hey! Thanks for your issue. We have moved..."
    }
  },
}

Then each package's Handler would be unmarshalled into a Go object and given the JSON values in the config.

Which which which?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant