diff --git a/pkg/reconciler/internal/updater/updater.go b/pkg/reconciler/internal/updater/updater.go index 9e66930..b1e09fd 100644 --- a/pkg/reconciler/internal/updater/updater.go +++ b/pkg/reconciler/internal/updater/updater.go @@ -26,8 +26,8 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/operator-framework/helm-operator/pkg/extensions" "github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil" + "github.com/operator-framework/helm-operator-plugins/pkg/extensions" "github.com/operator-framework/helm-operator-plugins/pkg/internal/status" ) diff --git a/pkg/reconciler/internal/updater/updater_test.go b/pkg/reconciler/internal/updater/updater_test.go index 7128d6e..7b7791d 100644 --- a/pkg/reconciler/internal/updater/updater_test.go +++ b/pkg/reconciler/internal/updater/updater_test.go @@ -32,7 +32,11 @@ import ( "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/conditions" ) -const testFinalizer = "testFinalizer" +const ( + testFinalizer = "testFinalizer" + availableReplicasStatus = int64(3) + replicasStatus = int64(5) +) var _ = Describe("Updater", func() { var ( @@ -90,12 +94,12 @@ var _ = Describe("Updater", func() { It("should support a mix of standard and custom status updates", func() { u.UpdateStatus(EnsureCondition(conditions.Deployed(corev1.ConditionTrue, "", ""))) u.UpdateStatusCustom(func(uSt *unstructured.Unstructured) bool { - Expect(unstructured.SetNestedMap(uSt.Object, map[string]interface{}{"bar": "baz"}, "foo")).To(Succeed()) + Expect(unstructured.SetNestedField(uSt.Object, replicasStatus, "replicas")).To(Succeed()) return true }) u.UpdateStatus(EnsureCondition(conditions.Irreconcilable(corev1.ConditionFalse, "", ""))) u.UpdateStatusCustom(func(uSt *unstructured.Unstructured) bool { - Expect(unstructured.SetNestedField(uSt.Object, "quux", "foo", "qux")).To(Succeed()) + Expect(unstructured.SetNestedField(uSt.Object, availableReplicasStatus, "availableReplicas")).To(Succeed()) return true }) u.UpdateStatus(EnsureCondition(conditions.Initialized(corev1.ConditionTrue, "", ""))) @@ -107,20 +111,20 @@ var _ = Describe("Updater", func() { Expect(found).To(BeFalse()) Expect(err).To(Not(HaveOccurred())) - val, found, err := unstructured.NestedString(obj.Object, "status", "foo", "bar") - Expect(val).To(Equal("baz")) + val, found, err := unstructured.NestedInt64(obj.Object, "status", "replicas") + Expect(val).To(Equal(replicasStatus)) Expect(found).To(BeTrue()) Expect(err).To(Not(HaveOccurred())) - val, found, err = unstructured.NestedString(obj.Object, "status", "foo", "qux") - Expect(val).To(Equal("quux")) + val, found, err = unstructured.NestedInt64(obj.Object, "status", "availableReplicas") + Expect(val).To(Equal(availableReplicasStatus)) Expect(found).To(BeTrue()) Expect(err).To(Not(HaveOccurred())) }) It("should preserve any custom status across multiple apply calls", func() { u.UpdateStatusCustom(func(uSt *unstructured.Unstructured) bool { - Expect(unstructured.SetNestedMap(uSt.Object, map[string]interface{}{"bar": "baz"}, "foo")).To(Succeed()) + Expect(unstructured.SetNestedField(uSt.Object, int64(5), "replicas")).To(Succeed()) return true }) Expect(u.Apply(context.TODO(), obj)).To(Succeed()) @@ -131,8 +135,8 @@ var _ = Describe("Updater", func() { Expect(found).To(BeFalse()) Expect(err).To(Not(HaveOccurred())) - val, found, err := unstructured.NestedString(obj.Object, "status", "foo", "bar") - Expect(val).To(Equal("baz")) + val, found, err := unstructured.NestedInt64(obj.Object, "status", "replicas") + Expect(val).To(Equal(replicasStatus)) Expect(found).To(BeTrue()) Expect(err).To(Succeed()) @@ -146,8 +150,8 @@ var _ = Describe("Updater", func() { Expect(found).To(BeFalse()) Expect(err).To(Not(HaveOccurred())) - val, found, err = unstructured.NestedString(obj.Object, "status", "foo", "bar") - Expect(val).To(Equal("baz")) + val, found, err = unstructured.NestedInt64(obj.Object, "status", "replicas") + Expect(val).To(Equal(replicasStatus)) Expect(found).To(BeTrue()) Expect(err).To(Succeed()) }) diff --git a/pkg/reconciler/reconciler.go b/pkg/reconciler/reconciler.go index 3d1e1f3..53a52ea 100644 --- a/pkg/reconciler/reconciler.go +++ b/pkg/reconciler/reconciler.go @@ -43,20 +43,19 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" - "sigs.k8s.io/controller-runtime/pkg/predicate" ctrlpredicate "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" "github.com/operator-framework/helm-operator-plugins/internal/sdk/controllerutil" "github.com/operator-framework/helm-operator-plugins/pkg/annotation" helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" + "github.com/operator-framework/helm-operator-plugins/pkg/extensions" "github.com/operator-framework/helm-operator-plugins/pkg/hook" "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/conditions" internalhook "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/hook" "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/updater" internalvalues "github.com/operator-framework/helm-operator-plugins/pkg/reconciler/internal/values" "github.com/operator-framework/helm-operator-plugins/pkg/values" - "github.com/joelanford/helm-operator/pkg/extensions" ) const uninstallFinalizer = "uninstall-helm-release" @@ -80,10 +79,10 @@ type Reconciler struct { selectorPredicate predicate.Predicate overrideValues map[string]string skipDependentWatches bool - extraWatches []watchDescription + extraWatches []watchDescription maxConcurrentReconciles int reconcilePeriod time.Duration - markFailedAfter time.Duration + markFailedAfter time.Duration maxHistory int skipPrimaryGVKSchemeRegistration bool