method

package
v0.0.0-...-628280f Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package method contains methods that may be generated for a Go type.

Index

Constants

View Source
const (
	ReferenceTypeMarker               = "crossplane:generate:reference:type"
	ReferenceExtractorMarker          = "crossplane:generate:reference:extractor"
	ReferenceReferenceFieldNameMarker = "crossplane:generate:reference:refFieldName"
	ReferenceSelectorFieldNameMarker  = "crossplane:generate:reference:selectorFieldName"
)

Comment markers used by ReferenceProcessor

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter func(o types.Object, methodName string) bool

A Filter is a function that determines whether a method should be written for the supplied object. It returns true if the method should be filtered.

func DefinedOutside

func DefinedOutside(fs *token.FileSet, filename string) Filter

DefinedOutside returns a MethodFilter that returns true if the supplied object has a method with the supplied name that is not defined in the supplied filename. The object's filename is determined using the supplied FileSet.

type New

type New func(f *jen.File, o types.Object)

New is a function that adds a method on the supplied object in the supplied file.

func NewGetCondition

func NewGetCondition(receiver, runtime string) New

NewGetCondition returns a NewMethod that writes a GetCondition method for the supplied Object to the supplied file.

func NewGetDeletionPolicy

func NewGetDeletionPolicy(receiver, runtime string) New

NewGetDeletionPolicy returns a NewMethod that writes a GetDeletionPolicy method for the supplied Object to the supplied file.

func NewGetManagementPolicies

func NewGetManagementPolicies(receiver, runtime string) New

NewGetManagementPolicies returns a NewMethod that writes a GetManagementPolicies method for the supplied Object to the supplied file.

func NewGetProviderConfigReference

func NewGetProviderConfigReference(receiver, runtime string) New

NewGetProviderConfigReference returns a NewMethod that writes a GetProviderConfigReference method for the supplied Object to the supplied file.

func NewGetPublishConnectionDetailsTo

func NewGetPublishConnectionDetailsTo(receiver, runtime string) New

NewGetPublishConnectionDetailsTo returns a NewMethod that writes a GetPublishConnectionDetailsTo method for the supplied Object to the supplied file.

func NewGetResourceReference

func NewGetResourceReference(receiver, core string) New

NewGetResourceReference returns a NewMethod that writes a GetResourceReference method for the supplied Object to the supplied file.

func NewGetRootProviderConfigReference

func NewGetRootProviderConfigReference(receiver, runtime string) New

NewGetRootProviderConfigReference returns a NewMethod that writes a GetProviderConfigReference method for the supplied Object to the supplied file. file. Note that unlike NewGetProviderConfigReference the generated method expects the ProviderConfigReference to be at the root of the struct, not under its Spec field.

func NewGetRootResourceReference

func NewGetRootResourceReference(receiver, runtime string) New

NewGetRootResourceReference returns a NewMethod that writes a GetRootResourceReference method for the supplied Object to the supplied file.

func NewGetUsers

func NewGetUsers(receiver string) New

NewGetUsers returns a NewMethod that writes a GetUsers method for the supplied Object to the supplied file.

func NewGetWriteConnectionSecretToReference

func NewGetWriteConnectionSecretToReference(receiver, runtime string) New

NewGetWriteConnectionSecretToReference returns a NewMethod that writes a GetWriteConnectionSecretToReference method for the supplied Object to the supplied file.

func NewLocalGetWriteConnectionSecretToReference

func NewLocalGetWriteConnectionSecretToReference(receiver, runtime string) New

NewLocalGetWriteConnectionSecretToReference returns a NewMethod that writes a GetWriteConnectionSecretToReference method for the supplied Object to the supplied file.

func NewLocalSetWriteConnectionSecretToReference

func NewLocalSetWriteConnectionSecretToReference(receiver, runtime string) New

NewLocalSetWriteConnectionSecretToReference returns a NewMethod that writes a SetWriteConnectionSecretToReference method for the supplied Object to the supplied file.

func NewManagedGetItems

func NewManagedGetItems(receiver, resource string) New

NewManagedGetItems returns a New that writes a GetItems method for the supplied object to the supplied file.

func NewProviderConfigUsageGetItems

func NewProviderConfigUsageGetItems(receiver, resource string) New

NewProviderConfigUsageGetItems returns a New that writes a GetItems method for the supplied object to the supplied file.

func NewResolveReferences

func NewResolveReferences(traverser *xptypes.Traverser, receiver, clientPath, referencePkgPath string) New

NewResolveReferences returns a NewMethod that writes a ResolveReferences for given managed resource, if needed.

func NewSetConditions

func NewSetConditions(receiver, runtime string) New

NewSetConditions returns a NewMethod that writes a SetConditions method for the supplied Object to the supplied file.

func NewSetDeletionPolicy

func NewSetDeletionPolicy(receiver, runtime string) New

