Skip to content

Commit dd68cd5

Browse files
committed
Rewrite HelmRepositoryReconciler to new standards
This commit rewrites the `HelmRepositoryReconciler` to new standards, while implementing the newly introduced Condition types, and trying to adhere better to Kubernetes API conventions. More specifically it introduces: - Implementation of more explicit Condition types to highlight abnormalities. - Extensive usage of the `conditions` subpackage from `runtime`. - Better and more conflict-resilient (status)patching of reconciled objects using the `patch` subpackage from runtime. - Proper implementation of kstatus' `Reconciling` and `Stalled` conditions. - Refactoring of some Helm elements to make them easier to use within the new reconciler logic. - Integration tests that solely rely on `testenv` and do not use Ginkgo. There are a couple of TODOs marked in-code, these are suggestions for the future and should be non-blocking. In addition to the TODOs, more complex and/or edge-case test scenarios may be added as well. Signed-off-by: Hidde Beydals <[email protected]>
1 parent 5f125eb commit dd68cd5

File tree

6 files changed

+872
-625
lines changed

6 files changed

+872
-625
lines changed

api/v1beta2/helmrepository_types.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ package v1beta2
1919
import (
2020
"time"
2121

22-
apimeta "k8s.io/apimachinery/pkg/api/meta"
2322
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2423

2524
"github.com/fluxcd/pkg/apis/acl"
2625
"github.com/fluxcd/pkg/apis/meta"
27-
"github.com/fluxcd/pkg/runtime/conditions"
2826
)
2927

3028
const (
@@ -108,47 +106,6 @@ const (
108106
IndexationSucceededReason string = "IndexationSucceed"
109107
)
110108

111-
// HelmRepositoryProgressing resets the conditions of the HelmRepository to
112-
// metav1.Condition of type meta.ReadyCondition with status 'Unknown' and
113-
// meta.ProgressingReason reason and message. It returns the modified
114-
// HelmRepository.
115-
func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
116-
repository.Status.ObservedGeneration = repository.Generation
117-
repository.Status.URL = ""
118-
repository.Status.Conditions = []metav1.Condition{}
119-
conditions.MarkUnknown(&repository, meta.ReadyCondition, meta.ProgressingReason, "reconciliation in progress")
120-
return repository
121-
}
122-
123-
// HelmRepositoryReady sets the given Artifact and URL on the HelmRepository and
124-
// sets the meta.ReadyCondition to 'True', with the given reason and message. It
125-
// returns the modified HelmRepository.
126-
func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reason, message string) HelmRepository {
127-
repository.Status.Artifact = &artifact
128-
repository.Status.URL = url
129-
conditions.MarkTrue(&repository, meta.ReadyCondition, reason, message)
130-
return repository
131-
}
132-
133-
// HelmRepositoryNotReady sets the meta.ReadyCondition on the given
134-
// HelmRepository to 'False', with the given reason and message. It returns the
135-
// modified HelmRepository.
136-
func HelmRepositoryNotReady(repository HelmRepository, reason, message string) HelmRepository {
137-
conditions.MarkFalse(&repository, meta.ReadyCondition, reason, message)
138-
return repository
139-
}
140-
141-
// HelmRepositoryReadyMessage returns the message of the metav1.Condition of type
142-
// meta.ReadyCondition with status 'True' if present, or an empty string.
143-
func HelmRepositoryReadyMessage(repository HelmRepository) string {
144-
if c := apimeta.FindStatusCondition(repository.Status.Conditions, meta.ReadyCondition); c != nil {
145-
if c.Status == metav1.ConditionTrue {
146-
return c.Message
147-
}
148-
}
149-
return ""
150-
}
151-
152109
// GetConditions returns the status conditions of the object.
153110
func (in HelmRepository) GetConditions() []metav1.Condition {
154111
return in.Status.Conditions

0 commit comments

Comments
 (0)