github.com/jdolitsky/cnab-go@v0.7.1-beta1/action/operation_configs.go (about)

     1  package action
     2  
     3  import (
     4  	"github.com/deislabs/cnab-go/driver"
     5  )
     6  
     7  // OperationConfigFunc is a configuration function that can be applied to an
     8  // operation.
     9  type OperationConfigFunc func(op *driver.Operation) error
    10  
    11  // OperationConfigs is a set of configuration functions that can be applied as a
    12  // unit to an operation.
    13  type OperationConfigs []OperationConfigFunc
    14  
    15  // ApplyConfig safely applies the configuration function to the operation, if
    16  // defined, and stops immediately upon the first error.
    17  func (cfgs OperationConfigs) ApplyConfig(op *driver.Operation) error {
    18  	var err error
    19  	for _, cfg := range cfgs {
    20  		err = cfg(op)
    21  		if err != nil {
    22  			return err
    23  		}
    24  	}
    25  	return nil
    26  }