dataspec

package
v0.4.2-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Documentable wrapper types form

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(body hcl.Body, spec RootSpec, ctx *hcl.EvalContext) (val cty.Value, diags diagnostics.Diag)

Wrapper over hcldec.Decode.

func ItemName

func ItemName(s Spec) string

Gets the name of the item (block or attr). It may be different form the name this item will have in the Object.

func RenderDoc

func RenderDoc(spec RootSpec, blockName string, labels ...string) string

RenderDoc renders the block documentation for spec.

Types

type AttrSpec

type AttrSpec struct {
	Name       string
	Type       cty.Type
	DefaultVal cty.Value
	ExampleVal cty.Value
	Doc        string

	Constraints constraint.Constraints
	// If set then value must be one of the specified values
	OneOf constraint.OneOf
	// For numbers - min value; for collections - min number of elements; for strings - min length
	MinInclusive cty.Value
	// For numbers - max value; for collections - max number of elements; for strings - max length
	MaxInclusive cty.Value
	// If specified – a deprecation warning would appear if an attribute is specified and non-null
	Deprecated string
	// If set then the value is hidden in logs
	Secret bool
}

AttrSpec represents the attribute value (hcldec.AttrSpec).

func (*AttrSpec) DocComment

func (a *AttrSpec) DocComment() hclwrite.Tokens

func (*AttrSpec) HcldecSpec

func (a *AttrSpec) HcldecSpec() (res hcldec.Spec)

func (*AttrSpec) KeyForObjectSpec

func (a *AttrSpec) KeyForObjectSpec() string

func (*AttrSpec) ValidateSpec

func (a *AttrSpec) ValidateSpec() (diags diagnostics.Diag)

func (*AttrSpec) ValidateValue

func (a *AttrSpec) ValidateValue(val cty.Value) (diags hcl.Diagnostics)

func (*AttrSpec) WriteDoc

func (a *AttrSpec) WriteDoc(w *hclwrite.Body)

type BlockSpec

type BlockSpec struct {
	Name     string
	Nested   Spec
	Doc      string
	Required bool
	// contains filtered or unexported fields
}

BlockSpec represents a nested block (hcldec.BlockSpec).

func (*BlockSpec) HcldecSpec

func (b *BlockSpec) HcldecSpec() hcldec.Spec

func (*BlockSpec) KeyForObjectSpec

func (b *BlockSpec) KeyForObjectSpec() string

func (*BlockSpec) ValidateSpec

func (b *BlockSpec) ValidateSpec() (errs diagnostics.Diag)

func (*BlockSpec) WriteDoc

func (b *BlockSpec) WriteDoc(w *hclwrite.Body)

type KeyForObjectSpec

type KeyForObjectSpec struct {
	Spec
	// contains filtered or unexported fields
}

Sets the name of Spec to be used as the key of hcldec.ObjectSpec.

func UnderKey

func UnderKey(key string, spec Spec) *KeyForObjectSpec

Specifies the key to be used in object spec

func (*KeyForObjectSpec) KeyForObjectSpec

func (ns *KeyForObjectSpec) KeyForObjectSpec() string

type ObjDumpSpec

type ObjDumpSpec struct {
	Doc string
	// contains filtered or unexported fields
}

Root-only spec

func (*ObjDumpSpec) HcldecSpec

func (o *ObjDumpSpec) HcldecSpec() hcldec.Spec

func (*ObjDumpSpec) IsEmpty

func (*ObjDumpSpec) IsEmpty() bool

func (*ObjDumpSpec) ValidateSpec

func (*ObjDumpSpec) ValidateSpec() (errs diagnostics.Diag)

func (*ObjDumpSpec) WriteDoc

func (o *ObjDumpSpec) WriteDoc(w *hclwrite.Body)

type ObjectSpec

type ObjectSpec []ObjectSpecChild

Wraps hcldec.ObjectSpec

func (ObjectSpec) HcldecSpec

func (o ObjectSpec) HcldecSpec() hcldec.Spec

func (ObjectSpec) IsEmpty

func (o ObjectSpec) IsEmpty() bool

func (ObjectSpec) ValidateSpec

func (o ObjectSpec) ValidateSpec() (errs diagnostics.Diag)

func (ObjectSpec) WriteDoc

func (o ObjectSpec) WriteDoc(w *hclwrite.Body)

type ObjectSpecChild

type ObjectSpecChild interface {
	Spec
	KeyForObjectSpec() string
}

Represents types that could be included as children in Object.

type OpaqueSpec

type OpaqueSpec struct {
	Spec hcldec.Spec
	Doc  string
}

OpaqueSpec adds an ability to use any hcldec.Spec (without automatic documentation generation).

func (*OpaqueSpec) HcldecSpec

func (o *OpaqueSpec) HcldecSpec() hcldec.Spec

func (*OpaqueSpec) ValidateSpec

func (*OpaqueSpec) ValidateSpec() (errs diagnostics.Diag)

func (*OpaqueSpec) WriteDoc

func (o *OpaqueSpec) WriteDoc(w *hclwrite.Body)

type RootSpec

type RootSpec interface {
	Spec
	// Must be safe to call on nil receiver
	IsEmpty() bool
	// contains filtered or unexported methods
}

RootSpec represents valid specs in root position (as .Args, .Config values).

type Spec

type Spec interface {
	HcldecSpec() hcldec.Spec
	WriteDoc(w *hclwrite.Body)

	ValidateSpec() diagnostics.Diag
	// contains filtered or unexported methods
}

Spec is a documentable wrapper over `hcldec.Spec`s.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL