Movatterモバイル変換


[0]ホーム

URL:


terraform

package
v0.20.0Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License:MITImports:16Imported by:3

Details

Repository

github.com/terraform-docs/terraform-docs

Links

Documentation

Overview

Package terraform is the representation of a Terraform Module.

It contains:

• Header: Module header found in shape of multi line '*.tf' comments or an entire file

• Footer: Module footer found in shape of multi line '*.tf' comments or an entire file

• Inputs: List of input 'variables' extracted from the Terraform module .tf files

• ModuleCalls: List of 'modules' extracted from the Terraform module .tf files

• Outputs: List of 'outputs' extracted from Terraform module .tf files

• Providers: List of 'providers' extracted from resources used in Terraform module

• Requirements: List of 'requirements' extracted from the Terraform module .tf files

• Resources: List of 'resources' extracted from the Terraform module .tf files

Usage

options := &terraform.Options{    Path:           "./examples",    ShowHeader:     true,    HeaderFromFile: "main.tf",    ShowFooter:     true,    FooterFromFile: "footer.md",    SortBy: &terraform.SortBy{        Name: true,    },    ReadComments: true,}tfmodule, err := terraform.LoadWithOptions(options)if err != nil {    log.Fatal(err)}...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeInput

type Input struct {Namestring       `json:"name" toml:"name" xml:"name" yaml:"name"`Typetypes.String `json:"type" toml:"type" xml:"type" yaml:"type"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`Defaulttypes.Value  `json:"default" toml:"default" xml:"default" yaml:"default"`Requiredbool         `json:"required" toml:"required" xml:"required" yaml:"required"`PositionPosition     `json:"-" toml:"-" xml:"-" yaml:"-"`}

Input represents a Terraform input.

func (*Input)GetValue

func (i *Input) GetValue()string

GetValue returns JSON representation of the 'Default' value, which is an 'interface'.If 'Default' is a primitive type, the primitive value of 'Default' will be returnedand not the JSON formatted of it.

func (*Input)HasDefault

func (i *Input) HasDefault()bool

HasDefault indicates if a Terraform variable has a default value set.

typeModule

