tfgen

package
v3.30.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 54 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.

nolint: goconst

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.

Types

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 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 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 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.

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 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

	// 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

Jump to

Keyboard shortcuts

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