Documentation
¶
Index ¶
- Constants
- func ComparePropertyReferences(left PropertyReference, right PropertyReference) int
- type Declaration
- type DeclarationType
- type Enum
- func (e *Enum) AddValue(value *EnumValue)
- func (e *Enum) Description() []string
- func (*Enum) Kind() DeclarationType
- func (e *Enum) Name() string
- func (e *Enum) Package() *Package
- func (e *Enum) SetPackage(pkg *Package)
- func (e *Enum) SetUsage(usage []PropertyReference)
- func (e *Enum) Usage() []PropertyReference
- func (e *Enum) Values() []*EnumValue
- type EnumValue
- type Function
- type FunctionList
- type ImportReference
- type ImportReferenceSet
- type Interface
- func (i *Interface) AddImplementation(obj *Object)
- func (i *Interface) Description() []string
- func (i *Interface) Embeds() []TypeReference
- func (i *Interface) Implementations() []*Object
- func (*Interface) Kind() DeclarationType
- func (i *Interface) Method(name string) (*Function, bool)
- func (i *Interface) Methods() FunctionList
- func (i *Interface) Name() string
- func (i *Interface) Package() *Package
- func (i *Interface) SetPackage(pkg *Package)
- func (i *Interface) SetUsage(usage []PropertyReference)
- func (i *Interface) Usage() []PropertyReference
- type MarkerSwitch
- type MarkerValue
- type Markers
- type Object
- func (o *Object) AddFunction(fn *Function)
- func (o *Object) AddInterface(iface *Interface)
- func (o *Object) Description() []string
- func (o *Object) Embed(name string) (*Property, bool)
- func (o *Object) Embeds() PropertyList
- func (o *Object) Function(name string) (*Function, bool)
- func (o *Object) Functions() FunctionList
- func (o *Object) ImplementsInterfaces() []*Interface
- func (*Object) Kind() DeclarationType
- func (o *Object) Package() *Package
- func (o *Object) Properties() PropertyList
- func (o *Object) Property(name string) (*Property, bool)
- func (o *Object) SetPackage(p *Package)
- func (o *Object) SetUsage(uses []PropertyReference)
- func (o *Object) Usage() []PropertyReference
- type Order
- type Package
- func (p *Package) Declaration(name string) (Declaration, bool)
- func (p *Package) Declarations(order Order) []Declaration
- func (p *Package) Group() string
- func (p *Package) Interface(name string) (*Interface, bool)
- func (p *Package) Module() string
- func (p *Package) Name() string
- func (p *Package) Object(name string) (*Object, bool)
- func (p *Package) PropertiesRequiredByDefault() string
- func (p *Package) Rank(name string) int
- func (p *Package) Version() string
- type PackageBuilder
- type PackageMarkers
- type Parameter
- type Property
- type PropertyContainer
- type PropertyList
- type PropertyMarkers
- type PropertyReference
- type Resource
- type TypeAssertionInfo
- type TypeReference
Constants ¶
const ( ResourceDeclaration = DeclarationType("Resource") ObjectDeclaration = DeclarationType("Object") EnumDeclaration = DeclarationType("Enum") InterfaceDeclaration = DeclarationType("Interface") )
const ( OrderAlphabetical = "alphabetical" OrderRanked = "ranked" )
Variables ¶
This section is empty.
Functions ¶
func ComparePropertyReferences ¶
func ComparePropertyReferences( left PropertyReference, right PropertyReference, ) int
Types ¶
type Declaration ¶
type Declaration interface {
Name() string
ID() string
Kind() DeclarationType
Usage() []PropertyReference
Package() *Package
Description() []string
}
Declaration is a common interface for declarations found in Go files.
type DeclarationType ¶
type DeclarationType string
type Enum ¶
type Enum struct {
TypeReference
// contains filtered or unexported fields
}
func (*Enum) Description ¶
func (*Enum) Kind ¶
func (*Enum) Kind() DeclarationType
func (*Enum) SetPackage ¶
func (*Enum) SetUsage ¶
func (e *Enum) SetUsage(usage []PropertyReference)
func (*Enum) Usage ¶
func (e *Enum) Usage() []PropertyReference
type EnumValue ¶
type EnumValue struct {
// contains filtered or unexported fields
}
func (*EnumValue) Description ¶
type Function ¶
type Function struct {
Name string // Name of the function/method
Receiver TypeReference // Type of the receiver (pointer or value)
IsPointerReceiver bool // Whether the receiver is a pointer
Parameters []Parameter // Function parameters
Results []Parameter // Return values
// contains filtered or unexported fields
}
Function represents a method declared on a struct type.
func TryNewFunction ¶
TryNewFunction attempts to create a Function from a dst.FuncDecl. Returns the function and true if successful, nil and false otherwise.
func (*Function) DeclaredOn ¶
DeclaredOn returns the object this function is declared on.
func (*Function) Description ¶
Description returns the description of the function.
type ImportReference ¶
func TryNewImportReference ¶
func TryNewImportReference(imp *dst.ImportSpec) (ImportReference, bool)
func (*ImportReference) Name ¶
func (imp *ImportReference) Name() string
type ImportReferenceSet ¶
type ImportReferenceSet map[string]ImportReference
ImportReferenceSet is a set of ImportReference objects, indexed by their alias.
func NewImportReferenceSet ¶
func NewImportReferenceSet(refs ...ImportReference) ImportReferenceSet
NewImportReferenceSet creates a new ImportReferenceSet and adds the provided ImportReferences to it.
func (ImportReferenceSet) Add ¶
func (set ImportReferenceSet) Add(ref ImportReference)
Add adds an ImportReference to the set, using its alias as the key. If the alias already exists, it will be overwritten.
func (ImportReferenceSet) LookupImportPath ¶
func (set ImportReferenceSet) LookupImportPath( typ TypeReference, ) (string, bool)
LookupImportPath looks up the import path for a given TypeReference in the ImportReferenceSet. It returns the import path and true if found, false otherwise.
type Interface ¶
type Interface struct {
TypeReference
// contains filtered or unexported fields
}
Interface represents an interface type declaration.
func TryNewInterface ¶
func TryNewInterface( spec dst.Spec, comments []string, importReferences map[string]ImportReference, ) (*Interface, bool)
TryNewInterface attempts to create an Interface from a dst.Spec. Returns the interface and true if successful, nil and false otherwise.
func (*Interface) AddImplementation ¶
AddImplementation adds an object as an implementation of this interface.
func (*Interface) Description ¶
Description returns the description of the interface.
func (*Interface) Embeds ¶
func (i *Interface) Embeds() []TypeReference
Embeds returns all the embedded interfaces, in the order they were declared.
func (*Interface) Implementations ¶
Implementations returns all the objects that implement this interface.
func (*Interface) Kind ¶
func (*Interface) Kind() DeclarationType
Kind returns the declaration type.
func (*Interface) Method ¶
Method returns the method with the given name and true, or nil and false if not found.
func (*Interface) Methods ¶
func (i *Interface) Methods() FunctionList
Methods returns all the methods of the interface, in alphabetical order.
func (*Interface) SetPackage ¶
SetPackage sets the package this interface belongs to.
func (*Interface) SetUsage ¶
func (i *Interface) SetUsage(usage []PropertyReference)
SetUsage sets the list of properties that reference this interface.
func (*Interface) Usage ¶
func (i *Interface) Usage() []PropertyReference
Usage returns the list of properties that reference this interface.
type MarkerSwitch ¶
type MarkerSwitch struct {
// contains filtered or unexported fields
}
MarkerSwitch captures the presence of a specific marker read from the source code.
func MakeMarkerSwitch ¶
func MakeMarkerSwitch(path ...string) MarkerSwitch
MakeMarkerSwitch creates a new MArkerSwitch with the given marker path. path is the marker path to look for.
func (*MarkerSwitch) Merge ¶
func (m *MarkerSwitch) Merge(other MarkerSwitch)
Merge combines the supplied MetadataSwitch with the current one, returning an error if the values differ.
func (*MarkerSwitch) Seen ¶
func (m *MarkerSwitch) Seen() bool
Seen returns true if this marker has been seen, false otherwise.
func (*MarkerSwitch) Update ¶
func (m *MarkerSwitch) Update(markers *Markers)
Update checks for the desired marker in passed set of markers, updating the value if found.
type MarkerValue ¶
type MarkerValue struct {
// contains filtered or unexported fields
}
MarkerValue captures the value of a specific marker read from the source code.
func MakeMarkerValue ¶
func MakeMarkerValue(path ...string) MarkerValue
MakeMarkerValue creates a new MetadataValue that looks for the given marker path. path is the path to the desired value.
func (*MarkerValue) Merge ¶
func (m *MarkerValue) Merge(other MarkerValue) error
Merge combines the supplied MetadataValue with the current one, returning an error if the values differ.
func (*MarkerValue) SetValue ¶
func (m *MarkerValue) SetValue(value string) error
func (*MarkerValue) Update ¶
func (m *MarkerValue) Update(markers *Markers) error
Update reads the value from the passed set of markers, updating the value if found. If a new value is found that's different from the current value, we return an error.
func (*MarkerValue) Value ¶
func (m *MarkerValue) Value() (string, bool)
Value returns the current value of the metadata, if known.
type Markers ¶
type Markers struct {
// contains filtered or unexported fields
}
func NewMarkers ¶
func ParseComments ¶
ParseComments iterates over the comments and returns the description and any commands that are not part of the description TODO: Add optional varidic "cleanup" functions to allow for more complex comment parsing/cleanup.
type Object ¶
type Object struct {
TypeReference
// contains filtered or unexported fields
}
func TryNewObject ¶
func (*Object) AddFunction ¶
AddFunction adds a function to the object.
func (*Object) AddInterface ¶
AddInterface adds an interface that this object implements.
func (*Object) Description ¶
func (*Object) Embed ¶
Embed returns the embed with the given name and true, or nil and false if not found.
func (*Object) Embeds ¶
func (o *Object) Embeds() PropertyList
Embeds returns all of the embeds of the object, in alphabetical order.
func (*Object) Function ¶
Function returns the function with the given name and true, or nil and false if not found.
func (*Object) Functions ¶
func (o *Object) Functions() FunctionList
Functions returns all the functions/methods of the object, in alphabetical order.
func (*Object) ImplementsInterfaces ¶
ImplementsInterfaces returns all the interfaces this object implements, in alphabetical order.
func (*Object) Kind ¶
func (*Object) Kind() DeclarationType
func (*Object) Properties ¶
func (o *Object) Properties() PropertyList
Properties returns all the properties of the object, in alphabetical order.
func (*Object) Property ¶
Property returns the property with the given name and true, or nil and false if not found.
func (*Object) SetPackage ¶
func (*Object) SetUsage ¶
func (o *Object) SetUsage(uses []PropertyReference)
func (*Object) Usage ¶
func (o *Object) Usage() []PropertyReference
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package is a struct containing all of the declarations found in a package directory.
func (*Package) Declaration ¶
func (p *Package) Declaration(name string) (Declaration, bool)
Declaration returns the declaration with the given name, if found.
func (*Package) Declarations ¶
func (p *Package) Declarations(order Order) []Declaration
func (*Package) PropertiesRequiredByDefault ¶
type PackageBuilder ¶
type PackageBuilder struct {
Resources []*Resource
Objects map[string]*Object
Enums []*Enum
Interfaces map[string]*Interface
Metadata *PackageMarkers
Config *config.Config
Log logr.Logger
}
PackageBuilder is a builder for Package instances.
func (*PackageBuilder) AddEnums ¶
func (b *PackageBuilder) AddEnums(enums ...*Enum)
AddEnums adds enums to the builder.
func (*PackageBuilder) AddInterfaces ¶
func (b *PackageBuilder) AddInterfaces(interfaces ...*Interface)
AddInterfaces adds interfaces to the builder.
func (*PackageBuilder) AddObjects ¶
func (b *PackageBuilder) AddObjects(objects ...*Object)
AddObjects adds objects to the builder.
func (*PackageBuilder) AddResources ¶
func (b *PackageBuilder) AddResources(resources ...*Resource)
AddResources adds resources to the builder.
func (*PackageBuilder) Build ¶
func (b *PackageBuilder) Build() *Package
Build creates a new Package from the builder.
type PackageMarkers ¶
type PackageMarkers struct {
Name string // Name of this package.
Module string // Reference to use when importing this package.
DefaultGroup string // Default group, based on directory name
DefaultVersion string // Default version, based on directory name
// contains filtered or unexported fields
}
PackageMarkers captures specific package markers read from the source code.
func NewPackageMarkers ¶
func NewPackageMarkers() *PackageMarkers
func (*PackageMarkers) Group ¶
func (m *PackageMarkers) Group() string
Group returns the group of the package, using the configured controller-runtime marker if set, or the directory name if not.
func (*PackageMarkers) Merge ¶
func (m *PackageMarkers) Merge(other *PackageMarkers) error
func (*PackageMarkers) PropertiesRequiredByDefault ¶
func (m *PackageMarkers) PropertiesRequiredByDefault() string
func (*PackageMarkers) Update ¶
func (m *PackageMarkers) Update(markers *Markers) error
func (*PackageMarkers) Version ¶
func (m *PackageMarkers) Version() string
Version returns the version of the package, using the configured controller-runtime marker if set, or the directory name if not.
type Parameter ¶
type Parameter struct {
Name string // Name of the parameter (may be empty)
Type TypeReference // Type of the parameter
}
Parameter represents a function parameter or return value.
func NewAnonymousParameter ¶
func NewAnonymousParameter( typeRef TypeReference, ) Parameter
NewAnonymousParameter creates a new anonymous Parameter. typeRef is the type of the parameter.
func NewNamedParameter ¶
func NewNamedParameter( name string, typeRef TypeReference, ) Parameter
NewNamedParameter creates a new named Parameter. name is the parameter name. typeRef is the type of the parameter.
type Property ¶
type Property struct {
Field string // Name of the field
Name string // Serialized name of the field
Type TypeReference
DeclaredOn PropertyContainer
// contains filtered or unexported fields
}
func NewProperty ¶
func NewProperty( name string, ref TypeReference, description []string, ) *Property
func (*Property) Description ¶
type PropertyContainer ¶
type PropertyContainer interface {
Embeds() PropertyList
Properties() PropertyList
Package() *Package
}
type PropertyList ¶
type PropertyList []*Property
type PropertyMarkers ¶
type PropertyMarkers struct {
// contains filtered or unexported fields
}
func NewPropertyMarkers ¶
func NewPropertyMarkers() *PropertyMarkers
func (*PropertyMarkers) Merge ¶
func (m *PropertyMarkers) Merge(other *PropertyMarkers) error
func (*PropertyMarkers) Optional ¶
func (m *PropertyMarkers) Optional() bool
func (*PropertyMarkers) Parse ¶
func (m *PropertyMarkers) Parse( markers *Markers, ) error
func (*PropertyMarkers) ParseDecorations ¶
func (m *PropertyMarkers) ParseDecorations(decs dst.NodeDecs) error
func (*PropertyMarkers) Required ¶
func (m *PropertyMarkers) Required() bool
type PropertyReference ¶
type PropertyReference struct {
HostName string // Name of the container of this property
HostID string // Id of the container of this property
Property string // Name of the property being referenced
}
func NewPropertyReference ¶
func NewPropertyReference( host string, id string, property string, ) PropertyReference
type Resource ¶
func TryNewResource ¶
func (*Resource) Kind ¶
func (*Resource) Kind() DeclarationType
type TypeAssertionInfo ¶
type TypeAssertionInfo struct {
InterfaceName string // Name of the interface being implemented
TypeName string // Name of the type that implements the interface
IsPointer bool // Whether the implementation is pointer-based (e.g., &Type{})
}
TypeAssertionInfo represents a type assertion of the form `var _ Interface = &Type{}`. These assertions are used to link interfaces to their implementations.
func NewTypeAssertionInfo ¶
func NewTypeAssertionInfo(interfaceName, typeName string, isPointer bool) TypeAssertionInfo
NewTypeAssertionInfo creates a new TypeAssertionInfo.
type TypeReference ¶
type TypeReference struct {
// contains filtered or unexported fields
}
func NewTypeReferenceFromExpr ¶
func NewTypeReferenceFromExpr(expr dst.Expr) TypeReference
func (*TypeReference) Display ¶
func (ref *TypeReference) Display() string
func (*TypeReference) ID ¶
func (ref *TypeReference) ID() string
func (*TypeReference) ImportPath ¶
func (ref *TypeReference) ImportPath() string
func (*TypeReference) Name ¶
func (ref *TypeReference) Name() string
func (*TypeReference) Package ¶
func (ref *TypeReference) Package() string
Source Files
¶
- comments.go
- declaration.go
- enum.go
- enum_value.go
- function.go
- import_reference.go
- import_reference_set.go
- interface.go
- markers.go
- markerswitch.go
- markervalue.go
- object.go
- package.go
- package_builder.go
- package_markers.go
- parameter.go
- parser.go
- property.go
- property_container.go
- property_markers.go
- property_reference.go
- resource.go
- sorting.go
- type_assertion.go
- type_reference.go