Files
unkin-agent 9da206dc7c Implement autobackup-operator controllers, tests, CI and packaging
PVCs and CloudNativePG Clusters need S3 buckets and backup schedules
provisioned consistently. This operator watches the
backups.unkin.net/{schedule,destination} annotations on those objects and
provisions everything needed to back them up, with no new CRDs.

- Add a PVC controller that provisions cephrgw ObjectStoreUser/Bucket/BucketAccess,
  auto-generates a restic repo-password Secret and creates a k8up Schedule scoped
  to the PVC via spec.backup.volumes[].persistentVolumeClaim.claimName.
- Add a CNPG Cluster controller that provisions the same bucket stack, idempotently
  patches spec.backup.barmanObjectStore (leaving a user-set destinationPath alone
  with a Warning event) and creates a ScheduledBackup.
- Resolve destinations through a ConfigMap lookup table; requeue until the
  BucketAccess is Ready before creating schedule resources; own-reference created
  resources and retain bucket data by default.
- Add schedule-mapping helpers (k8up 5-field/shortcut pass-through, CNPG 6-field
  seconds-first) and deterministic, length-bounded name derivation.
- Add unit tests (schedule mapping, name derivation, destination resolution) and
  envtest controller tests for both paths, wiring the external CRDs into envtest.
- Add kubebuilder-generated RBAC, a Dockerfile (distroless/nonroot), Woodpecker
  lint/test/build pipelines and a tag-triggered image push to the artifactapi
  docker-internal registry, plus a version-bump Makefile and deploy manifests.
2026-08-14 00:08:37 +10:00

89 lines
3.0 KiB
Go

package common
// RouteContainer is the entrypoint for a service, which may contain multiple
// routes under a common path with a common set of path parameters.
type RouteContainer interface {
// RootPath is the path that all contained routes are nested under.
RootPath() string
// PathParameters are common parameters defined in the root path.
PathParameters() []Parameter
// Routes are all routes exposed under the root path.
Routes() []Route
}
// Route is a logical endpoint of a service.
type Route interface {
// Method defines the HTTP Method.
Method() string
// Path defines the route's endpoint.
Path() string
// OperationName defines a machine-readable ID for the route.
OperationName() string
// Parameters defines the list of accepted parameters.
Parameters() []Parameter
// Description is a human-readable route description.
Description() string
// Consumes defines the consumed content-types.
Consumes() []string
// Produces defines the produced content-types.
Produces() []string
// Metadata allows adding extensions to the generated spec.
Metadata() map[string]interface{}
// RequestPayloadSample defines an example request payload. Can return nil.
RequestPayloadSample() interface{}
// ResponsePayloadSample defines an example response payload. Can return nil.
ResponsePayloadSample() interface{}
// StatusCodeResponses defines a mapping of HTTP Status Codes to the specific response(s).
// Multiple responses with the same HTTP Status Code are acceptable.
StatusCodeResponses() []StatusCodeResponse
}
// StatusCodeResponse is an explicit response type with an HTTP Status Code.
type StatusCodeResponse interface {
// Code defines the HTTP Status Code.
Code() int
// Message returns the human-readable message.
Message() string
// Model defines an example payload for this response.
Model() interface{}
}
// Parameter is a Route parameter.
type Parameter interface {
// Name defines the unique-per-route identifier.
Name() string
// Description is the human-readable description of the param.
Description() string
// Required defines if this parameter must be provided.
Required() bool
// Kind defines the type of the parameter itself.
Kind() ParameterKind
// DataType defines the type of data the parameter carries.
DataType() string
// AllowMultiple defines if more than one value can be supplied for the parameter.
AllowMultiple() bool
}
// ParameterKind is an enum of route parameter types.
type ParameterKind int
const (
// PathParameterKind indicates the request parameter type is "path".
PathParameterKind = ParameterKind(iota)
// QueryParameterKind indicates the request parameter type is "query".
QueryParameterKind
// BodyParameterKind indicates the request parameter type is "body".
BodyParameterKind
// HeaderParameterKind indicates the request parameter type is "header".
HeaderParameterKind
// FormParameterKind indicates the request parameter type is "form".
FormParameterKind
// UnknownParameterKind indicates the request parameter type has not been specified.
UnknownParameterKind
)