You are viewing development documentation built from the latest commit on main (last tag v0.2.0-rc.2, source commit 25e1a892).
APIs and features are subject to change.
MariaDB Builders
The mariadb package provides the generated constructors for the MariaDB operator (k8s.mariadb.com/v1alpha1) kinds. It is the canonical entry point for building MariaDB, its backups, restores, SQL jobs and SQL objects in kure. The Go types come from github.com/mariadb-operator/mariadb-operator/v26/api/v1alpha1, at the version kure’s go.mod pins.
Overview
Every kind this package covers is namespaced and takes (name, namespace):
| Resource | Purpose |
|---|---|
MariaDB | A MariaDB server: single instance, replication or Galera. |
Backup | A logical backup, once or on a schedule. |
PhysicalBackup | A physical backup or volume snapshot, once or on a schedule. |
Restore | A restore from a Backup or from object storage. |
PointInTimeRecovery | The binary-log archive a point-in-time restore reads. |
SqlJob | A SQL script run against a MariaDB, once or on a schedule. |
Database, User, Grant | SQL objects the operator keeps in a MariaDB. |
Connection | A Secret with connection details for an application. |
ExternalMariaDB | A MariaDB server outside the cluster, for the other kinds to point at. |
MaxScale is not covered. It is the one other kind of the group: kure does not register it in its scheme and generates no constructor for it. A caller that needs one builds the upstream mariadbv1alpha1.MaxScale type directly.
Each block on this page is the body of an Example function in example_test.go, which go test
runs: it imports this package as mariadb, the upstream API as
mariadbv1alpha1 "github.com/mariadb-operator/mariadb-operator/v26/api/v1alpha1",
k8s.io/apimachinery/pkg/api/resource, k8s.io/utils/ptr, github.com/go-kure/kure/pkg/kubernetes,
and fmt for the line that prints what the example built.
Constructors
Every kind this package registers has a generated Create<Kind> wrapper in zz_generated_create.go, produced from the scheme by pkg/kubernetes/internal/gen (make gen-builders, checked by make check-builders in CI). A wrapper delegates to kubernetes.Create[T] and emits TypeMeta and identity only: no default, no label, no spec value. The spec is the caller’s own field assignment:
The package has no Set* or Add* helpers: no field of these kinds needs one that the builder contract
admits. Labels and annotations use the generic kubernetes.AddLabel and kubernetes.AddAnnotation.
The upstream structs embed several sub-structs by value, so a zero sub-struct is still written out: a MariaDB with Galera: &Galera{Enabled: true} serializes galera.agent: {} and galera.initContainer.image: "". The operator’s CRD admits these, and testdata/mariadb.yaml shows the exact output.
The kinds this package registers, their scope, and what stated that scope are rows in the generated Supported kinds and field maturity tables.
SQL objects
A Database, a User and a Grant each point at their MariaDB through MariaDBRef:
Validation
The golden tests (golden_test.go) build a MariaDB, a Backup, a PhysicalBackup, a Restore and a SqlJob, and hold each one to the CustomResourceDefinition the pinned operator release ships before comparing it with its fixture under testdata/.
Related Packages
- kubernetes-builders — broader resource builder family
- cnpg — CloudNativePG, the PostgreSQL operator builders
- Compatibility matrix — the operator version these builders are pinned to