Documentation ¶
Index ¶
- Constants
- Variables
- func AttributeStatement(f, parent Field) *j.Statement
- func AttributeTypeDeclaration(f Field) string
- func NewManagedResourceTypeDefRenderer(mr *ManagedResource, tg template.TemplateGetter) *managedResourceTypeDefRenderer
- func RenderKubebuilderResourceAnnotation(mr *ManagedResource) string
- func TypeStatement(f Field, s *j.Statement) *j.Statement
- type AttributeField
- type AttributeType
- type DecodeFnGenerator
- type EncodeFnGenerator
- type Field
- type FieldType
- type Fragment
- func AtProviderFragments(mr *ManagedResource) []*Fragment
- func FieldFragments(f Field) []*Fragment
- func ForProviderFragments(mr *ManagedResource) []*Fragment
- func ResourceTypeFragment(mr *ManagedResource) *Fragment
- func SpecFragment(mr *ManagedResource) *Fragment
- func StatusFragment(mr *ManagedResource) *Fragment
- func TypeListFragment(mr *ManagedResource) *Fragment
- type ManagedResource
- type MergeFnGenerator
- type MultiError
- type NamedFields
- type ResourceNamer
- type StructField
- type StructTag
- type StructTagJson
Constants ¶
const CommentBlankLine = "" // assumes comments are joined with newlines
const KubebuilderMarkStatusSubresource = "+kubebuilder:subresource:status"
const KubebuilderObjectRoot = "+kubebuilder:object:root=true"
Variables ¶
var InvalidMRNameEmpty error = errors.New(".Name is required")
var InvalidMRPackagePathEmpty error = errors.New(".PackagePath is required")
Functions ¶
func AttributeStatement ¶
func NewManagedResourceTypeDefRenderer ¶
func NewManagedResourceTypeDefRenderer(mr *ManagedResource, tg template.TemplateGetter) *managedResourceTypeDefRenderer
func RenderKubebuilderResourceAnnotation ¶
func RenderKubebuilderResourceAnnotation(mr *ManagedResource) string
RenderKubebuilderResourceAnnotation renderes the kubebuilder resource tag which indicates whether the resources is namespace- or cluster-scoped and sets the categories field in the CRD which allow kubectl to select sets of resources based on matching category tags.
Types ¶
type AttributeField ¶
type AttributeField struct { Type AttributeType MapValueType AttributeType }
type AttributeType ¶
type AttributeType int
const ( AttributeTypeUnsupported AttributeType = iota AttributeTypeUintptr AttributeTypeUint8 AttributeTypeUint64 AttributeTypeUint32 AttributeTypeUint16 AttributeTypeUint AttributeTypeString AttributeTypeRune AttributeTypeInt8 AttributeTypeInt64 AttributeTypeInt32 AttributeTypeInt16 AttributeTypeInt AttributeTypeFloat64 AttributeTypeFloat32 AttributeTypeComplex64 AttributeTypeComplex128 AttributeTypeByte AttributeTypeBool // AttributeTypeMapStringKey means that the field is a map[string]<type> // where <type> is defined by the value of Field.AttributeField.MapValueType AttributeTypeMapStringKey )
func (AttributeType) String ¶
func (i AttributeType) String() string
type DecodeFnGenerator ¶
type EncodeFnGenerator ¶
type Field ¶
type Field struct { Name string Type FieldType Fields []Field StructField StructField AttributeField AttributeField IsSlice bool Tag *StructTag EncodeFnGenerator EncodeFnGenerator DecodeFnGenerator DecodeFnGenerator MergeFnGenerator MergeFnGenerator // struct comment "annotations" Computed bool Optional bool Required bool Sensitive bool }
type Fragment ¶
type Fragment struct {
// contains filtered or unexported fields
}
Fragment is a simple type for grouping comments with arbitrary jen statements Jen only has nice formatting for comments in the context of a File, which is a type we are trying to avoid in order to use Jen to only render more complex fragments on the assumption that go templates will be more readable for files.
func AtProviderFragments ¶
func AtProviderFragments(mr *ManagedResource) []*Fragment
func FieldFragments ¶
func ForProviderFragments ¶
func ForProviderFragments(mr *ManagedResource) []*Fragment
func ResourceTypeFragment ¶
func ResourceTypeFragment(mr *ManagedResource) *Fragment
func SpecFragment ¶
func SpecFragment(mr *ManagedResource) *Fragment
func StatusFragment ¶
func StatusFragment(mr *ManagedResource) *Fragment
func TypeListFragment ¶
func TypeListFragment(mr *ManagedResource) *Fragment
func (*Fragment) FormattedComments ¶
FormattedComments uses a simple rendering algo of prepending every line in the set of all comments with '//' and joining them together with '\n'
type ManagedResource ¶
type ManagedResource struct { Name string PackagePath string Parameters Field Observation Field CategoryTags []string // contains filtered or unexported fields }
func NewManagedResource ¶
func NewManagedResource(name, packagePath string) *ManagedResource
func (*ManagedResource) CategoryCSV ¶
func (mr *ManagedResource) CategoryCSV() string
CategoryTagsCSV returns a comma separated list respresenting CategoryTags this is used in the kubebuilder resource categories comment annotation eg: +kubebuilder:resource:categories={crossplane,managed,aws}
func (*ManagedResource) Namer ¶
func (mr *ManagedResource) Namer() ResourceNamer
func (*ManagedResource) Validate ¶
func (mr *ManagedResource) Validate() error
Validate ensures that the ManagedResource can be rendered to code
func (*ManagedResource) WithNamer ¶
func (mr *ManagedResource) WithNamer(n ResourceNamer) *ManagedResource
type MergeFnGenerator ¶
type MultiError ¶
MultiError gives client code the ability to type assert a possible multiError into a form where the individual errors can be examined.
func NewMultiError ¶
func NewMultiError(heading string) MultiError
NewMultiError handles initializing the errors slice and allows a heading to be set. The Error() method will print this heading before listing out the individual errors.
type NamedFields ¶
type NamedFields []Field
NamedFields implements the sort.Sort methodset, allowing you to call sort.Sort(NamedFields) on a slice of []Field
func (NamedFields) Len ¶
func (x NamedFields) Len() int
func (NamedFields) Less ¶
func (x NamedFields) Less(i, j int) bool
func (NamedFields) Swap ¶
func (x NamedFields) Swap(i, j int)
type ResourceNamer ¶
type ResourceNamer interface { TypeName() string TypeListName() string SpecTypeName() string StatusTypeName() string AtProviderTypeName() string ForProviderTypeName() string }
func NewDefaultNamer ¶
func NewDefaultNamer(resourceName string) ResourceNamer
type StructField ¶
type StructTag ¶
type StructTag struct {
Json *StructTagJson
}