tfgen

package
v3.63.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 64 Imported by: 282

Documentation

Overview

Pulling out some of the repeated strings tokens into constants would harm readability, so we just ignore the goconst linter's warning.

Index

Constants

View Source
const (
	Success = 0
	Warning = 1
	Failure = 2
	Fatal   = 3
)

Conversion outcome severity values

Variables

View Source
var AllLanguages = []Language{Golang, NodeJS, Python, CSharp}

Functions

func GenerateSchema

func GenerateSchema(info tfbridge.ProviderInfo, sink diag.Sink) (pschema.PackageSpec, error)

func LoadGoMod

func LoadGoMod() (*modfile.File, error)

func Main

func Main(pkg string, version string, prov tfbridge.ProviderInfo)

Main executes the TFGen process for the given package pkg and provider prov.

func MainWithCustomGenerate added in v3.34.0

func MainWithCustomGenerate(pkg string, version string, prov tfbridge.ProviderInfo,
	gen func(GeneratorOptions) error)

Like Main but allows to customize the generation logic past the parsing of cmd-line arguments.

Types

type ConversionError added in v3.34.0

type ConversionError struct {
	// contains filtered or unexported fields
}

A ConversionError occurs when convert.Convert yields a panic. This can be removed when https://github.com/pulumi/pulumi-terraform-bridge/issues/477 is resolved. ConversionError exposes the stacktrace of the panic so callers can choose to pass the trace along to the user or swallow it.

func (*ConversionError) Error added in v3.34.0

func (err *ConversionError) Error() string

Return the err-representation of this struct.

func (*ConversionError) StackTrace added in v3.34.0

func (err *ConversionError) StackTrace() string

StackTrace returns the stacktrace of the error.

func (*ConversionError) Unwrap added in v3.34.0

func (err *ConversionError) Unwrap() error

Unwrap provides error as returned by the conversion panic.

type CoverageTracker added in v3.6.0

type CoverageTracker struct {
	ProviderName    string // Name of the provider
	ProviderVersion string // Version of the provider

	EncounteredPages map[string]*DocumentationPage // Map linking page IDs to their data
	// contains filtered or unexported fields
}

Main overarching structure for storing coverage data on how many examples were processed, how many failed, and for what reason. At different stages, the code translator notifies the tracker of what is going on. Notifications are treated as an ordered sequence of events.

NOTIFICATION INTERFACE:

foundExample(pageName, hcl)

languageConversionSuccess(targetLanguage)

languageConversionWarning(targetLanguage, warningDiagnostics)

languageConversionFailure(targetLanguage, failureDiagnostics)

languageConversionPanic(targetLanguage, panicInfo)

type DocFile added in v3.61.0

type DocFile struct {
	Content  []byte
	FileName string
}

type DocKind

type DocKind string

DocKind indicates what kind of entity's documentation is being requested.

const (
	// ResourceDocs indicates documentation pertaining to resource entities.
	ResourceDocs DocKind = "resources"
	// DataSourceDocs indicates documentation pertaining to data source entities.
	DataSourceDocs DocKind = "data-sources"
)

func (DocKind) String added in v3.19.2

func (k DocKind) String() string

type DocsSource added in v3.61.0

type DocsSource interface {
	// contains filtered or unexported methods
}

A source of documentation bytes.

func NewGitRepoDocsSource added in v3.61.0

func NewGitRepoDocsSource(g *Generator) DocsSource

type DocumentationPage added in v3.12.0

type DocumentationPage struct {
	Name     string    // The unique ID of this documentation page
	Examples []Example // This page's examples, stored in the order they were found
}

A structure encompassing a single page, which contains one or more examples. This closely resembles the web pages seen in Pulumi/Terraform documentation.

type Example added in v3.12.0

type Example struct {
	OriginalHCL       string                               // Original HCL code that the example was found with
	ConversionResults map[string]*LanguageConversionResult // Mapping language names to their conversion results
}

Contains information about a single example, consisting of a block of HCL and one or more language conversion results.

