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 ImportReference
- type ImportReferenceSet
- type MarkerSwitch
- type MarkerValue
- type Markers
- type Object
- func (o *Object) Description() []string
- func (o *Object) Embed(name string) (*Property, bool)
- func (o *Object) Embeds() []*Property
- func (*Object) Kind() DeclarationType
- func (o *Object) Package() *Package
- func (o *Object) Properties() []*Property
- 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) 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 PackageMarkers
- type Property
- type PropertyContainer
- type PropertyMarkers
- type PropertyReference
- type Resource
- type TypeReference
Constants ¶
const ( ResourceDeclaration = DeclarationType("Resource") ObjectDeclaration = DeclarationType("Object") EnumDeclaration = DeclarationType("Enum") )
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 SetUsage([]PropertyReference) Package() *Package SetPackage(*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 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
func (ImportReferenceSet) Add ¶
func (set ImportReferenceSet) Add(ref ImportReference)
func (ImportReferenceSet) LookupImportPath ¶
func (set ImportReferenceSet) LookupImportPath( typ TypeReference, ) (string, bool)
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) Description ¶
func (*Object) Embed ¶
Embed returns the embed with the given name and true, or nil and false if not found.
func (*Object) Kind ¶
func (*Object) Kind() DeclarationType
func (*Object) Properties ¶
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 NewPackage ¶
func NewPackage( decl []Declaration, metadata *PackageMarkers, cfg *config.Config, log logr.Logger, ) *Package
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 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 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 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 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