setup.go 552 B

1234567891011121314151617181920212223242526
  1. package bridge
  2. type setupStep func(*networkConfiguration, *bridgeInterface) error
  3. type bridgeSetup struct {
  4. config *networkConfiguration
  5. bridge *bridgeInterface
  6. steps []setupStep
  7. }
  8. func newBridgeSetup(c *networkConfiguration, i *bridgeInterface) *bridgeSetup {
  9. return &bridgeSetup{config: c, bridge: i}
  10. }
  11. func (b *bridgeSetup) apply() error {
  12. for _, fn := range b.steps {
  13. if err := fn(b.config, b.bridge); err != nil {
  14. return err
  15. }
  16. }
  17. return nil
  18. }
  19. func (b *bridgeSetup) queueStep(step setupStep) {
  20. b.steps = append(b.steps, step)
  21. }