github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/jsonprovider/schema.go (about)

     1  package jsonprovider
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/internal/configs/configschema"
     5  )
     6  
     7  type Schema struct {
     8  	Version uint64 `json:"version"`
     9  	Block   *Block `json:"block,omitempty"`
    10  }
    11  
    12  // marshalSchema is a convenience wrapper around mashalBlock. Schema version
    13  // should be set by the caller.
    14  func marshalSchema(block *configschema.Block) *Schema {
    15  	if block == nil {
    16  		return &Schema{}
    17  	}
    18  
    19  	var ret Schema
    20  	ret.Block = marshalBlock(block)
    21  
    22  	return &ret
    23  }
    24  
    25  func marshalSchemas(blocks map[string]*configschema.Block, rVersions map[string]uint64) map[string]*Schema {
    26  	if blocks == nil {
    27  		return map[string]*Schema{}
    28  	}
    29  	ret := make(map[string]*Schema, len(blocks))
    30  	for k, v := range blocks {
    31  		ret[k] = marshalSchema(v)
    32  		version, ok := rVersions[k]
    33  		if ok {
    34  			ret[k].Version = version
    35  		}
    36  	}
    37  	return ret
    38  }