NewSetDeletionPolicy returns a NewMethod that writes a SetDeletionPolicy method for the supplied Object to the supplied file.

func NewSetManagementPolicies

func NewSetManagementPolicies(receiver, runtime string) New

NewSetManagementPolicies returns a NewMethod that writes a SetManagementPolicies method for the supplied Object to the supplied file.

func NewSetProviderConfigReference

func NewSetProviderConfigReference(receiver, runtime string) New

NewSetProviderConfigReference returns a NewMethod that writes a SetProviderConfigReference method for the supplied Object to the supplied file.

func NewSetPublishConnectionDetailsTo

func NewSetPublishConnectionDetailsTo(receiver, runtime string) New

NewSetPublishConnectionDetailsTo returns a NewMethod that writes a NewSetPublishConnectionDetailsTo method for the supplied Object to the supplied file.

func NewSetResourceReference

func NewSetResourceReference(receiver, core string) New

NewSetResourceReference returns a NewMethod that writes a SetResourceReference method for the supplied Object to the supplied file.

func NewSetRootProviderConfigReference

func NewSetRootProviderConfigReference(receiver, runtime string) New

NewSetRootProviderConfigReference returns a NewMethod that writes a SetProviderConfigReference method for the supplied Object to the supplied file. Note that unlike NewSetProviderConfigReference the generated method expects the ProviderConfigReference to be at the root of the struct, not under its Spec field.

func NewSetRootResourceReference

func NewSetRootResourceReference(receiver, runtime string) New

NewSetRootResourceReference returns a NewMethod that writes a SetRootResourceReference method for the supplied Object to the supplied file.

func NewSetUsers

func NewSetUsers(receiver string) New

NewSetUsers returns a NewMethod that writes a SetUsers method for the supplied Object to the supplied file.

func NewSetWriteConnectionSecretToReference

func NewSetWriteConnectionSecretToReference(receiver, runtime string) New

NewSetWriteConnectionSecretToReference returns a NewMethod that writes a SetWriteConnectionSecretToReference method for the supplied Object to the supplied file.

type Reference

type Reference struct {
	// RemoteType represents the type whose reference we're holding.
	RemoteType *jen.Statement

	// Extractor is the function call of the function that will take referenced
	// instance and return a string or []string to be set as value.
	Extractor *jen.Statement

	// RemoteListType is the list type of the type whose reference we're holding.
	RemoteListType *jen.Statement

	// GoValueFieldPath is the list of fields that needs to be traveled to access
	// the current value field. It may include prefixes like [] for array fields,
	// * for pointer fields or []* for array of pointer fields.
	GoValueFieldPath []string

	// GoRefFieldName is the name of the field whose type is *xpv1.Reference or
	// []xpv1.Reference.
	GoRefFieldName string

	// GoSelectorFieldName is the name of the field whose type is *xpv1.Selector
	GoSelectorFieldName string

	// IsSlice tells whether the current value type is a slice kind.
	IsSlice bool

	// IsPointer tells whether the current value type is a pointer kind.
	IsPointer bool

	// IsFloatPointer tells whether the current value pointer is of type float64
	IsFloatPointer bool
}

Reference is the internal representation that has enough information to let us generate the resolver.

type ReferenceProcessor

type ReferenceProcessor struct {
	// DefaultExtractor is used when the extractor is not overridden.
	DefaultExtractor *jen.Statement

	// Receiver is prepended to all field paths.
	Receiver string
	// contains filtered or unexported fields
}

ReferenceProcessor detects whether the field is marked as referencer and composes the internal representation of that reference.

func NewReferenceProcessor

func NewReferenceProcessor(receiver string, opts ...ReferenceProcessorOption) *ReferenceProcessor

NewReferenceProcessor returns a new *ReferenceProcessor .

func (*ReferenceProcessor) GetReferences

func (rp *ReferenceProcessor) GetReferences() []Reference

GetReferences returns all the references accumulated so far from processing.

func (*ReferenceProcessor) Process

func (rp *ReferenceProcessor) Process(_ *types.Named, f *types.Var, _, comment string, parentFields ...string) error

Process stores the reference information of the given field, if any.

type ReferenceProcessorOption

type ReferenceProcessorOption func(*ReferenceProcessor)

ReferenceProcessorOption is used to configure ReferenceProcessor.

func WithDefaultExtractor

func WithDefaultExtractor(ext *jen.Statement) ReferenceProcessorOption

WithDefaultExtractor returns an option that sets the extractor to given call.

type Set

type Set map[string]New

A Set is a map of method names to the New functions that produce them.

func (Set) Write

func (s Set) Write(f *jen.File, o types.Object, mf Filter)

Write the method Set for the supplied Object to the supplied file. Methods are filtered by the supplied Filter.

Jump to

Keyboard shortcuts

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