2021-08-23 09:14:53 -04:00
|
|
|
//go:build linux
|
2021-05-25 19:48:54 -04:00
|
|
|
// +build linux
|
|
|
|
|
2015-02-22 20:24:22 -05:00
|
|
|
package bridge
|
|
|
|
|
2015-05-22 13:56:36 -04:00
|
|
|
type setupStep func(*networkConfiguration, *bridgeInterface) error
|
2015-02-22 20:24:22 -05:00
|
|
|
|
2015-03-04 16:25:43 -05:00
|
|
|
type bridgeSetup struct {
|
2015-05-22 13:56:36 -04:00
|
|
|
config *networkConfiguration
|
2015-03-04 16:25:43 -05:00
|
|
|
bridge *bridgeInterface
|
|
|
|
steps []setupStep
|
2015-02-22 20:24:22 -05:00
|
|
|
}
|
|
|
|
|
2015-05-22 13:56:36 -04:00
|
|
|
func newBridgeSetup(c *networkConfiguration, i *bridgeInterface) *bridgeSetup {
|
2015-04-15 01:25:42 -04:00
|
|
|
return &bridgeSetup{config: c, bridge: i}
|
2015-02-22 20:24:22 -05:00
|
|
|
}
|
|
|
|
|
2015-03-04 16:25:43 -05:00
|
|
|
func (b *bridgeSetup) apply() error {
|
2015-02-22 20:24:22 -05:00
|
|
|
for _, fn := range b.steps {
|
2015-04-15 01:25:42 -04:00
|
|
|
if err := fn(b.config, b.bridge); err != nil {
|
2015-02-22 20:24:22 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-03-04 16:25:43 -05:00
|
|
|
func (b *bridgeSetup) queueStep(step setupStep) {
|
2015-02-22 20:24:22 -05:00
|
|
|
b.steps = append(b.steps, step)
|
|
|
|
}
|