meta

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MPL-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceMappingFileName = "aztfexportResourceMapping.json"
View Source
const SkippedResourcesFileName = "aztfexportSkippedResources.txt"

Variables

This section is empty.

Functions

func FindTerraform

func FindTerraform(ctx context.Context) (string, error)

FindTerraform finds the path to the terraform executable.

func NewBaseMeta

func NewBaseMeta(cfg config.CommonConfig) (*baseMeta, error)

Types

type BaseMeta

type BaseMeta interface {
	// Logger returns a slog.Logger
	Logger() *slog.Logger
	// ProviderName returns the target provider name, which is either azurerm or azapi.
	ProviderName() string
	// Init initializes the base meta, including initialize terraform, provider and soem runtime temporary resources.
	Init(ctx context.Context) error
	// DeInit deinitializes the base meta, including cleaning up runtime temporary resources.
	DeInit(ctx context.Context) error
	// Workspace returns the path of the output directory.
	Workspace() string
	// ParallelImport imports the specified import list in parallel (parallelism is set during the meta builder function).
	// Import error won't be returned in the error, but is recorded in each ImportItem.
	ParallelImport(ctx context.Context, items []*ImportItem) error
	// PushState pushes the terraform state file (the base state of the workspace, adding the newly imported resources) back to the workspace.
	PushState(ctx context.Context) error
	// CleanTFState clean up the specified TF resource from the workspace's state file.
	CleanTFState(ctx context.Context, addr string)
	// GenerateCfg generates the TF configuration of the import list. Only resources successfully imported will be processed.
	GenerateCfg(ctx context.Context, l ImportList) error
	// ExportSkippedResources writes a file listing record resources that are skipped to be imported to the output directory.
	ExportSkippedResources(ctx context.Context, l ImportList) error
	// ExportResourceMapping writes a resource mapping file to the output directory.
	ExportResourceMapping(ctx context.Context, l ImportList) error
	// CleanUpWorkspace is a weired method that is only meant to be used internally by aztfexport, which under the hood will remove everything in the output directory, except the generated TF config.
	// This method does nothing if HCLOnly in the Config is not set.
	CleanUpWorkspace(ctx context.Context) error

	SetPreImportHook(config.ImportCallback)
	SetPostImportHook(config.ImportCallback)
}

type ConfigInfo

type ConfigInfo struct {
	ImportItem
	DependsOn []Dependency
	// contains filtered or unexported fields
}

func (ConfigInfo) DumpHCL

func (cfg ConfigInfo) DumpHCL(w io.Writer) (int, error)

type ConfigInfos

type ConfigInfos []ConfigInfo

func (ConfigInfos) AddDependency

func (cfgs ConfigInfos) AddDependency() error

type Dependency

type Dependency struct {
	Candidates []string
}

type ImportItem

type ImportItem struct {
	// Azure resource Id
	AzureResourceID armid.ResourceId

	// The TF resource id
	TFResourceId string

	// Whether this azure resource failed to import into terraform (this might due to the TFResourceType doesn't match the resource)
	ImportError error

	// Whether this azure resource has been successfully imported
	Imported bool

	// Whether this azure resource failed to validate into terraform (tbh, this should reside in UI layer only)
	ValidateError error

	// The terraform resource
	TFAddr tfaddr.TFAddr

	// The cached terraform resource addr (this is only used by the interactive mode when reverting skipping this import item)
	TFAddrCache tfaddr.TFAddr

	// Whether this TF resource type is from recommendation
	IsRecommended bool

	Recommendations []string

	// State is what is being imported&read by terraform-plugin-go client. It is nil when importing via terraform binary.
	State cty.Value
}

func (ImportItem) Skip

func (item ImportItem) Skip() bool

type ImportList

type ImportList []ImportItem

func (ImportList) ImportErrored

func (l ImportList) ImportErrored() ImportList

func (ImportList) Imported

func (l ImportList) Imported() ImportList

func (ImportList) NonSkipped

func (l ImportList) NonSkipped() ImportList

func (ImportList) Skipped

func (l ImportList) Skipped() ImportList

type MetaGroupDummy

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

func NewGroupMetaDummy

func NewGroupMetaDummy(rg string, providerName string) *MetaGroupDummy

func (MetaGroupDummy) CleanTFState

func (m MetaGroupDummy) CleanTFState(_ context.Context, _ string)

func (MetaGroupDummy) CleanUpWorkspace

func (m MetaGroupDummy) CleanUpWorkspace(_ context.Context) error

func (MetaGroupDummy) DeInit

func (m MetaGroupDummy) DeInit(_ context.Context) error

func (MetaGroupDummy) ExportResourceMapping

func (m MetaGroupDummy) ExportResourceMapping(_ context.Context, l ImportList) error

func (MetaGroupDummy) ExportSkippedResources

func (m MetaGroupDummy) ExportSkippedResources(_ context.Context, l ImportList) error

