Skip to content

Commit 739ba3d

Browse files
dilyevskyclaude
andcommitted
[api] add core/v1alpha3 with per-record TTL Domain types
Introduce v1alpha3 as the new storage version for Domain and DomainZone, with per-record TTL support via typed DNS record substructs (DNSAddressRecords, DNSCNAMERecord, etc.) instead of flat string slices. - Create api/core/v1alpha3 package with Domain, DomainZone, shared types - Make v1alpha2 and v1alpha spoke versions converting through v1alpha3 hub - Add cross-version v1alpha<->v1alpha2 conversion functions chaining through v1alpha3, since the k8s scheme does not support multi-hop conversion - Register cross-version conversions on both the apiserver builder scheme (via WithAdditionalSchemeInstallers) and the controller-runtime scheme - Run codegen for deepcopy, register, clients, listers, informers, openapi Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d314fc0 commit 739ba3d

37 files changed

+5348
-164
lines changed

api/core/v1alpha/domain_conversion.go

Lines changed: 227 additions & 139 deletions
Large diffs are not rendered by default.

api/core/v1alpha/domain_types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"k8s.io/apiserver/pkg/registry/rest"
1010
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
1111

12-
v1alpha2 "github.com/apoxy-dev/apoxy/api/core/v1alpha2"
12+
v1alpha3 "github.com/apoxy-dev/apoxy/api/core/v1alpha3"
1313
)
1414