type GenerateOptions

type GenerateOptions struct {
	ModuleFormat string
}

type GenerateSchemaOptions added in v3.34.0

type GenerateSchemaOptions struct {
	ProviderInfo    tfbridge.ProviderInfo
	DiagnosticsSink diag.Sink
}

type GenerateSchemaResult added in v3.34.0

type GenerateSchemaResult struct {
	PackageSpec pschema.PackageSpec
	Renames     Renames
}

func GenerateSchemaWithOptions added in v3.34.0

func GenerateSchemaWithOptions(opts GenerateSchemaOptions) (*GenerateSchemaResult, error)

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(opts GeneratorOptions) (*Generator, error)

NewGenerator returns a code-generator for the given language runtime and package info.

func (*Generator) Generate

func (g *Generator) Generate() error

Generate creates Pulumi packages from the information it was initialized with.

func (*Generator) Renames added in v3.34.0

func (g *Generator) Renames() (Renames, error)

Remanes can be called after a successful call to Generate to extract name mappings.

func (*Generator) UnstableGenerateFromSchema added in v3.44.0

func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaResult) error

GenerateFromSchema creates Pulumi packages from a pulumi schema and the information the generator was initialized with.

This is an unstable API. We have exposed it so other packages within pulumi-terraform-bridge can consume it. We do not recommend other packages consume this API.

type GeneratorOptions

type GeneratorOptions struct {
	Package            string
	Version            string
	Language           Language
	ProviderInfo       tfbridge.ProviderInfo
	Root               afero.Fs
	ProviderInfoSource il.ProviderInfoSource
	PluginHost         plugin.Host
	TerraformVersion   string
	Sink               diag.Sink
	Debug              bool
	SkipDocs           bool
	SkipExamples       bool
	CoverageTracker    *CoverageTracker
}

type GetRepoPathErr added in v3.61.0

type GetRepoPathErr struct {
	Expected   string
	Underlying error
}

An error that represents a missing repo path directory.

func (GetRepoPathErr) Error added in v3.61.0

func (e GetRepoPathErr) Error() string

func (GetRepoPathErr) Unwrap added in v3.61.0

func (e GetRepoPathErr) Unwrap() error

type Language

type Language string
const (
	Golang Language = "go"
	NodeJS Language = "nodejs"
	Python Language = "python"
	CSharp Language = "dotnet"
	Schema Language = "schema"
	PCL    Language = "pulumi"
)

type LanguageConversionResult added in v3.6.0

type LanguageConversionResult struct {
	FailureSeverity int    // This conversion's outcome: [Success, Warning, Failure, Fatal]
	FailureInfo     string // Additional in-depth information
	Program         string // Converted program

	// How many times this example has been converted to this language.
	// It is expected that this will be equal to 1.
	TranslationCount int
}

Individual language information concerning how successfully an example was converted to Pulumi

type Renames added in v3.34.0

type Renames struct {
	// Resources[t] stores the Terraform name for a resource identified by the Pulumi token t.
	Resources map[tokens.Type]string `json:"resources,omitempty"`

	// Functions[t] stores the Terraform name for a data source that maps to a Pulumi function with token t.
	Functions map[tokens.ModuleMember]string `json:"functions,omitempty"`

	// RenamedProperties[t][p] stores the Terraform name of a Pulumi property p on a type identified by Pulumi token
	// t, when this name is changed, that is RenamedProperties[t][p] != p. Here the t token can represent a Resource
	// type, a datasource (function) type, or an auxiliary type.
	RenamedProperties map[tokens.Token]map[tokens.Name]string `json:"renamedProperties,omitempty"`

	// Similar to RenamedProperties but pertains to provider-level config.
	RenamedConfigProperties map[tokens.Name]string `json:"renamedConfigProperties,omitempty"`
}

Tabulates information about custom inflected or pluralied names. Pulumi bridged providers and Terraform conversion tooling may need to consult these tables to accurately translate between Pulumi and Terraform names.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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