github.com/pulumi/terraform@v1.4.0/pkg/command/jsonfunction/parameter.go (about)

     1  package jsonfunction
     2  
     3  import (
     4  	"github.com/zclconf/go-cty/cty"
     5  	"github.com/zclconf/go-cty/cty/function"
     6  )
     7  
     8  // parameter represents a parameter to a function.
     9  type parameter struct {
    10  	// Name is an optional name for the argument.
    11  	Name string `json:"name,omitempty"`
    12  
    13  	// Description is an optional human-readable description
    14  	// of the argument
    15  	Description string `json:"description,omitempty"`
    16  
    17  	// IsNullable is true if null is acceptable value for the argument
    18  	IsNullable bool `json:"is_nullable,omitempty"`
    19  
    20  	// A type that any argument for this parameter must conform to.
    21  	Type cty.Type `json:"type"`
    22  }
    23  
    24  func marshalParameter(p *function.Parameter) *parameter {
    25  	if p == nil {
    26  		return &parameter{}
    27  	}
    28  
    29  	return &parameter{
    30  		Name:        p.Name,
    31  		Description: p.Description,
    32  		IsNullable:  p.AllowNull,
    33  		Type:        p.Type,
    34  	}
    35  }
    36  
    37  func marshalParameters(parameters []function.Parameter) []*parameter {
    38  	ret := make([]*parameter, len(parameters))
    39  	for k, p := range parameters {
    40  		ret[k] = marshalParameter(&p)
    41  	}
    42  	return ret
    43  }