Skip to content

Commit

Permalink
Merge pull request #43 from fluxcd/progressing-status
Browse files Browse the repository at this point in the history
status: record progressing as intermediate state
  • Loading branch information
stefanprodan authored Apr 27, 2020
2 parents 9af721f + 8071dad commit b078847
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@ const (
// VerificationFailedReason represents the fact that the cryptographic provenance
// verification for the source failed.
VerificationFailedReason string = "VerificationFailed"

// ProgressingReason represents the fact that a source reconciliation
// is underway.
ProgressingReason string = "Progressing"
)
20 changes: 18 additions & 2 deletions api/v1alpha1/gitrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const (
)

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

// GitRepositoryNotReady resets the conditions of the HelmRepository
// GitRepositoryProgressing resets the conditions of the GitRepository
// to SourceCondition of type Ready with status unknown and
// progressing reason and message. It returns the modified GitRepository.
func GitRepositoryProgressing(repository GitRepository) GitRepository {
repository.Status.Conditions = []SourceCondition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return repository
}

// GitRepositoryNotReady resets the conditions of the GitRepository
// to SourceCondition of type Ready with status false and the given
// reason and message. It returns the modified GitRepository.
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/helmchart_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message str
return chart
}

// HelmChartProgressing resets the conditions of the HelmChart
// to SourceCondition of type Ready with status unknown and
// progressing reason and message. It returns the modified HelmChart.
func HelmChartProgressing(chart HelmChart) HelmChart {
chart.Status.Conditions = []SourceCondition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return chart
}

// HelmChartNotReady resets the conditions of the HelmChart to
// SourceCondition of type Ready with status false and the given
// reason and message. It returns the modified HelmChart.
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/helmrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reas
return repository
}

// HelmRepositoryProgressing resets the conditions of the HelmRepository
// to SourceCondition of type Ready with status unknown and
// progressing reason and message. It returns the modified HelmRepository.
func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
repository.Status.Conditions = []SourceCondition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return repository
}

// HelmRepositoryNotReady resets the conditions of the HelmRepository
// to SourceCondition of type Ready with status false and the given
// reason and message. It returns the modified HelmRepository.
Expand Down
6 changes: 6 additions & 0 deletions controllers/gitrepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
log.Error(err, "unable to update GitRepository status")
return ctrl.Result{Requeue: true}, err
}
} else {
repo = sourcev1.GitRepositoryProgressing(repo)
if err := r.Status().Update(ctx, &repo); err != nil {
log.Error(err, "unable to update GitRepository status")
return ctrl.Result{Requeue: true}, err
}
}

// try to remove old artifacts
Expand Down
6 changes: 6 additions & 0 deletions controllers/helmchart_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
log.Error(err, "unable to update HelmChart status")
return ctrl.Result{Requeue: true}, err
}
} else {
chart = sourcev1.HelmChartProgressing(chart)
if err := r.Status().Update(ctx, &chart); err != nil {
log.Error(err, "unable to update HelmChart status")
return ctrl.Result{Requeue: true}, err
}
}

// try to remove old artifacts
Expand Down
6 changes: 6 additions & 0 deletions controllers/helmrepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
log.Error(err, "unable to update HelmRepository status")
return ctrl.Result{Requeue: true}, err
}
} else {
repository = sourcev1.HelmRepositoryProgressing(repository)
if err := r.Status().Update(ctx, &repository); err != nil {
log.Error(err, "unable to update HelmRepository status")
return ctrl.Result{Requeue: true}, err
}
}

// try to remove old artifacts
Expand Down
4 changes: 4 additions & 0 deletions docs/spec/v1alpha1/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ const (
// VerificationFailedReason represents the fact that the cryptographic provenance
// verification for the source failed.
VerificationFailedReason string = "VerificationFailed"

// ProgressingReason represents the fact that a source reconciliation
// is underway.
ProgressingReason string = "Progressing"
)
```

Expand Down

0 comments on commit b078847

Please sign in to comment.