Documentation ¶
Overview ¶
Package gen is the core of terragen, where the template generation happens.
Index ¶
- type Config
- type DataSource
- type Git
- type Input
- func (i *Input) CreateOrUpdateMetadata() error
- func (i *Input) Generate(providerName string) error
- func (i *Input) GenerateDataSource(dataSources []string) error
- func (i *Input) GenerateResource(resources []string) error
- func (i *Input) MetadataScaffolded() bool
- func (i *Input) SetLogger(logger *logrus.Logger)
- type Main
- type Make
- type Metadata
- type Provider
- type Resource
- type Scaffold
- type SupportingComponents
- type TerraTemplate
- type Terragen
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.6.0
type Config struct { // Version of terragen used for generating scaffolds. Updates only when higher version of terragen used. Version string `json:"version" yaml:"version"` // RepoGroup to which the project is part of. RepoGroup string `json:"repo-group" yaml:"repo-group"` // ProjectModule represents the module of the project ProjectModule string `json:"project-module" yaml:"project-module"` // Provider name that was scaffolded. Provider string `json:"provider" yaml:"provider"` // ProviderPath where scaffolds were created. ProviderPath string `json:"provider-path" yaml:"provider-path"` // Resources that where scaffolded. Resources []string `json:"resources" yaml:"resources"` // DataSources that where scaffolded. DataSources []string `json:"data-sources" yaml:"data-sources"` // Importers that where scaffolded. Importers []string `json:"importers" yaml:"importers"` }
Config would be generated and stored by the utility for further references.
type DataSource ¶ added in v0.6.0
type DataSource struct { Path string DryRun bool Force bool SkipProviderUpdate bool AutoGenMessage string Provider string DataTemp string Name []string // contains filtered or unexported fields }
func NewDataSource ¶ added in v0.6.0
func NewDataSource(i *Input) *DataSource
func (*DataSource) Create ¶ added in v0.6.0
func (d *DataSource) Create() error
func (*DataSource) Get ¶ added in v0.7.0
func (d *DataSource) Get(currentContent []byte) ([]byte, error)
func (*DataSource) GetUpdated ¶ added in v0.7.0
func (d *DataSource) GetUpdated() error
func (*DataSource) Scaffolded ¶ added in v0.6.0
func (d *DataSource) Scaffolded() bool
func (*DataSource) Update ¶ added in v0.7.0
func (d *DataSource) Update() error
type Git ¶ added in v0.6.0
type Git struct { DryRun bool Provider string Path string GitIgnore string // contains filtered or unexported fields }
func (*Git) GetUpdated ¶ added in v0.7.0
func (*Git) Scaffolded ¶ added in v0.6.0
type Input ¶
type Input struct { // DryRun simulates scaffold creation by not creating one DryRun bool // Force will forcefully scaffold the datasource/resource by not validating the terragen version. // Enabling this might tamper the scaffolds. Force bool // SkipValidation will skip validating all the prerequisites such as checking go,goimports etc. SkipValidation bool // TerraformPluginFramework would generate scaffolds // with terraform-plugin-framework(https://github.com/hashicorp/terraform-plugin-framework). TerraformPluginFramework bool // ResourceRequired determines if resource to be created while generating scaffolds. // Enabling this wth no resource name is not accepted. ResourceRequired bool // DatasourceRequired determines if data_source to be created while generating scaffolds. // Enabling this wth no data_source name is not accepted. DatasourceRequired bool // SkipProviderUpdate when set, would skip updating the provider after generating the `data-sources` or `resources`. // When it is enabled, updating the provider with newer `data-sources` or `resources` has to be done manually. SkipProviderUpdate bool // ImporterRequired determines if importer to be created while generating scaffolds. // Enabling this wth no importer name is not accepted. ImporterRequired bool // Provider name of which the scaffolds to be created, defaults to terraform-provider-demo Provider string // Path defines where the templates has to be generated. Path string // AutoGenMessage will be configured by terragen and cannot be overwritten. AutoGenMessage string // Description to be added to resource/datasource. Description string // RepoGroup is used while creating go mod. Defaults to 'github.com/test/' // For a given provider, repo group would be appended. // Ex: For provider 'demo' the go mod would look like 'github.com/test/demo' // Resource to be created while generating scaffolds, // by passing a resource name here, it auto enabled ResourceRequired. // Provider name would be appended while constructing final resource name. // EX: resource 'create_cluster' for provider demo would become 'demo_create_cluster'. Resource []string // DataSource to be created while generating scaffolds, // by passing a resource name here, it auto enabled DatasourceRequired. // Provider name would be appended while constructing final data_source name. // EX: resource 'load_image' for provider demo would become 'demo_load_image'. DataSource []string // List of all the dependent packages for terraform, if not passed it picks default. Dependents []string // TemplateRaw consists of go-templates which are the core for terragen. TemplateRaw TerraTemplate // RepoGroup to which the Terraform provider is to be part. This would be used as base name to set `go.mod` // ex: github.com/nikshilsbhat RepoGroup string // contains filtered or unexported fields }
Input holds the required values to generate the templates.
func (*Input) CreateOrUpdateMetadata ¶
func (*Input) GenerateDataSource ¶ added in v0.6.0
func (*Input) GenerateResource ¶ added in v0.6.0
func (*Input) MetadataScaffolded ¶ added in v0.6.0
type Main ¶ added in v0.6.0
type Main struct { DryRun bool Path string RootTemp string Provider string AutoGenMessage string Dependents []string // contains filtered or unexported fields }
func (*Main) GetUpdated ¶ added in v0.7.0
func (*Main) Scaffolded ¶ added in v0.6.0
type Make ¶ added in v0.6.0
type Make struct { DryRun bool Path string Provider string // contains filtered or unexported fields }
func (*Make) GetUpdated ¶ added in v0.7.0
func (*Make) Scaffolded ¶ added in v0.7.0
type Provider ¶ added in v0.6.0
type Provider struct { Provider string DryRun bool Path string Mod string ProviderTemp string MetaDataPath string AutoGenMessage string Resource []string DataSource []string Importer []string // contains filtered or unexported fields }
func NewProvider ¶ added in v0.6.0
func (*Provider) GetUpdated ¶ added in v0.6.0
func (*Provider) Scaffolded ¶ added in v0.6.0
type Resource ¶ added in v0.6.0
type Resource struct { Path string DryRun bool Force bool SkipProviderUpdate bool Importer bool AutoGenMessage string Provider string ResourceTemp string Name []string // contains filtered or unexported fields }
func NewResource ¶ added in v0.6.0
func (*Resource) GetUpdated ¶ added in v0.7.0
func (*Resource) Scaffolded ¶ added in v0.6.0
type Scaffold ¶ added in v0.6.0
Scaffold implement method that generates the scaffolds for the Terraform provider.
type SupportingComponents ¶ added in v0.7.0
type SupportingComponents struct { DryRun bool Provider string Path string GolangCILint string GoReleaser string RegistryManifest string // contains filtered or unexported fields }
func NewReleaseNLinter ¶ added in v0.7.0
func NewReleaseNLinter(i *Input) *SupportingComponents
func (*SupportingComponents) Create ¶ added in v0.7.0
func (r *SupportingComponents) Create() error
func (*SupportingComponents) Get ¶ added in v0.7.0
func (r *SupportingComponents) Get(currentContent []byte) ([]byte, error)
func (*SupportingComponents) GetUpdated ¶ added in v0.7.0
func (r *SupportingComponents) GetUpdated() error
func (*SupportingComponents) Scaffolded ¶ added in v0.7.0
func (r *SupportingComponents) Scaffolded() bool
func (*SupportingComponents) Update ¶ added in v0.7.0
func (r *SupportingComponents) Update() error
type TerraTemplate ¶
type TerraTemplate struct { // ProviderTemp holds the template for provider ProviderTemp string `json:"provider-template,omitempty" yaml:"provider-template,omitempty"` // RootTemp holds the template for root file RootTemp string `json:"root-template,omitempty" yaml:"provider-template,omitempty"` // DataTemp holds the template for data DataTemp string `json:"data-template,omitempty" yaml:"data-template,omitempty"` // ResourceTemp holds the template for resource ResourceTemp string `json:"resource-template,omitempty" yaml:"resource-template,omitempty"` // GitIgnore that where scaffolded. GitIgnore string `json:"gitignore,omitempty" yaml:"gitignore,omitempty"` // GolangCILint that where scaffolded. GolangCILint string `json:"golang-ci-lint,omitempty" yaml:"golang-ci-lint,omitempty"` // GoReleaser that where scaffolded. GoReleaser string `json:"go-releaser,omitempty" yaml:"go-releaser,omitempty"` // RegistryManifest is a terraform registry manifest that is to be scaffolded. RegistryManifest string `json:"registry-manifest,omitempty" yaml:"registry-manifest,omitempty"` }
TerraTemplate are the collections of go-templates which are used to generate terraform provider's base template.
Click to show internal directories.
Click to hide internal directories.