Documentation
¶
Index ¶
- Constants
- Variables
- type DatabaseProvider
- type DatabaseRenderer
- func (r *DatabaseRenderer) RegisterCRD(gvk schema.GroupVersionKind, obj runtime.Object)
- func (r *DatabaseRenderer) Render(unbindDefinition *Definition, context *RenderContext) (string, error)
- func (r *DatabaseRenderer) RenderToObjects(renderedYAML string) ([]runtime.Object, error)
- func (r *DatabaseRenderer) Validate(params map[string]interface{}, schema DefinitionParameterSchema) error
- type Definition
- type DefinitionImport
- type DefinitionMetadata
- type DefinitionParameterSchema
- type HelmChartInfo
- type IndexResponse
- type ParameterProperty
- type RenderContext
Constants ¶
const DB_CATEGORY = "databases"
Variables ¶
var (
BaseDatabaseURL = "https://raw.githubusercontent.com/unbindapp/unbind-custom-service-definitions/refs/tags/%s"
)
var (
ErrDatabaseNotFound = errors.New("database not found")
)
Functions ¶
This section is empty.
Types ¶
type DatabaseProvider ¶
type DatabaseProvider struct {
// contains filtered or unexported fields
}
DatabaseProvider fetches database definitions from GitHub
func NewDatabaseProvider ¶
func NewDatabaseProvider() *DatabaseProvider
func (*DatabaseProvider) FetchDatabaseDefinition ¶
func (p *DatabaseProvider) FetchDatabaseDefinition( ctx context.Context, tagVersion, dbType string, ) (*Definition, error)
FetchDatabaseDefinition downloads the metadata/definition for the requested database, resolves $ref imports, converts every YAML map to map[string]interface{}, and returns a Definition ready for Huma to marshal.
func (*DatabaseProvider) ListDatabases ¶
func (self *DatabaseProvider) ListDatabases(ctx context.Context, tagVersion string) ([]string, error)
ListDatabases lists all available databases
type DatabaseRenderer ¶
type DatabaseRenderer struct {
// contains filtered or unexported fields
}
DatabaseRenderer renders a DB definition into Kubernetes resources
func NewDatabaseRenderer ¶
func NewDatabaseRenderer() *DatabaseRenderer
func (*DatabaseRenderer) RegisterCRD ¶
func (r *DatabaseRenderer) RegisterCRD(gvk schema.GroupVersionKind, obj runtime.Object)
RegisterCRD registers a custom resource definition with the renderer For custom CRDs it enabled better validation
func (*DatabaseRenderer) Render ¶
func (r *DatabaseRenderer) Render(unbindDefinition *Definition, context *RenderContext) (string, error)
Render renders a definition to YAML string that can be applied to Kubernetes
func (*DatabaseRenderer) RenderToObjects ¶
func (r *DatabaseRenderer) RenderToObjects(renderedYAML string) ([]runtime.Object, error)
RenderToObjects parses the rendered YAML into Kubernetes objects
func (*DatabaseRenderer) Validate ¶
func (r *DatabaseRenderer) Validate(params map[string]interface{}, schema DefinitionParameterSchema) error
Validate validates parameters against the schema
type Definition ¶
type Definition struct { Name string `json:"name"` Port int `json:"port"` Category string `json:"category"` Description string `json:"description"` Type string `json:"type"` Version string `json:"version"` Schema DefinitionParameterSchema `json:"schema"` Content string `json:"-"` Chart *HelmChartInfo `json:"chart,omitempty"` }
Definition represents a fully resolved definition
type DefinitionImport ¶
DefinitionImport represents an import of an external schema
type DefinitionMetadata ¶
type DefinitionMetadata struct { Name string `yaml:"name" json:"name"` Port int `yaml:"port" json:"port"` Description string `yaml:"description" json:"description"` Type string `yaml:"type" json:"type"` Version string `yaml:"version" json:"version"` DBVersion string `yaml:"dbVersion" json:"dbVersion"` Imports []DefinitionImport `yaml:"imports,omitempty" json:"imports,omitempty"` Schema DefinitionParameterSchema `yaml:"schema" json:"schema"` // Helm-specific fields Chart *HelmChartInfo `yaml:"chart,omitempty" json:"chart,omitempty"` }
DefinitionMetadata represents the metadata of a definition
type DefinitionParameterSchema ¶
type DefinitionParameterSchema struct { Properties map[string]ParameterProperty `yaml:"properties" json:"properties"` Required []string `yaml:"required,omitempty" json:"required,omitempty"` Imports map[string]interface{} `json:"-" yaml:"-"` // For resolved imports }
DefinitionParameterSchema defines the structure for allowed parameters
type HelmChartInfo ¶
type HelmChartInfo struct { Name string `yaml:"name" json:"name"` // Name of the chart Version string `yaml:"version" json:"version"` // Version of the chart to use Repository string `yaml:"repository" json:"repository"` // Chart repository URL RepositoryName string `yaml:"repositoryName,omitempty" json:"repositoryName,omitempty"` // Name for the repository CR }
HelmChartInfo contains information about a Helm chart
type IndexResponse ¶
type ParameterProperty ¶
type ParameterProperty struct { Type string `yaml:"type" json:"type"` Description string `yaml:"description,omitempty" json:"description,omitempty"` Default interface{} `yaml:"default,omitempty" json:"default,omitempty"` Enum []string `yaml:"enum,omitempty" json:"enum,omitempty"` Properties map[string]ParameterProperty `yaml:"properties,omitempty" json:"properties,omitempty"` AdditionalProperties *ParameterProperty `yaml:"additionalProperties,omitempty" json:"additionalProperties,omitempty"` Ref string `yaml:"$ref,omitempty" json:"$ref,omitempty"` Minimum *float64 `yaml:"minimum,omitempty" json:"minimum,omitempty"` Maximum *float64 `yaml:"maximum,omitempty" json:"maximum,omitempty"` }
ParameterProperty defines a single parameter's schema
type RenderContext ¶
type RenderContext struct { // Service info Name string Namespace string TeamID string // Definition info Definition Definition // Parameters from service Parameters map[string]interface{} // RFC3339 time format constant for templates RFC3339 string }
RenderContext holds the data for definition rendering