github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/libnetwork/drivers/bridge/setup.go (about)

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