registry

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// RandRFC1123Subdomain represents a template variable to be substituted
	// by the test runner at runtime with a random RFC1123 subdomain string.
	RandRFC1123Subdomain = "${Rand.RFC1123Subdomain}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependencies

type Dependencies map[string]string

Dependencies are the example manifests for the dependency resources. Key is formatted as <Terraform resource>.<example name>

func (Dependencies) SetPathValue

func (d Dependencies) SetPathValue(dependencyKey string, fieldPath string, val any) error

SetPathValue sets the field at the specified path to the given value in the example manifest of the specified dependency. Key format is: <Terraform resource type>.<configuration block name>, e.g., aws_subnet.subnet1

type ProviderMetadata

type ProviderMetadata struct {
	Name      string               `yaml:"name"`
	Resources map[string]*Resource `yaml:"resources"`
}

ProviderMetadata metadata for a Terraform native provider

func NewProviderMetadata

func NewProviderMetadata(name string) *ProviderMetadata

NewProviderMetadata initializes a new ProviderMetadata for extracting metadata from the Terraform registry.

func NewProviderMetadataFromFile

func NewProviderMetadataFromFile(providerMetadata []byte) (*ProviderMetadata, error)

NewProviderMetadataFromFile loads metadata from the specified YAML-formatted document

func (*ProviderMetadata) ScrapeRepo

func (pm *ProviderMetadata) ScrapeRepo(config *ScrapeConfiguration) error

ScrapeRepo scrape metadata from the configured Terraform native provider repo

func (*ProviderMetadata) Store

func (pm *ProviderMetadata) Store(path string) error

Store stores this scraped ProviderMetadata at the specified path

type Resource

type Resource struct {
	// SubCategory is the category name under which this Resource resides in
	// Terraform registry docs. Example:"Key Vault" for Azure Vault resources.
	// In Terraform docs, resources are grouped (categorized) using this field.
	SubCategory string `yaml:"subCategory"`
	// Description is a short description for the resource as it appears in
	// Terraform registry. Example: "Manages a Key Vault Key." for the
	// azurerm_key_vault_key resource.
	// This field is suitable for use in generating CRD Kind documentation.
	Description string `yaml:"description,omitempty"`
	// Name is the Terraform name of the resource. Example: azurerm_key_vault_key
	Name string `yaml:"name"`
	// Title is the title name of the resource that appears in
	// the Terraform registry doc page for a Terraform resource.
	Title string `yaml:"title"`
	// Examples are the example HCL configuration blocks for the resource
	// that appear in the resource's registry page. They are in the same
	// order as they appear on the registry page.
	Examples []ResourceExample `yaml:"examples,omitempty"`
	// ArgumentDocs maps resource attributes to their documentation in the
	// resource's registry page.
	ArgumentDocs map[string]string `yaml:"argumentDocs"`
	// ImportStatements are the example Terraform import statements as they
	// appear in the resource's registry page.
	// Example: terraform import azurerm_key_vault.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.KeyVault/vaults/vault1
	ImportStatements []string `yaml:"importStatements"`
	// ExternalName configured for this resource. This allows the
	// external name used in the generated example manifests to be
	// overridden for a specific resource via configuration.
	ExternalName string `yaml:"-"`
}

Resource represents the scraped metadata for a Terraform resource

type ResourceExample

type ResourceExample struct {
	Name         string            `yaml:"name"`
	Manifest     string            `yaml:"manifest"`
	References   map[string]string `yaml:"references,omitempty"`
	Dependencies Dependencies      `yaml:"dependencies,omitempty"`
	Paved        fieldpath.Paved   `yaml:"-"`
}

ResourceExample represents the scraped example HCL configuration for a Terraform resource

func (*ResourceExample) SetPathValue

func (re *ResourceExample) SetPathValue(fieldPath string, val any) error

SetPathValue sets the field at the specified path to the given value in the example manifest.

type ScrapeConfiguration

type ScrapeConfiguration struct {
	// Debug Output debug messages
	Debug bool
	// RepoPath is the path of the Terraform native provider repo
	RepoPath string
	// CodeXPath Code XPath expression
	CodeXPath string
	// PreludeXPath Prelude XPath expression
	PreludeXPath string
	// FieldDocXPath Field documentation XPath expression
	FieldDocXPath string
	// ImportXPath Import statements XPath expression
	ImportXPath string
	// FileExtensions extensions of the files to be scraped
	FileExtensions []string
	// ResourcePrefix Terraform resource name prefix for the Terraform provider
	ResourcePrefix string
}

ScrapeConfiguration is a configurator for the scraper

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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