Skip to content

Commit 8400ed9

Browse files
committed
resourcegroup: use default KroDomainName when group is empty
Add fallback to KroDomainName when group is not specified in resource group controller and CRD synthesis. This ensures consistent behavior when creating CRDs without an explicit group name. The change affects two components: - ResourceGroup reconciler: Set default group during cleanup - CRD synthesis: Use default group when generating new CRDs
1 parent 2d1a2f8 commit 8400ed9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/controller/resourcegroup/controller_cleanup.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ func (r *ResourceGroupReconciler) cleanupResourceGroup(ctx context.Context, rg *
4040
return fmt.Errorf("failed to shutdown microcontroller: %w", err)
4141
}
4242

43+
group := rg.Spec.Schema.Group
44+
if group == "" {
45+
group = v1alpha1.KroDomainName
46+
}
4347
// cleanup CRD
44-
crdName := extractCRDName(rg.Spec.Schema.Group, rg.Spec.Schema.Kind)
48+
crdName := extractCRDName(group, rg.Spec.Schema.Kind)
4549
if err := r.cleanupResourceGroupCRD(ctx, crdName); err != nil {
4650
return fmt.Errorf("failed to cleanup CRD %s: %w", crdName, err)
4751
}

pkg/graph/crd/crd.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"fmt"
1818
"strings"
1919

20+
"github.com/awslabs/kro/api/v1alpha1"
2021
"github.com/gobuffalo/flect"
2122
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -25,7 +26,11 @@ import (
2526
// SynthesizeCRD generates a CustomResourceDefinition for a given API version and kind
2627
// with the provided spec and status schemas~
2728
func SynthesizeCRD(group, apiVersion, kind string, spec, status extv1.JSONSchemaProps, statusFieldsOverride bool) *extv1.CustomResourceDefinition {
28-
return newCRD(group, apiVersion, kind, newCRDSchema(spec, status, statusFieldsOverride))
29+
crdGroup := group
30+
if crdGroup == "" {
31+
crdGroup = v1alpha1.KroDomainName
32+
}
33+
return newCRD(crdGroup, apiVersion, kind, newCRDSchema(spec, status, statusFieldsOverride))
2934
}
3035

3136
func newCRD(group, apiVersion, kind string, schema *extv1.JSONSchemaProps) *extv1.CustomResourceDefinition {

0 commit comments

Comments
 (0)