terraformutils

package
v0.0.0-...-53af832 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClosingBracketRegexp = regexp.MustCompile(`.?\\>`)
View Source
var OpeningBracketRegexp = regexp.MustCompile(`.?\\<`)

Functions

func ConnectServices

func ConnectServices(importResources map[string][]Resource, isServicePath bool, resourceConnections map[string]map[string][]string) map[string][]Resource

func ContainsResource

func ContainsResource(s []Resource, e Resource) bool

func FilterCleanup

func FilterCleanup(s *Service, isInitial bool)

func HclPrintResource

func HclPrintResource(resources []Resource, providerData map[string]interface{}, output string, sort bool) ([]byte, error)

Print hcl file from TerraformResource + provider

func IgnoreKeys

func IgnoreKeys(resourcesTypes []string, p *providerwrapper.ProviderWrapper) map[string][]string

func NewTfState

func NewTfState(resources []Resource) *terraform.State

func ParseFilterValues

func ParseFilterValues(value string) []string

func Print

func Print(data interface{}, mapsObjects map[string]struct{}, format string, sort bool) ([]byte, error)

func PrintTfState

func PrintTfState(resources []Resource) ([]byte, error)

func RefreshResourceWorker

func RefreshResourceWorker(input chan *Resource, wg *sync.WaitGroup, provider *providerwrapper.ProviderWrapper)

func RefreshResourcesByProvider

func RefreshResourcesByProvider(providersMapping *ProvidersMapping, providerWrapper *providerwrapper.ProviderWrapper) error

func TfSanitize

func TfSanitize(name string) string

Sanitize name for terraform style

func WalkAndCheckField

func WalkAndCheckField(path string, data interface{}) bool

func WalkAndGet

func WalkAndGet(path string, data interface{}) []interface{}

func WalkAndOverride

func WalkAndOverride(path, oldValue, newValue string, data interface{})

Types

type ApplicableFilter

type ApplicableFilter interface {
	IsApplicable(resourceName string) bool
}

type BaseResource

type BaseResource struct {
	Tags map[string]string `json:"tags,omitempty"`
}

type FlatmapParser

type FlatmapParser struct {
	Flatmapper
	// contains filtered or unexported fields
}

func NewFlatmapParser

func NewFlatmapParser(attributes map[string]string, ignoreKeys []*regexp.Regexp, allowEmptyValues []*regexp.Regexp) *FlatmapParser

func (*FlatmapParser) Parse

func (p *FlatmapParser) Parse(ty cty.Type) (map[string]interface{}, error)

FromFlatmap converts a map compatible with what would be produced by the "flatmap" package to a map[string]interface{} object type.

The intended result type must be provided in order to guide how the map contents are decoded. This must be an object type or this function will panic.

Flatmap values can only represent maps when they are of primitive types, so the given type must not have any maps of complex types or the result is undefined.

The result may contain null values if the given map does not contain keys for all of the different key paths implied by the given type.

type Flatmapper

type Flatmapper interface {
	Parse(ty cty.Type) (map[string]interface{}, error)
}

type Provider

type Provider struct {
	Service ServiceGenerator
	Config  cty.Value
}

func (*Provider) GenerateFiles

func (p *Provider) GenerateFiles()

func (*Provider) GenerateOutputPath

func (p *Provider) GenerateOutputPath() error

func (*Provider) GetBasicConfig

func (p *Provider) GetBasicConfig() cty.Value

func (*Provider) GetConfig

func (p *Provider) GetConfig() cty.Value

func (*Provider) GetName

func (p *Provider) GetName() string

func (*Provider) GetService

func (p *Provider) GetService() ServiceGenerator

func (*Provider) GetSupportedService

func (p *Provider) GetSupportedService() map[string]ServiceGenerator

func (*Provider) Init

func (p *Provider) Init(args []string) error

func (*Provider) InitService

func (p *Provider) InitService(serviceName string) error

type ProviderGenerator

type ProviderGenerator interface {
	Init(args []string) error
	InitService(serviceName string, verbose bool) error
	GetName() string
	GetService() ServiceGenerator
	GetConfig() cty.Value
	GetBasicConfig() cty.Value
	GetSupportedService() map[string]ServiceGenerator
	GenerateFiles()
	GetProviderData(arg ...string) map[string]interface{}
	GenerateOutputPath() error
	GetResourceConnections() map[string]map[string][]string
}

type ProvidersMapping

type ProvidersMapping struct {
	Resources map[*Resource]bool
	Services  map[string]bool
	Providers map[ProviderGenerator]bool
	// contains filtered or unexported fields
}

func NewProvidersMapping

func NewProvidersMapping(baseProvider ProviderGenerator) *ProvidersMapping

func (*ProvidersMapping) AddServiceToProvider

func (p *ProvidersMapping) AddServiceToProvider(service string) ProviderGenerator

func (*ProvidersMapping) CleanupProviders

func (p *ProvidersMapping) CleanupProviders()

func (*ProvidersMapping) ConvertTFStates

func (p *ProvidersMapping) ConvertTFStates(providerWrapper *providerwrapper.ProviderWrapper)

