model

package
v0.0.0-...-5eebe45 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceDeclaration = DeclarationType("Resource")
	ObjectDeclaration   = DeclarationType("Object")
	EnumDeclaration     = DeclarationType("Enum")
)
View Source
const (
	OrderAlphabetical = "alphabetical"
)

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)
	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 TryNewEnum

func TryNewEnum(spec dst.Spec, comments []string) (*Enum, bool)

func (*Enum) AddValue

func (e *Enum) AddValue(value *EnumValue)

func (*Enum) Description

func (e *Enum) Description() []string

func (*Enum) Kind

func (e *Enum) Kind() DeclarationType

func (*Enum) Name

func (e *Enum) Name() string

func (*Enum) SetUsage

func (e *Enum) SetUsage(usage []PropertyReference)

func (*Enum) Usage

func (e *Enum) Usage() []PropertyReference

func (*Enum) Values

func (e *Enum) Values() []*EnumValue

type EnumValue

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

func TryNewEnumValue

func TryNewEnumValue(spec dst.Spec) (*EnumValue, bool)

func (*EnumValue) Description

func (v *EnumValue) Description() []string

func (*EnumValue) Kind

func (v *EnumValue) Kind() string

func (*EnumValue) Name

func (v *EnumValue) Name() string

func (*EnumValue) Value

func (v *EnumValue) Value() string

type Markers

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

func NewMarkers

func NewMarkers() *Markers

func ParseComments

func ParseComments(comments []string) ([]string, *Markers)

ParseComments iterates over the comments and returns the description and any commands that are not part of the description

func (*Markers) Add

func (m *Markers) Add(marker string)

Add a marker to the list

func (*Markers) Any

func (m *Markers) Any() bool

func (*Markers) Exists

func (m *Markers) Exists(path ...string) bool

Exists returns true if the marker exists

func (*Markers) Lookup

func (m *Markers) Lookup(path ...string) (string, bool)

Lookup a marker value by path, returning the final value

type Object

type Object struct {
	TypeReference
	// contains filtered or unexported fields
}

func TryNewObject

func TryNewObject(spec dst.Spec, comments []string) (*Object, bool)

func (*Object) Description

func (o *Object) Description() []string

func (*Object) Embed

func (o *Object) Embed(name string) (*Property, bool)

Embed returns the embed with the given name and true, or nil and false if not found

func (*Object) Embeds

func (o *Object) Embeds() []*Property

Embeds returns all of the embeds of the object, in alphabetical order

func (*Object) Kind

func (o *Object) Kind() DeclarationType

func (*Object) Properties

func (o *Object) Properties() []*Property

Properties returns all the properties of the object, in alphabetical order

func (*Object) Property

func (o *Object) Property(name string) (*Property, bool)

Property returns the property with the given name and true, or nil and false if not found

func (*Object) SetUsage

func (o *Object) SetUsage(uses []PropertyReference)

func (*Object) Usage

func (o *Object) Usage() []PropertyReference

type Order

type Order string

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 PackageMetadata,
	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) Group

func (p *Package) Group() string

Group returns the group of the package

func (*Package) Module

func (p *Package) Module() string

Module returns the module of the package

func (*Package) Name

func (p *Package) Name() string

func (*Package) Object

func (p *Package) Object(name string) (*Object, bool)

Object returns the object with the given name, if there is one

func (*Package) Version

func (p *Package) Version() string

Version returns the version of the package

type PackageMetadata

type PackageMetadata struct {
	Name    string // Name of this package
	Module  string // Reference to use when importing this package
	Group   string // Controller-Gen Group of this package
	Version string // Controller-Gen Version of this package
}

func (*PackageMetadata) TrySetGroup

func (m *PackageMetadata) TrySetGroup(group string) bool

TrySetGroup will set the group if it is not already set, returning true if successful and false if unchanged

func (*PackageMetadata) TrySetVersion

func (m *PackageMetadata) TrySetVersion(version string) bool

TrySetVersion will set the version if it is not already set, returning true if successful and false if unchanged

type Property

type Property struct {
	Field string // Name of the field
	Name  string // Serialized name of the field
	Type  TypeReference
	// contains filtered or unexported fields
}

func TryNewProperty

func TryNewProperty(name string, field *dst.Field) (*Property, bool)

func (*Property) Description

func (p *Property) Description() []string

func (*Property) Required

func (p *Property) Required() string

type PropertyContainer

type PropertyContainer interface {
	Properties() []*Property
}

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

type Resource struct {
	Object
	Spec   *Property
	Status *Property
}

func TryNewResource

func TryNewResource(object *Object) (*Resource, bool)

func (*Resource) Kind

func (r *Resource) Kind() DeclarationType

type TypeReference

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

func NewTypeReference

func NewTypeReference(expr dst.Expr) TypeReference

func (*TypeReference) Id

func (ref *TypeReference) Id() string

func (*TypeReference) Name

func (ref *TypeReference) Name() string

Jump to

Keyboard shortcuts

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