github.com/jdolitsky/cnab-go@v0.7.1-beta1/bundle/parameters.go (about)

     1  package bundle
     2  
     3  // Parameter defines a single parameter for a CNAB bundle
     4  type Parameter struct {
     5  	Definition  string    `json:"definition" yaml:"definition"`
     6  	ApplyTo     []string  `json:"applyTo,omitempty" yaml:"applyTo,omitempty"`
     7  	Description string    `json:"description,omitempty" yaml:"description,omitempty"`
     8  	Destination *Location `json:"destination,omitemtpty" yaml:"destination,omitempty"`
     9  	Required    bool      `json:"required,omitempty" yaml:"required,omitempty"`
    10  }
    11  
    12  // AppliesTo returns a boolean value specifying whether or not
    13  // the Parameter applies to the provided action
    14  func (parameter *Parameter) AppliesTo(action string) bool {
    15  	if len(parameter.ApplyTo) == 0 {
    16  		return true
    17  	}
    18  	for _, act := range parameter.ApplyTo {
    19  		if action == act {
    20  			return true
    21  		}
    22  	}
    23  	return false
    24  }