github.com/rawahars/moby@v24.0.4+incompatible/libnetwork/drivers/bridge/setup.go (about)

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