1515
const (
@@ -309,31 +309,31 @@ func (a *Domain) GetStatus() resource.StatusSubResource {
309309
var _ resource.MultiVersionObject = &Domain{}
310310

311311
func (a *Domain) NewStorageVersionObject() runtime.Object {
312-
return &v1alpha2.Domain{}
312+
return &v1alpha3.Domain{}
313313
}
314314

315315
func (a *Domain) ConvertToStorageVersion(storageObj runtime.Object) error {
316-
obj, ok := storageObj.(*v1alpha2.Domain)
316+
obj, ok := storageObj.(*v1alpha3.Domain)
317317
if !ok {
318-
return errors.New("failed to convert to v1alpha2 Domain")
318+
return errors.New("failed to convert to v1alpha3 Domain")
319319
}
320320

321321
obj.ObjectMeta = *a.ObjectMeta.DeepCopy()
322-
obj.Spec = *convertDomainSpecFromV1Alpha1ToV1Alpha2(&a.Spec)
323-
obj.Status = *convertDomainStatusFromV1Alpha1ToV1Alpha2(&a.Status)
322+
obj.Spec = *convertDomainSpecFromV1Alpha1ToV1Alpha3(&a.Spec)
323+
obj.Status = *convertDomainStatusFromV1Alpha1ToV1Alpha3(&a.Status)
324324

325325
return nil
326326
}
327327

328328
func (a *Domain) ConvertFromStorageVersion(storageObj runtime.Object) error {
329-
obj, ok := storageObj.(*v1alpha2.Domain)
329+
obj, ok := storageObj.(*v1alpha3.Domain)
330330
if !ok {
331-
return errors.New("failed to convert from v1alpha2 Domain")
331+
return errors.New("failed to convert from v1alpha3 Domain")
332332
}
333333

334334
a.ObjectMeta = *obj.ObjectMeta.DeepCopy()
335-
a.Spec = *convertDomainSpecFromV1Alpha2ToV1Alpha1(&obj.Spec)
336-
a.Status = *convertDomainStatusFromV1Alpha2ToV1Alpha1(&obj.Status)
335+
a.Spec = *convertDomainSpecFromV1Alpha3ToV1Alpha1(&obj.Spec)
336+
a.Status = *convertDomainStatusFromV1Alpha3ToV1Alpha1(&obj.Status)
337337

338338
return nil
339339
}

api/core/v1alpha/domain_zone_types.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"k8s.io/apiserver/pkg/registry/rest"
1010
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
1111

12-
v1alpha2 "github.com/apoxy-dev/apoxy/api/core/v1alpha2"
12+
v1alpha3 "github.com/apoxy-dev/apoxy/api/core/v1alpha3"
1313
)
1414

1515
// +kubebuilder:object:root=true
@@ -243,34 +243,34 @@ func (a *DomainZone) GetStatus() resource.StatusSubResource {
243243
var _ resource.MultiVersionObject = &DomainZone{}
244244

245245
func (a *DomainZone) NewStorageVersionObject() runtime.Object {
246-
return &v1alpha2.DomainZone{}
246+
return &v1alpha3.DomainZone{}
247247
}
248248

249249
func (a *DomainZone) ConvertToStorageVersion(storageObj runtime.Object) error {
250-
obj, ok := storageObj.(*v1alpha2.DomainZone)
250+
obj, ok := storageObj.(*v1alpha3.DomainZone)
251251
if !ok {
252-
return errors.New("failed to convert to v1alpha2 DomainZone")
252+
return errors.New("failed to convert to v1alpha3 DomainZone")
253253
}
254254

255255
obj.ObjectMeta = *a.ObjectMeta.DeepCopy()
256256

257257
// Convert Spec
258258
obj.Spec.Nameservers = a.Spec.Nameservers
259259
if a.Spec.RegistrationConfig != nil {
260-
obj.Spec.RegistrationConfig = &v1alpha2.RegistrationConfig{
260+
obj.Spec.RegistrationConfig = &v1alpha3.RegistrationConfig{
261261
AutoRenew: a.Spec.RegistrationConfig.AutoRenew,
262262
RegistrationPeriodYears: a.Spec.RegistrationConfig.RegistrationPeriodYears,
263263
}
264264
if a.Spec.RegistrationConfig.Registrant != nil {
265-
obj.Spec.RegistrationConfig.Registrant = &v1alpha2.Registrant{
265+
obj.Spec.RegistrationConfig.Registrant = &v1alpha3.Registrant{
266266
FirstName: a.Spec.RegistrationConfig.Registrant.FirstName,
267267
LastName: a.Spec.RegistrationConfig.Registrant.LastName,
268268
Email: a.Spec.RegistrationConfig.Registrant.Email,
269269
Phone: a.Spec.RegistrationConfig.Registrant.Phone,
270270
Organization: a.Spec.RegistrationConfig.Registrant.Organization,
271271
}
272272
if a.Spec.RegistrationConfig.Registrant.Address != nil {
273-
obj.Spec.RegistrationConfig.Registrant.Address = &v1alpha2.Address{
273+
obj.Spec.RegistrationConfig.Registrant.Address = &v1alpha3.Address{
274274
AddressLine1: a.Spec.RegistrationConfig.Registrant.Address.AddressLine1,
275275
AddressLine2: a.Spec.RegistrationConfig.Registrant.Address.AddressLine2,
276276
City: a.Spec.RegistrationConfig.Registrant.Address.City,
@@ -283,10 +283,10 @@ func (a *DomainZone) ConvertToStorageVersion(storageObj runtime.Object) error {
283283
}
284284

285285
// Convert Status
286-
obj.Status.Phase = v1alpha2.DomainZonePhase(a.Status.Phase)
286+
obj.Status.Phase = v1alpha3.DomainZonePhase(a.Status.Phase)
287287
obj.Status.Conditions = a.Status.Conditions
288288
if a.Status.RegistrationStatus != nil {
289-
obj.Status.RegistrationStatus = &v1alpha2.RegistrationStatus{
289+
obj.Status.RegistrationStatus = &v1alpha3.RegistrationStatus{
290290
RegistrationID: a.Status.RegistrationStatus.RegistrationID,
291291
EstimatedCost: a.Status.RegistrationStatus.EstimatedCost,
292292
PaymentURL: a.Status.RegistrationStatus.PaymentURL,
@@ -296,7 +296,7 @@ func (a *DomainZone) ConvertToStorageVersion(storageObj runtime.Object) error {
296296
}
297297
}
298298
if a.Status.Nameservers != nil {
299-
obj.Status.Nameservers = &v1alpha2.NameserverStatus{
299+
obj.Status.Nameservers = &v1alpha3.NameserverStatus{
300300
Required: a.Status.Nameservers.Required,
301301
Current: a.Status.Nameservers.Current,
302302
}
@@ -306,9 +306,9 @@ func (a *DomainZone) ConvertToStorageVersion(storageObj runtime.Object) error {
306306
}
307307

308308
func (a *DomainZone) ConvertFromStorageVersion(storageObj runtime.Object) error {
309-
obj, ok := storageObj.(*v1alpha2.DomainZone)
309+
obj, ok := storageObj.(*v1alpha3.DomainZone)
310310
if !ok {
311-
return errors.New("failed to convert from v1alpha2 DomainZone")
311+
return errors.New("failed to convert from v1alpha3 DomainZone")
312312
}
313313

314314
a.ObjectMeta = *obj.ObjectMeta.DeepCopy()

0 commit comments

Comments
 (0)