9da206dc7c
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.
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package reflect2
|
|
|
|
import (
|
|
"reflect"
|
|
"unsafe"
|
|
)
|
|
|
|
type UnsafeStructType struct {
|
|
unsafeType
|
|
likePtr bool
|
|
}
|
|
|
|
func newUnsafeStructType(cfg *frozenConfig, type1 reflect.Type) *UnsafeStructType {
|
|
return &UnsafeStructType{
|
|
unsafeType: *newUnsafeType(cfg, type1),
|
|
likePtr: likePtrType(type1),
|
|
}
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) LikePtr() bool {
|
|
return type2.likePtr
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) Indirect(obj interface{}) interface{} {
|
|
objEFace := unpackEFace(obj)
|
|
assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype)
|
|
return type2.UnsafeIndirect(objEFace.data)
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
|
|
if type2.likePtr {
|
|
return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr))
|
|
}
|
|
return packEFace(type2.rtype, ptr)
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) FieldByName(name string) StructField {
|
|
structField, found := type2.Type.FieldByName(name)
|
|
if !found {
|
|
return nil
|
|
}
|
|
return newUnsafeStructField(type2, structField)
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) Field(i int) StructField {
|
|
return newUnsafeStructField(type2, type2.Type.Field(i))
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) FieldByIndex(index []int) StructField {
|
|
return newUnsafeStructField(type2, type2.Type.FieldByIndex(index))
|
|
}
|
|
|
|
func (type2 *UnsafeStructType) FieldByNameFunc(match func(string) bool) StructField {
|
|
structField, found := type2.Type.FieldByNameFunc(match)
|
|
if !found {
|
|
panic("field match condition not found in " + type2.Type.String())
|
|
}
|
|
return newUnsafeStructField(type2, structField)
|
|
}
|