func (*ProvidersMapping) GetBaseProvider

func (p *ProvidersMapping) GetBaseProvider() ProviderGenerator

func (*ProvidersMapping) GetResourcesByService

func (p *ProvidersMapping) GetResourcesByService() map[string][]Resource

func (*ProvidersMapping) GetServices

func (p *ProvidersMapping) GetServices() []string

func (*ProvidersMapping) MatchProvider

func (p *ProvidersMapping) MatchProvider(resource *Resource) ProviderGenerator

func (*ProvidersMapping) ProcessResources

func (p *ProvidersMapping) ProcessResources(isCleanup bool)

func (*ProvidersMapping) RemoveServices

func (p *ProvidersMapping) RemoveServices(services []string)

func (*ProvidersMapping) SetResources

func (p *ProvidersMapping) SetResources(resourceToKeep []*Resource)

func (*ProvidersMapping) ShuffleResources

func (p *ProvidersMapping) ShuffleResources() []*Resource

type Resource

type Resource struct {
	InstanceInfo      *terraform.InstanceInfo
	InstanceState     *terraform.InstanceState
	Outputs           map[string]*terraform.OutputState `json:",omitempty"`
	ResourceName      string
	Provider          string
	Item              map[string]interface{} `json:",omitempty"`
	IgnoreKeys        []string               `json:",omitempty"`
	AllowEmptyValues  []string               `json:",omitempty"`
	AdditionalFields  map[string]interface{} `json:",omitempty"`
	SlowQueryRequired bool
	DataFiles         map[string][]byte
}

func NewResource

func NewResource(id, resourceName, resourceType, provider string,
	attributes map[string]string,
	allowEmptyValues []string,
	additionalFields map[string]interface{}) Resource

func NewSimpleResource

func NewSimpleResource(id, resourceName, resourceType, provider string, allowEmptyValues []string) Resource

func RefreshResources

func RefreshResources(resources []*Resource, provider *providerwrapper.ProviderWrapper, slowProcessingResources [][]*Resource) ([]*Resource, error)

func (*Resource) ConvertTFstate

func (r *Resource) ConvertTFstate(provider *providerwrapper.ProviderWrapper) error

func (Resource) GetIDKey

func (r Resource) GetIDKey() string

func (*Resource) ParseTFstate

func (r *Resource) ParseTFstate(parser Flatmapper, impliedType cty.Type) error

func (*Resource) Refresh

func (r *Resource) Refresh(provider *providerwrapper.ProviderWrapper)

func (*Resource) ServiceName

func (r *Resource) ServiceName() string

type ResourceFilter

type ResourceFilter struct {
	ApplicableFilter
	ServiceName      string
	FieldPath        string
	AcceptableValues []string
}

func (*ResourceFilter) Filter

func (rf *ResourceFilter) Filter(resource Resource) bool

func (*ResourceFilter) IsApplicable

func (rf *ResourceFilter) IsApplicable(serviceName string) bool

type Service

type Service struct {
	Name         string
	Resources    []Resource
	ProviderName string
	Args         map[string]interface{}
	Filter       []ResourceFilter
	Verbose      bool
}

func (*Service) GetArgs

func (s *Service) GetArgs() map[string]interface{}

func (*Service) GetName

func (s *Service) GetName() string

func (*Service) GetProviderName

func (s *Service) GetProviderName() string

func (*Service) GetResources

func (s *Service) GetResources() []Resource

func (*Service) InitResources

func (s *Service) InitResources() error

func (*Service) InitialCleanup

func (s *Service) InitialCleanup()

func (*Service) ParseFilter

func (s *Service) ParseFilter(rawFilter string) []ResourceFilter

func (*Service) ParseFilters

func (s *Service) ParseFilters(rawFilters []string)

func (*Service) PopulateIgnoreKeys

func (s *Service) PopulateIgnoreKeys(providerWrapper *providerwrapper.ProviderWrapper)

func (*Service) PostConvertHook

func (s *Service) PostConvertHook() error

func (*Service) PostRefreshCleanup

func (s *Service) PostRefreshCleanup()

func (*Service) SetArgs

func (s *Service) SetArgs(args map[string]interface{})

func (*Service) SetName

func (s *Service) SetName(name string)

func (*Service) SetProviderName

func (s *Service) SetProviderName(providerName string)

func (*Service) SetResources

func (s *Service) SetResources(resources []Resource)

func (*Service) SetVerbose

func (s *Service) SetVerbose(verbose bool)

type ServiceGenerator

type ServiceGenerator interface {
	InitResources() error
	GetResources() []Resource
	SetResources(resources []Resource)
	ParseFilter(rawFilter string) []ResourceFilter
	ParseFilters(rawFilters []string)
	PostConvertHook() error
	GetArgs() map[string]interface{}
	SetArgs(args map[string]interface{})
	SetName(name string)
	SetVerbose(bool)
	SetProviderName(name string)
	GetProviderName() string
	GetName() string
	InitialCleanup()
	PopulateIgnoreKeys(*providerwrapper.ProviderWrapper)
	PostRefreshCleanup()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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