tokens

package
v3.82.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 137

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeTokens added in v3.81.0

func ComputeTokens(info *info.Provider, opts Strategy) error

Assigns resource and data source tokens unless already specified by the user.

Context: bridging a provider requires every TF resource and data source have a matching entry in [Resources] and [DataSources]. Each entry needs to minimally specifying the Pulumi token in [ResourceInfo.Tok]. The mapping entries can be done by hand for smaller provides but become a chore for providers with 1000s of entries.

ComputeTokens scans TF resources and datasources to populate missing entries as needed with automatically computed Pulumi tokens.

ComputeTokens always respects and does not modify pre-existing entires. The user can therefore manually override the token decision by providing [ResourceInfo] or [DataSourceInfo] entry prior to calling ComputeTokens.

ComputeTokens respects [ProviderInfo.IgnoreMappings]. It will not create a mapping for any token in [ProviderInfo.IgnoreMappings].

Types

type DataSourceStrategy added in v3.81.0

type DataSourceStrategy = info.DataSourceStrategy

type InferredModulesOpts

type InferredModulesOpts struct {
	// The TF prefix of the package.
	TfPkgPrefix string
	// The name of the main module. Defaults to "index".
	MainModule string
	// The minimum number of shared items for a prefix before it becomes a module.
	//
	// < 0 -> don't bin into modules.
	// = 0 -> apply the default value.
	// > 0 -> set the value.
	MinimumModuleSize int
	// The number of items in a longer prefix needed to break out into it's own prefix.
	//
	// For example, with the tokens `pkg_mod_sub1_a`, `pkg_mod_sub2_b`, `pkg_mod_sub2_c`,
	// `pkg_mod_sub3_d`:
	//
	// MinimumSubmoduleSize = 3 will result in:
	//
	//	pkg:mod:Sub1A, pkg:mod:Sub2B, pkg:mod:Sub2C, pkg:mod:Sub3D
	//
	// MinimumSubmoduleSize = 2 will result in:
	//
	//	pkg:mod:Sub1A, pkg:modSub2:B, pkg:modSub2C, pkg:mod:Sub3D
	//
	// < 0 -> don't bin into submodules. Only the most common prefix will be used.
	// = 0 -> apply the default value.
	// > 0 -> set the value.
	MimimumSubmoduleSize int
}

type Make

type Make func(module, name string) (string, error)

A function that joins a module and name into a pulumi type token.

For example:

func(module, name string) (string, error) {
 return fmt.Sprintf("pkgName:%s:%s", module, name), nil
}

func MakeStandard

func MakeStandard(pkgName string) Make

Convert a Terraform token to a Pulumi token with the standard mapping.

The mapping is

(pkg, module, name) => pkg:module/lowerFirst(name):name

type ResourceStrategy added in v3.81.0

type ResourceStrategy = info.ResourceStrategy

type Strategy added in v3.81.0

type Strategy = info.Strategy

Describe the mapping from TF resource and datasource tokens to Pulumi resources and datasources.

func InferredModules

func InferredModules(
	p *info.Provider, finalize Make, opts *InferredModulesOpts,
) (Strategy, error)

A strategy to infer module placement from global analysis of all items (Resources & DataSources).

func KnownModules

func KnownModules(
	tfPackagePrefix, defaultModule string, modules []string, finalize Make,
) Strategy

A strategy for assigning tokens to a hand generated set of modules.

If defaultModule is "", then the returned strategies will error on not encountering a matching module.

func MappedModules

func MappedModules(
	tfPackagePrefix, defaultModule string, modules map[string]string, finalize Make,
) Strategy

A strategy for assigning tokens to a hand generated set of modules with an arbitrary mapping from TF modules to Pulumi modules.

If defaultModule is "", then the returned strategies will error on not encountering a matching module.

func SingleModule

func SingleModule(
	tfPackagePrefix, moduleName string, finalize Make,
) Strategy

A strategy that assigns all tokens to the same module.

For example:

rStrat, dStrat := SingleModule("pkgName_", "index", finalize)

The above example would transform "pkgName_foo" into "pkgName:index:Foo".

Jump to

Keyboard shortcuts

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