Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit 5bca955

Browse files
committed
Set context error when using invalid source value
When we encounter an invalid source value in an annotation, we need to properly set the pipeline into an error state to not continue binding operations. This reports an error back to the user that their sourceValue isn't correct. Signed-off-by: Andy Sadler <[email protected]>
1 parent 2a7d521 commit 5bca955

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pkg/reconcile/pipeline/handler/collect/impl.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import (
1818
)
1919

2020
var DataNotMap = errors.New("Returned data are not a map, skip collecting")
21+
var ErrorValueNotFound = errors.New("Value not found in map")
2122

2223
const (
2324
ErrorReadingServicesReason = "ErrorReadingServices"
2425
ErrorReadingCRD = "ErrorReadingCRD"
2526
ErrorReadingDescriptorReason = "ErrorReadingDescriptor"
2627
ErrorReadingBindingReason = "ErrorReadingBinding"
2728
ErrorReadingSecret = "ErrorReadingSecret"
29+
ValueNotFound = "ValueNotFound"
2830
)
2931

3032
func PreFlight(ctx pipeline.Context) {
@@ -254,8 +256,10 @@ func collectItems(prefix string, ctx pipeline.Context, service pipeline.Service,
254256
} else {
255257
condition := v1alpha1.Conditions().NotCollectionReady().
256258
Msg(fmt.Sprintf("Value for key %v_%v not found", prefix+k.String(), n.String())).
257-
Reason("ValueNotFound").Build()
259+
Reason(ValueNotFound).Build()
258260
ctx.SetCondition(condition)
261+
ctx.Error(ErrorValueNotFound)
262+
ctx.StopProcessing()
259263
return
260264
}
261265
}

pkg/reconcile/pipeline/handler/collect/impl_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1084,12 +1084,13 @@ var _ = Describe("Issue 943", func() {
10841084
crd.EXPECT().Resource().Return(&unstructured.Unstructured{})
10851085
service.EXPECT().CustomResourceDefinition().Return(crd, nil)
10861086

1087-
// TODO: msg must be rephrased.
10881087
ctx.EXPECT().SetCondition(
10891088
v1alpha1.Conditions().NotCollectionReady().
1090-
Reason("ValueNotFound").
1089+
Reason(collect.ValueNotFound).
10911090
Msg("Value for key java-maven_port_foo not found").
10921091
Build())
1092+
ctx.EXPECT().Error(collect.ErrorValueNotFound)
1093+
ctx.EXPECT().StopProcessing()
10931094

10941095
collect.BindingDefinitions(ctx)
10951096
collect.BindingItems(ctx)

0 commit comments

Comments
 (0)