gen

package
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package gen is the core of terragen, where the template generation happens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	// 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
	// ResourceRequired determines if resource to be created while generating scaffolds.
	// Enabling this wth no resource name is not accepted.
	ResourceRequired bool
	// 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
	// DatasourceRequired determines if data_source to be created while generating scaffolds.
	// Enabling this wth no data_source name is not accepted.
	DatasourceRequired bool
	// Importer to be created while generating scaffolds,
	// by passing a resource name here, it auto enabled ImporterRequired.
	Importer string
	// 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
	// List of all the dependent packages for terraform, if not passed it picks default.
	Dependents []string
	// Path defines where the templates has to be generated.
	Path string
	// TemplateRaw consists of go-templates which are the core for terragen.
	TemplateRaw TerraTemplate
	// AutoGenMessage will be configured by terragen and cannot be overwritten.
	AutoGenMessage string
	// Description to be added to resource/datasource
	Description string
	// DryRun simulates scaffold creation by not creating one
	DryRun bool
	// 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 looks 'github.com/test/demo'
	RepoGroup string
	// contains filtered or unexported fields
}

Input holds the required values to generate the templates

func (*Input) CreateDataSource

func (i *Input) CreateDataSource(cmd *cobra.Command, args []string)

func (*Input) CreateImporter

func (i *Input) CreateImporter(cmd *cobra.Command, args []string)

func (*Input) CreateMain

func (i *Input) CreateMain() error

func (*Input) CreateOrUpdateMetadata

func (i *Input) CreateOrUpdateMetadata() error

func (*Input) CreateProvider

func (i *Input) CreateProvider(cmd *cobra.Command, args []string)

CreateProvider scaffolds the provider and its components as per the requirements.

func (*Input) CreateResource

func (i *Input) CreateResource(cmd *cobra.Command, args []string)

type Metadata

type Metadata 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"`
}

Metadata would be generated and stored by the utility for further references.

type TerraTemplate

type TerraTemplate struct {
	// ProviderTemp holds the template for provider
	ProviderTemp string `json:"provider-template" yaml:"provider-template"`
	// RootTemp holds the template for root file
	RootTemp string `json:"root-template" yaml:"provider-template"`
	// DataTemp holds the template for data
	DataTemp string `json:"data-template" yaml:"data-template"`
	// ResourceTemp holds the template for resource
	ResourceTemp string `json:"resource-template" yaml:"resource-template"`
	// GitIgnore that where scaffolded.
	GitIgnore string `json:"gitignore" yaml:"gitignore"`
}

TerraTemplate are the collections of go-templates which are used to generate terraform provider's base template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL