setup.go 570 B

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