github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/libnetwork/drivers/bridge/setup.go (about)

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