func (MetaGroupDummy) GenerateCfg

func (m MetaGroupDummy) GenerateCfg(_ context.Context, l ImportList) error

func (MetaGroupDummy) Init

func (m MetaGroupDummy) Init(_ context.Context) error

func (MetaGroupDummy) ListResource

func (m MetaGroupDummy) ListResource(_ context.Context) (ImportList, error)

func (MetaGroupDummy) Logger added in v0.15.0

func (m MetaGroupDummy) Logger() *slog.Logger

func (MetaGroupDummy) ParallelImport

func (m MetaGroupDummy) ParallelImport(_ context.Context, items []*ImportItem) error

func (MetaGroupDummy) ProviderName added in v0.14.0

func (m MetaGroupDummy) ProviderName() string

func (MetaGroupDummy) PushState

func (m MetaGroupDummy) PushState(_ context.Context) error

func (MetaGroupDummy) ScopeName

func (m MetaGroupDummy) ScopeName() string

func (*MetaGroupDummy) SetPostImportHook added in v0.15.0

func (meta *MetaGroupDummy) SetPostImportHook(cb config.ImportCallback)

func (*MetaGroupDummy) SetPreImportHook added in v0.15.0

func (meta *MetaGroupDummy) SetPreImportHook(cb config.ImportCallback)

func (MetaGroupDummy) Workspace

func (m MetaGroupDummy) Workspace() string

type MetaMap

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

func NewMetaMap

func NewMetaMap(cfg config.Config) (*MetaMap, error)

func (*MetaMap) CleanTFState

func (meta *MetaMap) CleanTFState(ctx context.Context, addr string)

func (MetaMap) CleanUpWorkspace

func (meta MetaMap) CleanUpWorkspace(_ context.Context) error

func (MetaMap) DeInit

func (meta MetaMap) DeInit(ctx context.Context) error

func (MetaMap) ExportResourceMapping

func (meta MetaMap) ExportResourceMapping(ctx context.Context, l ImportList) error

func (MetaMap) ExportSkippedResources

func (meta MetaMap) ExportSkippedResources(_ context.Context, l ImportList) error

func (MetaMap) GenerateCfg

func (meta MetaMap) GenerateCfg(ctx context.Context, l ImportList) error

func (*MetaMap) Init

func (meta *MetaMap) Init(ctx context.Context) error

func (*MetaMap) ListResource

func (meta *MetaMap) ListResource(_ context.Context) (ImportList, error)

func (MetaMap) Logger added in v0.15.0

func (meta MetaMap) Logger() *slog.Logger

func (*MetaMap) ParallelImport

func (meta *MetaMap) ParallelImport(ctx context.Context, items []*ImportItem) error

func (MetaMap) ProviderName added in v0.14.0

func (meta MetaMap) ProviderName() string

func (MetaMap) PushState

func (meta MetaMap) PushState(ctx context.Context) error

func (MetaMap) ScopeName

func (meta MetaMap) ScopeName() string

func (*MetaMap) SetPostImportHook added in v0.15.0

func (meta *MetaMap) SetPostImportHook(cb config.ImportCallback)

func (*MetaMap) SetPreImportHook added in v0.15.0

func (meta *MetaMap) SetPreImportHook(cb config.ImportCallback)

func (MetaMap) Workspace

func (meta MetaMap) Workspace() string

type MetaQuery

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

func NewMetaQuery

func NewMetaQuery(cfg config.Config) (*MetaQuery, error)

func (*MetaQuery) CleanTFState

func (meta *MetaQuery) CleanTFState(ctx context.Context, addr string)

func (MetaQuery) CleanUpWorkspace

func (meta MetaQuery) CleanUpWorkspace(_ context.Context) error

func (MetaQuery) DeInit

func (meta MetaQuery) DeInit(ctx context.Context) error

func (MetaQuery) ExportResourceMapping

func (meta MetaQuery) ExportResourceMapping(ctx context.Context, l ImportList) error

func (MetaQuery) ExportSkippedResources

func (meta MetaQuery) ExportSkippedResources(_ context.Context, l ImportList) error

func (MetaQuery) GenerateCfg

func (meta MetaQuery) GenerateCfg(ctx context.Context, l ImportList) error

func (*MetaQuery) Init

func (meta *MetaQuery) Init(ctx context.Context) error

func (*MetaQuery) ListResource

func (meta *MetaQuery) ListResource(ctx context.Context) (ImportList, error)

func (MetaQuery) Logger added in v0.15.0

func (meta MetaQuery) Logger() *slog.Logger

func (*MetaQuery) ParallelImport

func (meta *MetaQuery) ParallelImport(ctx context.Context, items []*ImportItem) error

func (MetaQuery) ProviderName added in v0.14.0

func (meta MetaQuery) ProviderName() string

func (MetaQuery) PushState

func (meta MetaQuery) PushState(ctx context.Context) error

func (MetaQuery) ScopeName

func (meta MetaQuery) ScopeName() string

