databases

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DB_CATEGORY = "databases"

Variables

View Source
var (
	BaseDatabaseURL = "https://raw.githubusercontent.com/unbindapp/unbind-custom-service-definitions/refs/tags/%s"
)
View Source
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

type DefinitionImport struct {
	Path string `yaml:"path"`
	As   string `yaml:"as"`
}

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 IndexResponse struct {
	Categories []struct {
		Name      string   `json:"name"`
		Templates []string `json:"templates"`
	} `json:"categories"`
}

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

Jump to

Keyboard shortcuts

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