Skip to content

Commit

Permalink
fix externaldns crd required fields (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiveerk authored Feb 14, 2025
1 parent 4e83743 commit 20a88be
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/clusterexternaldns_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func (c *ClusterExternalDNS) SetCondition(condition metav1.Condition) {
// ClusterExternalDNSSpec allows users to specify desired the state of a cluster-scoped ExternalDNS deployment.
type ClusterExternalDNSSpec struct {
// ResourceName is the name that will be used for the ExternalDNS deployment and related resources. Will default to the name of the ClusterExternalDNS resource if not specified.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9][-a-z0-9\.]*[a-z0-9]$`
// +kubebuilder:validation:Required
ResourceName string `json:"resourceName,omitempty"`
ResourceName string `json:"resourceName"`

// TenantID is the ID of the Azure tenant where the DNS zones are located.
// +kubebuilder:validation:Required
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/externaldns_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type ExternalDNSSpec struct {
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9][-a-z0-9\.]*[a-z0-9]$`
// +kubebuilder:validation:Required
ResourceName string `json:"resourceName,omitempty"`
ResourceName string `json:"resourceName"`

// TenantID is the ID of the Azure tenant where the DNS zones are located.
// +kubebuilder:validation:Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ spec:
required:
- dnsZoneResourceIDs
- identity
- resourceName
- resourceNamespace
- resourceTypes
- tenantID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ spec:
required:
- dnsZoneResourceIDs
- identity
- resourceName
- resourceTypes
- tenantID
type: object
Expand Down
12 changes: 12 additions & 0 deletions testing/e2e/suites/clusterexternaldns_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func validClusterExternalDNS() *v1alpha1.ClusterExternalDNS {
Name: "test",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand Down Expand Up @@ -97,6 +98,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "invalid-tenant",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "test",
DNSZoneResourceIDs: []string{
Expand All @@ -121,6 +123,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "no-tenant",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174001/resourceGroups/test/providers/Microsoft.network/dnszones/test",
Expand All @@ -145,6 +148,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
},
Spec: v1alpha1.ClusterExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
ResourceNamespace: "default",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174001/resourceGroups/test/providers/Microsoft.network/dnszones/test",
Expand All @@ -169,6 +173,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "diff-type",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand All @@ -194,6 +199,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "duplicate-zones",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand All @@ -219,6 +225,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "diff-rg",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand Down Expand Up @@ -266,6 +273,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "no-resourcetypes",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand All @@ -290,6 +298,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "empty-resourcetypes",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand All @@ -315,6 +324,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "invalid-resourcetypes",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand All @@ -340,6 +350,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
Name: "no-identity",
},
Spec: v1alpha1.ClusterExternalDNSSpec{
ResourceName: "test",
ResourceNamespace: "default",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
Expand All @@ -363,6 +374,7 @@ func clusterExternalDnsCrdTests(in infra.Provisioned) []test {
},
Spec: v1alpha1.ClusterExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
ResourceNamespace: "default",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
Expand Down
35 changes: 24 additions & 11 deletions testing/e2e/suites/externaldns_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func validExternalDNS() *v1alpha1.ExternalDNS {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand Down Expand Up @@ -74,7 +75,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "test",
ResourceName: "test",
TenantID: "test",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174001/resourceGroups/test/providers/Microsoft.network/dnszones/test",
},
Expand All @@ -98,6 +100,7 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
ResourceName: "test",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174001/resourceGroups/test/providers/Microsoft.network/dnszones/test",
},
Expand All @@ -121,7 +124,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174001/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand All @@ -146,7 +150,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/privatednszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
Expand All @@ -171,7 +176,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
Expand All @@ -196,7 +202,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test2/providers/Microsoft.network/dnszones/test2",
Expand All @@ -221,6 +228,7 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{},
ResourceTypes: []string{"ingress", "gateway"},
Expand All @@ -243,7 +251,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand All @@ -267,7 +276,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand All @@ -292,7 +302,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand All @@ -317,7 +328,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand All @@ -339,7 +351,8 @@ func externalDnsCrdTests(in infra.Provisioned) []test {
Namespace: "default",
},
Spec: v1alpha1.ExternalDNSSpec{
TenantID: "123e4567-e89b-12d3-a456-426614174000",
ResourceName: "test",
TenantID: "123e4567-e89b-12d3-a456-426614174000",
DNSZoneResourceIDs: []string{
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test",
"/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourceGroups/test/providers/Microsoft.network/dnszones/test2",
Expand Down

0 comments on commit 20a88be

Please sign in to comment.