types

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 22 Imported by: 1 module, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// PackagePathXPCommonAPIs is the go path for the Crossplane core APIs
	// package with common APIs (relocated from crossplane-runtime in v2.3.0).
	PackagePathXPCommonAPIs = "github.com/crossplane/crossplane/apis/v2/core/v2"
	// PackagePathXPV2CommonAPIs is the go path for the Crossplane core APIs
	// package with common v2 APIs (consolidated into the same package in v2.3.0).
	PackagePathXPV2CommonAPIs = "github.com/crossplane/crossplane/apis/v2/core/v2"
)
View Source
const (
	// PackagePathK8sApiExtensions is the go package path for the
	// K8s apiextensions/v1 package
	PackagePathK8sApiExtensions = "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
)

Variables

This section is empty.

Functions

func AddServerSideApplyMarkers

func AddServerSideApplyMarkers(f *Field)

AddServerSideApplyMarkers adds server-side apply comment markers to indicate that scalar maps and sets can be merged granularly, not replace atomically.

func AddServerSideApplyMarkersFromConfig

func AddServerSideApplyMarkersFromConfig(f *Field, cfg *config.Resource) error

func IsObservation

func IsObservation(s *schema.Schema) bool

IsObservation returns whether the specified Schema belongs to an observed attribute, i.e., whether it's a required computed field.

func NewStringOrBoolType added in v2.5.0

func NewStringOrBoolType() types.Type

NewStringOrBoolType returns a types.Type representing the StringOrBool type. The returned type is a pointer type.

func TypePath

func TypePath(i any) string

TypePath returns go package path for the input type. This is a helper function to be used whenever this information is needed, like configuring to reference to a type. Should not be used if the type is in the same package as the caller.

Types

type Builder

type Builder struct {
	Package *types.Package
	// contains filtered or unexported fields
}

Builder is used to generate Go type equivalence of given Terraform schema.

func NewBuilder

func NewBuilder(pkg *types.Package, scope CRDScope) *Builder

NewBuilder returns a new Builder.

func (*Builder) AddToBuilder

func (g *Builder) AddToBuilder(typeNames *TypeNames, r *resource) (*types.Named, *types.Named, *types.Named)

AddToBuilder adds fields to the Builder.

func (*Builder) Build

func (g *Builder) Build(cfg *config.Resource) (Generated, error)

Build returns parameters and observation types built out of Terraform schema.

type CRDScope

type CRDScope string
const (
	CRDScopeNamespaced CRDScope = "Namespaced"
	CRDScopeCluster    CRDScope = "Cluster"
)

type Field

type Field struct {
	Schema                                   *schema.Schema
	Name                                     name.Name
	Comment                                  *comments.Comment
	TFTag                                    *structtag.Value
	JSONTag                                  *structtag.Value
	FieldNameCamel                           string
	TerraformPaths, CRDPaths, CanonicalPaths []string
	FieldType                                types.Type
	InitType                                 types.Type
	AsBlocksMode                             bool
	Reference                                *config.Reference
	TransformedName                          string
	SelectorName                             string
	Identifier                               bool
	Required                                 bool
	// Injected is set if this Field is an injected field to the Terraform
	// schema as an object list map key for server-side apply merges.
	Injected bool
	// Sensitive is set if this Field holds sensitive data and is thus
	// generated as a secret reference.
	Sensitive bool
}

Field represents a field that is built from the Terraform schema. It contains the go field related information such as tags, field type, comment.

func NewField

func NewField(g *Builder, cfg *config.Resource, r *resource, sch *schema.Schema, snakeFieldName string, tfPath, xpPath, names []string, asBlocksMode bool) (*Field, error)

NewField returns a constructed Field object.

func NewReferenceField

func NewReferenceField(g *Builder, cfg *config.Resource, r *resource, sch *schema.Schema, ref *config.Reference, snakeFieldName string, tfPath, xpPath, names []string, asBlocksMode bool) (*Field, error)

NewReferenceField returns a constructed reference Field object.

func NewSensitiveField

func NewSensitiveField(g *Builder, cfg *config.Resource, r *resource, sch *schema.Schema, snakeFieldName string, tfPath, xpPath, names []string, asBlocksMode bool) (*Field, bool, error)

NewSensitiveField returns a constructed sensitive Field object.

func (*Field) AddToResource

func (f *Field) AddToResource(g *Builder, r *resource, typeNames *TypeNames, opt config.SchemaElementOption)

AddToResource adds built field to the resource.

type Generated

type Generated struct {
	Types    []*types.Named
	Comments twtypes.Comments

	ForProviderType  *types.Named
	InitProviderType *types.Named
	AtProviderType   *types.Named

	ValidationRules string
}

Generated is a struct that holds generated types

type StringOrBool added in v2.5.0

type StringOrBool string

StringOrBool is stored canonically as a string, but can also decode from bools.

func (*StringOrBool) MarshalJSON added in v2.5.0

func (b *StringOrBool) MarshalJSON() ([]byte, error)

func (*StringOrBool) UnmarshalJSON added in v2.5.0

func (b *StringOrBool) UnmarshalJSON(data []byte) error

type TypeNames

type TypeNames struct {
	ParameterTypeName   *types.TypeName
	InitTypeName        *types.TypeName
	ObservationTypeName *types.TypeName
}

TypeNames represents the parameter and observation name of the resource.

func NewTypeNames

func NewTypeNames(fieldPaths []string, pkg *types.Package, overrideFieldNames map[string]string) (*TypeNames, error)

NewTypeNames returns a new TypeNames object.

Directories

Path Synopsis
conversion

Jump to

Keyboard shortcuts

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