type Module struct {XMLNamexml.Name `json:"-" toml:"-" xml:"module" yaml:"-"`Headerstring         `json:"header" toml:"header" xml:"header" yaml:"header"`Footerstring         `json:"footer" toml:"footer" xml:"footer" yaml:"footer"`Inputs       []*Input       `json:"inputs" toml:"inputs" xml:"inputs>input" yaml:"inputs"`ModuleCalls  []*ModuleCall  `json:"modules" toml:"modules" xml:"modules>module" yaml:"modules"`Outputs      []*Output      `json:"outputs" toml:"outputs" xml:"outputs>output" yaml:"outputs"`Providers    []*Provider    `json:"providers" toml:"providers" xml:"providers>provider" yaml:"providers"`Requirements []*Requirement `json:"requirements" toml:"requirements" xml:"requirements>requirement" yaml:"requirements"`Resources    []*Resource    `json:"resources" toml:"resources" xml:"resources>resource" yaml:"resources"`RequiredInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"`OptionalInputs []*Input `json:"-" toml:"-" xml:"-" yaml:"-"`}

Module represents a Terraform module. It consists of

funcLoadWithOptions

func LoadWithOptions(config *print.Config) (*Module,error)

LoadWithOptions returns new instance of Module with all the inputs andoutputs discovered from provided 'path' containing Terraform config

func (*Module)HasFooter

func (m *Module) HasFooter()bool

HasFooter indicates if the module has footer.

func (*Module)HasHeader

func (m *Module) HasHeader()bool

HasHeader indicates if the module has header.

func (*Module)HasInputs

func (m *Module) HasInputs()bool

HasInputs indicates if the module has inputs.

func (*Module)HasModuleCalls

func (m *Module) HasModuleCalls()bool

HasModuleCalls indicates if the module has modulecalls.

func (*Module)HasOutputs

func (m *Module) HasOutputs()bool

HasOutputs indicates if the module has outputs.

func (*Module)HasProviders

func (m *Module) HasProviders()bool

HasProviders indicates if the module has providers.

func (*Module)HasRequirements

func (m *Module) HasRequirements()bool

HasRequirements indicates if the module has requirements.

func (*Module)HasResources

func (m *Module) HasResources()bool

HasResources indicates if the module has resources.

typeModuleCall

type ModuleCall struct {Namestring       `json:"name" toml:"name" xml:"name" yaml:"name"`Sourcestring       `json:"source" toml:"source" xml:"source" yaml:"source"`Versionstring       `json:"version" toml:"version" xml:"version" yaml:"version"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`PositionPosition     `json:"-" toml:"-" xml:"-" yaml:"-"`}

ModuleCall represents a submodule called by Terraform module.

func (*ModuleCall)FullName

func (mc *ModuleCall) FullName()string

FullName returns full name of the modulecall, with version if available

typeOutput

type Output struct {Namestring       `json:"name" toml:"name" xml:"name" yaml:"name"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`Valuetypes.Value  `json:"value,omitempty" toml:"value,omitempty" xml:"value,omitempty" yaml:"value,omitempty"`Sensitivebool         `json:"sensitive,omitempty" toml:"sensitive,omitempty" xml:"sensitive,omitempty" yaml:"sensitive,omitempty"`PositionPosition     `json:"-" toml:"-" xml:"-" yaml:"-"`ShowValuebool         `json:"-" toml:"-" xml:"-" yaml:"-"`}

Output represents a Terraform output.

func (*Output)GetValue

func (o *Output) GetValue()string

GetValue returns JSON representation of the 'Value', which is an 'interface'.If 'Value' is a primitive type, the primitive value of 'Value' will be returnedand not the JSON formatted of it.

func (*Output)HasDefault

func (o *Output) HasDefault()bool

HasDefault indicates if a Terraform output has a default value set.

func (*Output)MarshalJSON

func (o *Output) MarshalJSON() ([]byte,error)

MarshalJSON custom yaml marshal function to take '--output-values' flag intoconsideration. It means if the flag is not set Value and Sensitive fields areset to 'omitempty', otherwise if output values are being shown 'omitempty' getsexplicitly removed to show even empty and false values.

func (*Output)MarshalXML

func (o *Output) MarshalXML(e *xml.Encoder, startxml.StartElement)error

MarshalXML custom xml marshal function to take '--output-values' flag intoconsideration. It means if the flag is not set Value and Sensitive fieldsare set to 'omitempty', otherwise if output values are being shown 'omitempty'gets explicitly removed to show even empty and false values.

func (*Output)MarshalYAML

func (o *Output) MarshalYAML() (interface{},error)

MarshalYAML custom yaml marshal function to take '--output-values' flag intoconsideration. It means if the flag is not set Value and Sensitive fields areset to 'omitempty', otherwise if output values are being shown 'omitempty' getsexplicitly removed to show even empty and false values.

typePosition

type Position struct {Filenamestring `json:"-" toml:"-" xml:"-" yaml:"-"`Lineint    `json:"-" toml:"-" xml:"-" yaml:"-"`}

Position represents position of Terraform item (input, output, provider, etc) in a file.

typeProvider

type Provider struct {Namestring       `json:"name" toml:"name" xml:"name" yaml:"name"`Aliastypes.String `json:"alias" toml:"alias" xml:"alias" yaml:"alias"`Versiontypes.String `json:"version" toml:"version" xml:"version" yaml:"version"`PositionPosition     `json:"-" toml:"-" xml:"-" yaml:"-"`}

Provider represents a Terraform output.

func (*Provider)FullName

func (p *Provider) FullName()string

FullName returns full name of the provider, with alias if available

typeRequirement

type Requirement struct {Namestring       `json:"name" toml:"name" xml:"name" yaml:"name"`Versiontypes.String `json:"version" toml:"version" xml:"version" yaml:"version"`}

Requirement represents a requirement for Terraform module.

typeResource

type Resource struct {Typestring       `json:"type" toml:"type" xml:"type" yaml:"type"`Namestring       `json:"name" toml:"name" xml:"name" yaml:"name"`ProviderNamestring       `json:"provider" toml:"provider" xml:"provider" yaml:"provider"`ProviderSourcestring       `json:"source" toml:"source" xml:"source" yaml:"source"`Modestring       `json:"mode" toml:"mode" xml:"mode" yaml:"mode"`Versiontypes.String `json:"version" toml:"version" xml:"version" yaml:"version"`Descriptiontypes.String `json:"description" toml:"description" xml:"description" yaml:"description"`PositionPosition     `json:"-" toml:"-" xml:"-" yaml:"-"`}

Resource represents a managed or data type that is created by the module

func (*Resource)GetMode

func (r *Resource) GetMode()string

GetMode returns normalized resource type as "resource" or "data source"

func (*Resource)Spec

func (r *Resource) Spec()string

Spec returns the resource spec addresses a specific resource in the config.It takes the form: resource_type.resource_name[resource index]For more details, see:https://www.terraform.io/docs/cli/state/resource-addressing.html#resource-spec

func (*Resource)URL

func (r *Resource) URL()string

URL returns a best guess at the URL for resource documentation

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp