helpers

package
v0.0.0-...-ca22424 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Register   operation = "register"
	Unregister operation = "unregister"
)
View Source
const (
	TypeResource   resourceType = "resource"
	TypeDatasource resourceType = "datasource"
)

Variables

This section is empty.

Functions

func CallTerraform

func CallTerraform(opts ...string) ([]byte, error)

CallTerraform calls the locally installed terraform binary with the specified options returns the raw []byte output for the caller to process.

func GoFmt

func GoFmt(file string) error

GoFmt calls `gofmt -w` over the specified file (including path)

func PrefixedDescriptionString

func PrefixedDescriptionString(input string) string

func PrefixedLabelString

func PrefixedLabelString(input string) string

func ProviderName

func ProviderName() (providerName *string, err error)

func SchemaItemFormatter

func SchemaItemFormatter(input interface{}, name string) string

func SchemaItemFormatterAttributes

func SchemaItemFormatterAttributes(input interface{}, name string) string

func SchemaItemFormatterSpecial

func SchemaItemFormatterSpecial(input Schema, name string) string

func Terrafmt

func Terrafmt(path string) error

Terrafmt calls (if installed) katbyte/terrafmt to format Terraform configurations in the specified file

func TerraformResourceName

func TerraformResourceName(provider, resourceName string) string

func ToDelimTitle

func ToDelimTitle(input string) string

func ToString

func ToString(value interface{}) string

func UpdateRegistration

func UpdateRegistration(servicePackagePath string, resourceName string, resource resourceType, _ operation, isTyped bool) error

UpdateRegistration modifies the `registration.go` file to add (or remove?) items from the relevant blocks when a user adds (or removes?) a resource or datasource via `tfpdk resource` or `tfpdk datasource`

servicePackagePath = The path from the route of the provider to the service package to which the item is to be registered resourceName = the model name of a typed resource, or the snakeCase name of the item resource = string value for the item type, one of TypeResource or TypeDatasource op = one of Register or Unregister // TODO - removing is a future concern so not yet implemented isTyped = true if the resources uses the TypedSDK

Types

type Configuration

type Configuration struct {
	ProviderName          string      `hcl:"provider_name,optional"`
	ProviderCanonicalName string      `hcl:"provider_canonical_name,optional"`
	ServicePackagesPath   string      `hcl:"service_packages_path,optional"`
	SchemaAPIURL          string      `hcl:"schema_api_url,optional"`
	DocsPath              string      `hcl:"docs_path,optional"`
	DocsVersion           DocsVersion `hcl:"docs_version,optional"`
	ProviderGithubOrg     string      `hcl:"provider_github_org,optional"`
	ResourceDocsDirname   string      `hcl:"resource_docs_directory_name,optional"`
	DataSourceDocsDirname string      `hcl:"data_source_docs_directory_name,optional"`
	TypedSDK              bool        `hcl:"use_typed_sdk,optional"`
}

func LoadConfig

func LoadConfig() *Configuration

LoadConfig loads the configuration file if present to allow users to override various settings in the tool, such as path to services, docs and any SDK options.

type DocType

type DocType string
const DocTypeDataSource DocType = "data-source"
const DocTypeResource DocType = "resource"

type DocsVersion

type DocsVersion string
const (
	ConfigFileName                  = ".tfpdk.hcl"
	DocsVersionLegacy   DocsVersion = "legacy"
	DocsVersionRegistry DocsVersion = "registry"
)

type Resource

type Resource struct {
	Schema   map[string]Schema `json:"schema"`
	Timeouts *Timeouts         `json:"timeouts,omitempty"`
}

func GetSchema

func GetSchema(apiHost string, docType string, name string) (*Resource, error)

type Schema

type Schema struct {
	Type        string      `json:"type,omitempty"`
	ConfigMode  string      `json:"config_mode,omitempty"`
	Optional    bool        `json:"optional,omitempty"`
	Required    bool        `json:"required,omitempty"`
	Default     interface{} `json:"default,omitempty"`
	Description string      `json:"description,omitempty"`
	Computed    bool        `json:"computed,omitempty"`
	ForceNew    bool        `json:"force_new,omitempty"`
	Elem        interface{} `json:"elem,omitempty"`
	MaxItems    int         `json:"max_items,omitempty"`
	MinItems    int         `json:"min_items,omitempty"`
}

func FlattenMapToSchema

func FlattenMapToSchema(input map[string]interface{}) Schema

type Timeouts

type Timeouts struct {
	Create int `json:"create,omitempty"`
	Read   int `json:"read,omitempty"`
	Delete int `json:"delete,omitempty"`
	Update int `json:"update,omitempty"`
}

Jump to

Keyboard shortcuts

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