metadata

package
v0.0.0-...-2b87275 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0, MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDefaultLineage

func IsDefaultLineage(lineage, apiLineage []string) bool

Returns true if the lineage is the default we'd expect for a field, and false otherwise. If any ancestor has a non-default lineage, this will return false.

Types

type Field

type Field struct {
	// The name of the field in the REST API, including the path. For example, "buildConfig.source.storageSource.bucket".
	ApiField string `yaml:"api_field,omitempty"`
	// The name of the field in Terraform, including the path. For example, "build_config.source.storage_source.bucket". Defaults to the value
	// of `api_field` converted to snake_case.
	Field string `yaml:"field,omitempty"`
	// If true, the field is only present in the provider. This primarily applies for virtual fields and url-only parameters. When set to true,
	// `field` should be set and `api_field` should be left empty. Default: `false`.
	ProviderOnly bool `yaml:"provider_only,omitempty"`
	// If true, this is a JSON field which "covers" all child API fields. As a special case, JSON fields which cover an entire resource can
	// have `api_field` set to `*`.
	Json bool `yaml:"json,omitempty"`
}

Field is a field in a metadata.yaml file.

func FromProperties

func FromProperties(props []*api.Type) []Field

type Metadata

type Metadata struct {
	// The name of the Terraform resource. For example, "google_cloudfunctions2_function".
	Resource string `yaml:"resource"`

	// The generation method used to create the Terraform resource. For example, "mmv1", "dcl", "handwritten".
	GenerationType string `yaml:"generation_type"`

	// The source file of this metadata. This will only be set for generated resources, and will be the yaml file that contains the resource definition.
	SourceFile string `yaml:"source_file"`

	// The base name of the API used for this resource. For example, "cloudfunctions.googleapis.com".
	ApiServiceName string `yaml:"api_service_name"`

	// The version of the API used for this resource. For example, "v2".
	ApiVersion string `yaml:"api_version"`

	// The API "resource type kind" used for this resource. For example, "Function".
	ApiResourceTypeKind string `yaml:"api_resource_type_kind"`

	// The custom CAI asset name format for this resource is typically specified (for example, //cloudsql.googleapis.com/projects/{{project}}/instances/{{name}}).
	// This will only have a value if it's different than the Terraform resource ID format.
	CaiAssetNameFormat string `yaml:"cai_asset_name_format,omitempty"`

	// The API URL patterns used by this resource that represent variants. For example, "folders/{folder}/feeds/{feed}". Each pattern must match the value defined
	// in the API exactly. The use of `api_variant_patterns` is only meaningful when the resource type has multiple parent types available.
	ApiVariantPatterns []string `yaml:"api_variant_patterns,omitempty"`

	// Whether the resource was autogenerated from OpenAPI specs.
	AutogenStatus bool `yaml:"autogen_status,omitempty"`

	// List of fields on the resource.
	Fields []Field `yaml:"fields"`
}

Metadata represents a metadata.yaml file for a single Terraform resource.

func FromResource

func FromResource(r api.Resource) Metadata

FromResource returns a Metadata object based on a Resource.

Jump to

Keyboard shortcuts

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