Skip to content

Commit

Permalink
Merge pull request #34 from FabianKramm/hooks
Browse files Browse the repository at this point in the history
feat: add generic controller
  • Loading branch information
FabianKramm authored Aug 30, 2022
2 parents 68a7bf2 + 1dcab88 commit 0b2ce49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,16 @@ func (m *manager) start() error {
return errors.Wrapf(err, "start %s syncer", v.Name())
}
}

// controller starter?
controllerStarter, ok := v.(syncer.ControllerStarter)
if ok {
log.Infof("Start controller %s", v.Name())
err = controllerStarter.Register(m.context)
if err != nil {
return errors.Wrapf(err, "start %s controller", v.Name())
}
}
}

log.Infof("Successfully started plugin.")
Expand Down
6 changes: 6 additions & 0 deletions syncer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,9 @@ type IndicesRegisterer interface {
type ControllerModifier interface {
ModifyController(ctx *context.RegisterContext, builder *builder.Builder) (*builder.Builder, error)
}

// ControllerStarter is a generic controller that can be used if the syncer abstraction does not fit
// the use case
type ControllerStarter interface {
Register(ctx *context.RegisterContext) error
}

0 comments on commit 0b2ce49

Please sign in to comment.