introspect

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package introspect has shared utilities for reflecting.

Introspection is one level up from reflection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProperties added in v0.4.0

func FindProperties(typ reflect.Type) (map[string]FieldTag, error)

func GetToken

func GetToken(pkg tokens.Package, typ reflect.Type) (tokens.Type, error)

GetToken calculates the Pulumi token that typ would be projected into.

func StructToMap

func StructToMap(i any) map[string]interface{}

Types

type Annotator added in v0.4.0

type Annotator struct {
	Descriptions        map[string]string
	Defaults            map[string]any
	DefaultEnvs         map[string][]string
	Token               string
	Aliases             []string
	DeprecationMessages map[string]string
	// contains filtered or unexported fields
}

Annotator implements the Annotator interface as defined in resource/resource.go.

func NewAnnotator added in v0.4.0

func NewAnnotator(resource any) Annotator

func (*Annotator) AddAlias added in v0.20.0

func (a *Annotator) AddAlias(module tokens.ModuleName, token tokens.TypeName)

func (*Annotator) Deprecate added in v1.0.0

func (a *Annotator) Deprecate(i any, message string)

func (*Annotator) Describe added in v0.4.0

func (a *Annotator) Describe(i any, description string)

func (*Annotator) SetDefault added in v0.4.0

func (a *Annotator) SetDefault(i any, defaultValue any, env ...string)

SetDefault annotates a struct field with a default value. The default value must be a primitive type in the pulumi type system.

func (*Annotator) SetToken added in v0.13.0

func (a *Annotator) SetToken(module tokens.ModuleName, token tokens.TypeName)

type ExplicitType added in v0.7.0

type ExplicitType struct {
	Pkg     string
	Version string
	Module  string
	Name    string
}

ExplicitType is an explicitly specified type ref token.

type FieldMatcher added in v0.4.0

type FieldMatcher struct {
	// contains filtered or unexported fields
}

func NewFieldMatcher added in v0.4.0

func NewFieldMatcher(i any) FieldMatcher

func (*FieldMatcher) GetField added in v0.4.0

func (f *FieldMatcher) GetField(field any) (FieldTag, bool, error)

func (*FieldMatcher) TargetStructFields added in v0.9.0

func (f *FieldMatcher) TargetStructFields(t any) ([]FieldTag, bool, error)

TargetStructFields returns the set of fields that `t` describes for a given matcher.

If `t` is the struct that the field matcher is based on, return all visible fields on the struct. Otherwise `nil, false, nil` is returned.

type FieldTag

type FieldTag struct {
	Name        string        // The name of the field in the Pulumi type system.
	Optional    bool          // If the field is optional in the Pulumi type system.
	Internal    bool          // If the field should exist in the Pulumi type system.
	Secret      bool          // If the field is secret.
	ExplicitRef *ExplicitType // The name and version of the external type consumed in the field.
	// NOTE: ReplaceOnChanges will only be obeyed when the default diff implementation is used.
	ReplaceOnChanges bool // If changes in the field should force a replacement.
}

func ParseTag

func ParseTag(field reflect.StructField) (FieldTag, error)

ParseTag gets tag information out of struct tags. It looks under the `pulumi` and `provider` tag namespaces.

type ToPropertiesOptions

type ToPropertiesOptions struct {
	ComputedKeys []string
}

Jump to

Keyboard shortcuts

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