-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from mikenairn/48_use_txt_registry
registry: Use txt registry for owned records
- Loading branch information
Showing
11 changed files
with
761 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,12 @@ require ( | |
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect | ||
sigs.k8s.io/yaml v1.4.0 // indirect | ||
) | ||
|
||
replace sigs.k8s.io/external-dns => github.com/kuadrant/external-dns v0.0.0-20240315162317-073094ed9bea | ||
|
||
// To Update with changes from v0.14.0_kuadrant run: | ||
// go mod edit --replace sigs.k8s.io/external-dns=github.com/kuadrant/[email protected]_kuadrant | ||
// go mod tidy | ||
|
||
// To Update for local development | ||
// go mod edit --replace sigs.k8s.io/external-dns=/home/mnairn/go/src/github.com/kubernetes-sigs/external-dns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
//go:build integration | ||
|
||
/* | ||
Copyright 2024. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package controller | ||
|
||
import ( | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gstruct" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/utils/ptr" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
externaldnsendpoint "sigs.k8s.io/external-dns/endpoint" | ||
|
||
"github.com/kuadrant/dns-operator/api/v1alpha1" | ||
"github.com/kuadrant/dns-operator/internal/common/conditions" | ||
) | ||
|
||
var _ = Describe("DNSRecordReconciler", func() { | ||
var dnsRecord *v1alpha1.DNSRecord | ||
var managedZone *v1alpha1.ManagedZone | ||
var testNamespace string | ||
|
||
BeforeEach(func() { | ||
CreateNamespace(&testNamespace) | ||
|
||
managedZone = testBuildManagedZone("mz-example-com", testNamespace, "example.com") | ||
Expect(k8sClient.Create(ctx, managedZone)).To(Succeed()) | ||
|
||
dnsRecord = &v1alpha1.DNSRecord{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "foo.example.com", | ||
Namespace: testNamespace, | ||
}, | ||
Spec: v1alpha1.DNSRecordSpec{ | ||
ManagedZoneRef: &v1alpha1.ManagedZoneReference{ | ||
Name: managedZone.Name, | ||
}, | ||
Endpoints: []*externaldnsendpoint.Endpoint{ | ||
{ | ||
DNSName: "foo.example.com", | ||
Targets: []string{ | ||
"127.0.0.1", | ||
}, | ||
RecordType: "A", | ||
SetIdentifier: "", | ||
RecordTTL: 60, | ||
Labels: nil, | ||
ProviderSpecific: nil, | ||
}, | ||
}, | ||
}, | ||
} | ||
}) | ||
|
||
AfterEach(func() { | ||
if dnsRecord != nil { | ||
err := k8sClient.Delete(ctx, dnsRecord) | ||
Expect(client.IgnoreNotFound(err)).ToNot(HaveOccurred()) | ||
} | ||
if managedZone != nil { | ||
err := k8sClient.Delete(ctx, managedZone) | ||
Expect(client.IgnoreNotFound(err)).ToNot(HaveOccurred()) | ||
} | ||
}) | ||
|
||
It("should have ready condition with status true", func() { | ||
Expect(k8sClient.Create(ctx, dnsRecord)).To(Succeed()) | ||
Eventually(func(g Gomega) { | ||
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsRecord), dnsRecord) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(dnsRecord.Status.Conditions).To( | ||
ContainElement(MatchFields(IgnoreExtras, Fields{ | ||
"Type": Equal(string(conditions.ConditionTypeReady)), | ||
"Status": Equal(metav1.ConditionTrue), | ||
"Reason": Equal("ProviderSuccess"), | ||
"Message": Equal("Provider ensured the dns record"), | ||
"ObservedGeneration": Equal(dnsRecord.Generation), | ||
})), | ||
) | ||
g.Expect(dnsRecord.Finalizers).To(ContainElement(DNSRecordFinalizer)) | ||
}, TestTimeoutMedium, time.Second).Should(Succeed()) | ||
}) | ||
|
||
It("should not allow ownerID to be updated once set", func() { | ||
Expect(k8sClient.Create(ctx, dnsRecord)).To(BeNil()) | ||
|
||
Eventually(func(g Gomega) { | ||
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsRecord), dnsRecord) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(dnsRecord.Status.Conditions).To( | ||
ContainElement(MatchFields(IgnoreExtras, Fields{ | ||
"Type": Equal(string(conditions.ConditionTypeReady)), | ||
"Status": Equal(metav1.ConditionTrue), | ||
"Reason": Equal("ProviderSuccess"), | ||
"Message": Equal("Provider ensured the dns record"), | ||
"ObservedGeneration": Equal(dnsRecord.Generation), | ||
})), | ||
) | ||
g.Expect(dnsRecord.Finalizers).To(ContainElement(DNSRecordFinalizer)) | ||
}, TestTimeoutMedium, time.Second).Should(Succeed()) | ||
|
||
//Allows updating from not owned to owned | ||
Eventually(func(g Gomega) { | ||
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsRecord), dnsRecord) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
|
||
dnsRecord.Spec.OwnerID = ptr.To("foobar") | ||
err = k8sClient.Update(ctx, dnsRecord) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
}, TestTimeoutMedium, time.Second).Should(Succeed()) | ||
|
||
//Does not allow ownerID to change once set | ||
Eventually(func(g Gomega) { | ||
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsRecord), dnsRecord) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(dnsRecord.Spec.OwnerID).To(PointTo(Equal("foobar"))) | ||
|
||
dnsRecord.Spec.OwnerID = ptr.To("foobarbaz") | ||
err = k8sClient.Update(ctx, dnsRecord) | ||
g.Expect(err).To(MatchError(ContainSubstring("OwnerID is immutable"))) | ||
|
||
err = k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsRecord), dnsRecord) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(dnsRecord.Spec.OwnerID).To(PointTo(Equal("foobar"))) | ||
}, TestTimeoutMedium, time.Second).Should(Succeed()) | ||
|
||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.