Documentation ¶
Index ¶
- Constants
- func ConvertTFState(tfState *TFState, providerAddr string) models.Resource
- func GetWorkSpaceDir() (string, error)
- func TFError(infos []byte) error
- type Diagnostic
- type Pos
- type Range
- type Snippet
- type TFState
- type TerraformInfo
- type WorkSpace
- func (w *WorkSpace) Apply(ctx context.Context) (*TFState, error)
- func (w *WorkSpace) Destroy(ctx context.Context) error
- func (w *WorkSpace) GetProvider() (string, error)
- func (w *WorkSpace) InitWorkSpace(ctx context.Context) error
- func (w *WorkSpace) Read(ctx context.Context) (*TFState, error)
- func (w *WorkSpace) RefreshOnly(ctx context.Context) (*TFState, error)
- func (w *WorkSpace) SetResource(resource *models.Resource)
- func (w *WorkSpace) WriteHCL() error
- func (w *WorkSpace) WriteTFState(priorState *models.Resource) error
- type WorkspaceStore
Constants ¶
const ( HCLMAINFILE = "main.tf.json" HCLLOCKFILE = ".terraform.hcl.lock" TFSTATEFILE = "terraform.tfstate" )
Variables ¶
This section is empty.
Functions ¶
func ConvertTFState ¶
ConvertTFState convert Terraform State to kusion State
func GetWorkSpaceDir ¶
GetWrokSpaceDir return kusion terrafrom runtime workspace dir Defalut workspace dir is ~/.kusion/.terraform
Types ¶
type Diagnostic ¶
type Diagnostic struct { Severity string `json:"severity"` Summary string `json:"summary"` Detail string `json:"detail"` Range Range `json:"range"` Snippet Snippet `json:"snippet"` }
Diagnostic represents relevant fields of a Terraform CLI JSON-formatted log line diagnostic info
type Pos ¶
type Pos struct { // Line is a one-based count for the line in the indicated file. Line int `json:"line"` // Column is a one-based count of Unicode characters from the start of the line. Column int `json:"column"` // Byte is a zero-based offset into the indicated file. Byte int `json:"byte"` }
Pos represents a position in the source code.
type Range ¶
type Range struct { Filename string `json:"filename"` Start Pos `json:"start"` End Pos `json:"end"` }
DiagnosticRange represents the filename and position of the diagnostic subject. This defines the range of the source to be highlighted in the output. Note that the snippet may include additional surrounding source code if the diagnostic has a context range.
The Start position is inclusive, and the End position is exclusive. Exact positions are intended for highlighting for human interpretation only and are subject to change.
type Snippet ¶
type Snippet struct { Context string `json:"context"` Code string `json:"code"` StartLine int `json:"start_line"` HighlightStartOffset int `json:"highlight_start_offset"` HighlightEndOffset int `json:"highlight_end_offset"` Values []interface{} `json:"values"` }
Snippet represents source code information about the diagnostic. It is possible for a diagnostic to have a source (and therefore a range) but no source code can be found. In this case, the range field will be present and the snippet field will not.
type TFState ¶
type TFState struct { FormatVersion string `json:"format_version,omitempty"` TerraformVersion string `json:"terraform_version,omitempty"` Values *stateValues `json:"values,omitempty"` }
Terraform State schema from https://github.com/hashicorp/terraform/blob/main/internal/command/jsonstate/state.go
type TerraformInfo ¶
type TerraformInfo struct { Level string `json:"@level"` Message string `json:"@message"` Module string `json:"@module"` Timestamp time.Time `json:"@timestamp"` Diagnostic Diagnostic `json:"diagnostic"` Type string `json:"type"` }
TerraformInfo represent fields of a Terraform CLI JSON-formatted log line
type WorkSpace ¶
type WorkSpace struct {
// contains filtered or unexported fields
}
func (*WorkSpace) GetProvider ¶
GetProvider get provider addr from terraform lock file. return provider addr and erros eg. registry.terraform.io/hashicorp/local/2.2.3
func (*WorkSpace) InitWorkSpace ¶
InitWorkSpace init terraform runtime workspace
func (*WorkSpace) Read ¶
Read make terraform show call. Return terraform state model TODO: terraform show livestate.
func (*WorkSpace) RefreshOnly ¶
Refresh Sync Terraform State
func (*WorkSpace) SetResource ¶
SetResource set workspace resource
type WorkspaceStore ¶
WorkspaceStore store Terraform workspaces.
func GetWorkspaceStore ¶
func GetWorkspaceStore(fs afero.Afero) (WorkspaceStore, error)
GetWorkspaceStore find directory in the filesystem and store workspace return all terraform workspace record in the filesystem.