Skip to content

Commit

Permalink
WIP first conditions done
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasheed Abdul-Aziz committed Sep 3, 2021
1 parent be1542f commit a621a39
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
7 changes: 7 additions & 0 deletions pkg/apis/v1alpha1/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ import (

const (
PipelineReady = "Ready"
RunTemplateReady = "RunTemplateReady"
)

const (
ReadyRunTemplateReason = "Ready"
NotFoundRunTemplateReason = "RunTemplateNotFound"
)


// +kubebuilder:object:root=true

type Pipeline struct {
Expand Down
9 changes: 0 additions & 9 deletions pkg/apis/v1alpha1/run_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

const (
RunTemplateReady = "Ready"
)

const (
ReadyRunTemplateReason = "Ready"
NotFoundRunTemplateReason = "RunTemplateNotFound"
)

// +kubebuilder:object:root=true

type RunTemplate struct {
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/pipeline/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ func (r *Reconciler) realize(request ctrl.Request, logger logr.Logger) {
})

if err != nil {
logger.Error(err, fmt.Sprintf("could not get RunTemplate '%s'", pipeline.Spec.RunTemplateName))
errorMessage := fmt.Sprintf("could not get RunTemplate '%s'", pipeline.Spec.RunTemplateName)
logger.Error(err, errorMessage)

conditionManager.AddPositive(RunTemplateMissingCondition(err))
conditionManager.AddPositive(RunTemplateMissingCondition(fmt.Errorf("%s: %w",errorMessage,err)))
pipeline.Status.Conditions, _ = conditionManager.Finalize()
_ = r.Repository.StatusUpdate(pipeline)
_ = r.Repository.StatusUpdate(pipeline) // FIXME: deal with errors!

return
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/pipeline/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ var _ = FDescribe("Reconcile", func() {
Expect(statusObject.Name).To(Equal("my-pipeline"))

Expect(statusObject.Status.Conditions).To(ContainElements(
MatchFields(0, Fields{
MatchFields(IgnoreExtras, Fields{
"Type": Equal("Ready"),
"Status": Equal(metav1.ConditionFalse),
"Reason": Equal("RunTemplateNotFound"),
"Message": Equal("could not get RunTemplate 'my-run-template'"),
"Reason": Equal("ConditionsUnmet"),
"Message": Equal("not all conditions are met"),
}),
MatchFields(0, Fields{
MatchFields(IgnoreExtras, Fields{
"Type": Equal("RunTemplateReady"),
"Status": Equal(metav1.ConditionFalse),
"Reason": Equal("RunTemplateNotFound"),
"Message": Equal("could not get RunTemplate 'my-run-template'"), // fixme full error?
"Message": Equal("could not get RunTemplate 'my-run-template': Errol mcErrorFace"),
}),
))
})
Expand Down

0 comments on commit a621a39

Please sign in to comment.