func (*MetaQuery) SetPostImportHook added in v0.15.0

func (meta *MetaQuery) SetPostImportHook(cb config.ImportCallback)

func (*MetaQuery) SetPreImportHook added in v0.15.0

func (meta *MetaQuery) SetPreImportHook(cb config.ImportCallback)

func (MetaQuery) Workspace

func (meta MetaQuery) Workspace() string

type MetaResource

type MetaResource struct {
	AzureIds     []armid.ResourceId
	ResourceName string
	ResourceType string
	// contains filtered or unexported fields
}

func NewMetaResource

func NewMetaResource(cfg config.Config) (*MetaResource, error)

func (*MetaResource) CleanTFState

func (meta *MetaResource) CleanTFState(ctx context.Context, addr string)

func (MetaResource) CleanUpWorkspace

func (meta MetaResource) CleanUpWorkspace(_ context.Context) error

func (MetaResource) DeInit

func (meta MetaResource) DeInit(ctx context.Context) error

func (MetaResource) ExportResourceMapping

func (meta MetaResource) ExportResourceMapping(ctx context.Context, l ImportList) error

func (MetaResource) ExportSkippedResources

func (meta MetaResource) ExportSkippedResources(_ context.Context, l ImportList) error

func (MetaResource) GenerateCfg

func (meta MetaResource) GenerateCfg(ctx context.Context, l ImportList) error

func (*MetaResource) Init

func (meta *MetaResource) Init(ctx context.Context) error

func (*MetaResource) ListResource

func (meta *MetaResource) ListResource(ctx context.Context) (ImportList, error)

func (MetaResource) Logger added in v0.15.0

func (meta MetaResource) Logger() *slog.Logger

func (*MetaResource) ParallelImport

func (meta *MetaResource) ParallelImport(ctx context.Context, items []*ImportItem) error

func (MetaResource) ProviderName added in v0.14.0

func (meta MetaResource) ProviderName() string

func (MetaResource) PushState

func (meta MetaResource) PushState(ctx context.Context) error

func (MetaResource) ScopeName

func (meta MetaResource) ScopeName() string

func (*MetaResource) SetPostImportHook added in v0.15.0

func (meta *MetaResource) SetPostImportHook(cb config.ImportCallback)

func (*MetaResource) SetPreImportHook added in v0.15.0

func (meta *MetaResource) SetPreImportHook(cb config.ImportCallback)

func (MetaResource) Workspace

func (meta MetaResource) Workspace() string

type MetaResourceGroup

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

func NewMetaResourceGroup

func NewMetaResourceGroup(cfg config.Config) (*MetaResourceGroup, error)

func (*MetaResourceGroup) CleanTFState

func (meta *MetaResourceGroup) CleanTFState(ctx context.Context, addr string)

func (MetaResourceGroup) CleanUpWorkspace

func (meta MetaResourceGroup) CleanUpWorkspace(_ context.Context) error

func (MetaResourceGroup) DeInit

func (meta MetaResourceGroup) DeInit(ctx context.Context) error

func (MetaResourceGroup) ExportResourceMapping

func (meta MetaResourceGroup) ExportResourceMapping(ctx context.Context, l ImportList) error

func (MetaResourceGroup) ExportSkippedResources

func (meta MetaResourceGroup) ExportSkippedResources(_ context.Context, l ImportList) error

func (MetaResourceGroup) GenerateCfg

func (meta MetaResourceGroup) GenerateCfg(ctx context.Context, l ImportList) error

func (*MetaResourceGroup) Init

func (meta *MetaResourceGroup) Init(ctx context.Context) error

func (*MetaResourceGroup) ListResource

func (meta *MetaResourceGroup) ListResource(ctx context.Context) (ImportList, error)

func (MetaResourceGroup) Logger added in v0.15.0

func (meta MetaResourceGroup) Logger() *slog.Logger

func (*MetaResourceGroup) ParallelImport

func (meta *MetaResourceGroup) ParallelImport(ctx context.Context, items []*ImportItem) error

func (MetaResourceGroup) ProviderName added in v0.14.0

func (meta MetaResourceGroup) ProviderName() string

func (MetaResourceGroup) PushState

func (meta MetaResourceGroup) PushState(ctx context.Context) error

func (MetaResourceGroup) ScopeName

func (meta MetaResourceGroup) ScopeName() string

func (*MetaResourceGroup) SetPostImportHook added in v0.15.0

func (meta *MetaResourceGroup) SetPostImportHook(cb config.ImportCallback)

func (*MetaResourceGroup) SetPreImportHook added in v0.15.0

func (meta *MetaResourceGroup) SetPreImportHook(cb config.ImportCallback)

func (MetaResourceGroup) Workspace

func (meta MetaResourceGroup) Workspace() string

type TFConfigTransformer

type TFConfigTransformer func(configs ConfigInfos) (ConfigInfos, error)

Jump to

Keyboard shortcuts

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