commons

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBuildTFConfigDir error
	ErrBuildTFConfigDir = fmt.Errorf("failed to build terraform allResourcesConfig")
)

Functions

func CreateResourceConfig

func CreateResourceConfig(managedResource *hclConfigs.Resource) (resourceConfig output.ResourceConfig, err error)

CreateResourceConfig creates output.ResourceConfig

func GetConfigSource

func GetConfigSource(remoteURLMapping map[string]string, resourceConfig output.ResourceConfig, absRootDir string) (string, bool, error)

GetConfigSource - get the source path for the resource

func GetModuleProviderVersion added in v1.17.1

func GetModuleProviderVersion(module *hclConfigs.Module, addr addrs.Provider, terraformVersion string) string

GetModuleProviderVersion identifies the version constraints for module resources.

func GetProviderVersion added in v1.18.1

func GetProviderVersion(f *hclConfigs.File, addr addrs.Provider, terraformVersion string) string

GetProviderVersion identifies the version constraints for file resources.

func GetRemoteLocation

func GetRemoteLocation(cache map[string]string, resourcePath string) (remoteURL, tmpDir string)

GetRemoteLocation checks wether the source belongs to the remote module present in downloader cache. cache has key = remoteURL and value = tempDir

func LoadIacFile

func LoadIacFile(absFilePath, terraformVersion string) (allResourcesConfig output.AllResourceConfigs, err error)

LoadIacFile parses the given terraform file from the given file path

func ResolveProvider added in v1.18.1

func ResolveProvider(resource *hclConfigs.Resource, requiredProviders []*hclConfigs.RequiredProviders) addrs.Provider

ResolveProvider resolves provider addr

Types

type ModuleConfig

type ModuleConfig struct {
	Config           *hclConfigs.Config
	ParentModuleCall *hclConfigs.ModuleCall
	Name             string
}

ModuleConfig contains the *hclConfigs.Config for every module in the unified config tree along with *hclConfig.ModuleCall made by the parent module. The ParentModuleCall helps in resolving references for variables initilaized in the parent ModuleCall

type ProviderVersions added in v1.17.1

type ProviderVersions struct {
	Versions []struct {
		Version   string   `json:"version"`
		Protocols []string `json:"protocols"`
	} `json:"versions"`
	Warnings []string `json:"warnings"`
}

ProviderVersions ...

type RefResolver

type RefResolver struct {
	Config           *hclConfigs.Config
	ParentModuleCall *hclConfigs.ModuleCall
}

RefResolver tries to resolve all the references in the given terraform config

func NewRefResolver

func NewRefResolver(config *hclConfigs.Config,
	parentModuleCall *hclConfigs.ModuleCall) *RefResolver

NewRefResolver returns a new RefResolver struct

func (*RefResolver) ResolveLocalRef

func (r *RefResolver) ResolveLocalRef(localRef, callerRef string) interface{}

ResolveLocalRef returns the local value as configured in IaC config in module

func (*RefResolver) ResolveLookupRef

func (r *RefResolver) ResolveLookupRef(lookupRef, callerRef string) interface{}

ResolveLookupRef returns the lookup value as configured in IaC config in module

func (*RefResolver) ResolveModuleRef

func (r *RefResolver) ResolveModuleRef(moduleRef, callerRef string,
	children map[string]*hclConfigs.Config) interface{}

ResolveModuleRef tries to resolve cross module references

func (*RefResolver) ResolveRefs

func (r *RefResolver) ResolveRefs(config jsonObj) jsonObj

ResolveRefs figures out all the variable references in the resource config and tries to replace the variable references, if possible, with actual value

func (*RefResolver) ResolveStrRef

func (r *RefResolver) ResolveStrRef(ref, callerRef string) interface{}

ResolveStrRef tries to resolve a string reference. Reference can be a variable "${var.foo}", cross module variable "${module.foo.bar}", local value "${local.foo}"

func (*RefResolver) ResolveVarRef

func (r *RefResolver) ResolveVarRef(varRef, callerRef string) interface{}

ResolveVarRef returns the variable value as configured in IaC config in module

func (*RefResolver) ResolveVarRefFromParentModuleCall

func (r *RefResolver) ResolveVarRefFromParentModuleCall(varRef, callerRef string) interface{}

ResolveVarRefFromParentModuleCall returns the variable value as configured in ModuleCall from parent module. The resolved value can be an absolute value (string, int, bool etc.) or it can also be another reference, which may need further resolution

type TerraformDirectoryLoader

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

TerraformDirectoryLoader implements terraform directory loading

func NewTerraformDirectoryLoader

func NewTerraformDirectoryLoader(rootDirectory, terraformVersion string, options map[string]interface{}) TerraformDirectoryLoader

NewTerraformDirectoryLoader creates a new terraformDirectoryLoader

func (*TerraformDirectoryLoader) GetRemoteModuleIfPresentInTerraformSrc

func (t *TerraformDirectoryLoader) GetRemoteModuleIfPresentInTerraformSrc(req *hclConfigs.ModuleRequest) (src string, destpath string)

GetRemoteModuleIfPresentInTerraformSrc - Gets the remote module if present in terraform init cache

func (TerraformDirectoryLoader) LoadIacDir

func (t TerraformDirectoryLoader) LoadIacDir() (allResourcesConfig output.AllResourceConfigs, err error)

LoadIacDir starts traversing from the given rootDir and traverses through all the descendant modules present to create an output list of all the resources present in rootDir and descendant modules

type TerraformInstalledModuleMetaData

type TerraformInstalledModuleMetaData struct {
	Key        string `json:"Key"`
	SourceAddr string `json:"Source"`
	VersionStr string `json:"Version,omitempty"`
	Dir        string `json:"Dir"`
}

TerraformInstalledModuleMetaData metadata about the module downloaded and present in terraform cache.

type TerraformModuleManifest

type TerraformModuleManifest struct {
	Modules []TerraformInstalledModuleMetaData `json:"Modules"`
}

TerraformModuleManifest holds details of all modules downloaded by terraform

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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