Skip to content

Commit b078847

Browse files
authored
Merge pull request #43 from fluxcd/progressing-status
status: record progressing as intermediate state
2 parents 9af721f + 8071dad commit b078847

8 files changed

+76
-2
lines changed

api/v1alpha1/condition_types.go

+4
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ const (
6969
// VerificationFailedReason represents the fact that the cryptographic provenance
7070
// verification for the source failed.
7171
VerificationFailedReason string = "VerificationFailed"
72+
73+
// ProgressingReason represents the fact that a source reconciliation
74+
// is underway.
75+
ProgressingReason string = "Progressing"
7276
)

api/v1alpha1/gitrepository_types.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const (
113113
)
114114

115115
// GitRepositoryReady sets the given artifact and url on the
116-
// HelmRepository and resets the conditions to SourceCondition of
116+
// GitRepository and resets the conditions to SourceCondition of
117117
// type Ready with status true and the given reason and message.
118118
// It returns the modified GitRepository.
119119
func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason, message string) GitRepository {
@@ -139,7 +139,23 @@ func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason
139139
return repository
140140
}
141141

142-
// GitRepositoryNotReady resets the conditions of the HelmRepository
142+
// GitRepositoryProgressing resets the conditions of the GitRepository
143+
// to SourceCondition of type Ready with status unknown and
144+
// progressing reason and message. It returns the modified GitRepository.
145+
func GitRepositoryProgressing(repository GitRepository) GitRepository {
146+
repository.Status.Conditions = []SourceCondition{
147+
{
148+
Type: ReadyCondition,
149+
Status: corev1.ConditionUnknown,
150+
LastTransitionTime: metav1.Now(),
151+
Reason: ProgressingReason,
152+
Message: "reconciliation in progress",
153+
},
154+
}
155+
return repository
156+
}
157+
158+
// GitRepositoryNotReady resets the conditions of the GitRepository
143159
// to SourceCondition of type Ready with status false and the given
144160
// reason and message. It returns the modified GitRepository.
145161
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {

api/v1alpha1/helmchart_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message str
9393
return chart
9494
}
9595

96+
// HelmChartProgressing resets the conditions of the HelmChart
97+
// to SourceCondition of type Ready with status unknown and
98+
// progressing reason and message. It returns the modified HelmChart.
99+
func HelmChartProgressing(chart HelmChart) HelmChart {
100+
chart.Status.Conditions = []SourceCondition{
101+
{
102+
Type: ReadyCondition,
103+
Status: corev1.ConditionUnknown,
104+
LastTransitionTime: metav1.Now(),
105+
Reason: ProgressingReason,
106+
Message: "reconciliation in progress",
107+
},
108+
}
109+
return chart
110+
}
111+
96112
// HelmChartNotReady resets the conditions of the HelmChart to
97113
// SourceCondition of type Ready with status false and the given
98114
// reason and message. It returns the modified HelmChart.

api/v1alpha1/helmrepository_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reas
9292
return repository
9393
}
9494

95+
// HelmRepositoryProgressing resets the conditions of the HelmRepository
96+
// to SourceCondition of type Ready with status unknown and
97+
// progressing reason and message. It returns the modified HelmRepository.
98+
func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
99+
repository.Status.Conditions = []SourceCondition{
100+
{
101+
Type: ReadyCondition,
102+
Status: corev1.ConditionUnknown,
103+
LastTransitionTime: metav1.Now(),
104+
Reason: ProgressingReason,
105+
Message: "reconciliation in progress",
106+
},
107+
}
108+
return repository
109+
}
110+
95111
// HelmRepositoryNotReady resets the conditions of the HelmRepository
96112
// to SourceCondition of type Ready with status false and the given
97113
// reason and message. It returns the modified HelmRepository.

controllers/gitrepository_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
6868
log.Error(err, "unable to update GitRepository status")
6969
return ctrl.Result{Requeue: true}, err
7070
}
71+
} else {
72+
repo = sourcev1.GitRepositoryProgressing(repo)
73+
if err := r.Status().Update(ctx, &repo); err != nil {
74+
log.Error(err, "unable to update GitRepository status")
75+
return ctrl.Result{Requeue: true}, err
76+
}
7177
}
7278

7379
// try to remove old artifacts

controllers/helmchart_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
6868
log.Error(err, "unable to update HelmChart status")
6969
return ctrl.Result{Requeue: true}, err
7070
}
71+
} else {
72+
chart = sourcev1.HelmChartProgressing(chart)
73+
if err := r.Status().Update(ctx, &chart); err != nil {
74+
log.Error(err, "unable to update HelmChart status")
75+
return ctrl.Result{Requeue: true}, err
76+
}
7177
}
7278

7379
// try to remove old artifacts

controllers/helmrepository_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
7070
log.Error(err, "unable to update HelmRepository status")
7171
return ctrl.Result{Requeue: true}, err
7272
}
73+
} else {
74+
repository = sourcev1.HelmRepositoryProgressing(repository)
75+
if err := r.Status().Update(ctx, &repository); err != nil {
76+
log.Error(err, "unable to update HelmRepository status")
77+
return ctrl.Result{Requeue: true}, err
78+
}
7379
}
7480

7581
// try to remove old artifacts

docs/spec/v1alpha1/common.md

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ const (
138138
// VerificationFailedReason represents the fact that the cryptographic provenance
139139
// verification for the source failed.
140140
VerificationFailedReason string = "VerificationFailed"
141+
142+
// ProgressingReason represents the fact that a source reconciliation
143+
// is underway.
144+
ProgressingReason string = "Progressing"
141145
)
142146
```
143147

0 commit comments

Comments
 (0)