Better error reporting for image policy evaluation
A more verbose message associated with the error should give the user better understanding of the cause and the nature of the failure. Fixes #143 Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
parent
de3de64add
commit
746f61edb3
|
@ -158,7 +158,7 @@ func (r *ImagePolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||||
}
|
}
|
||||||
|
|
||||||
if latest == "" {
|
if latest == "" {
|
||||||
msg := "no image found for policy"
|
msg := fmt.Sprintf("Cannot determine latest tag for policy: %s", err.Error())
|
||||||
pol.Status.LatestImage = ""
|
pol.Status.LatestImage = ""
|
||||||
imagev1.SetImagePolicyReadiness(
|
imagev1.SetImagePolicyReadiness(
|
||||||
&pol,
|
&pol,
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (p *Numerical) Latest(versions []string) (string, error) {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case i == 0:
|
case i == 0:
|
||||||
break // First iteration, nothing to compare
|
// First iteration, nothing to compare
|
||||||
case p.Order == NumericalOrderAsc && cv < pv, p.Order == NumericalOrderDesc && cv > pv:
|
case p.Order == NumericalOrderAsc && cv < pv, p.Order == NumericalOrderDesc && cv > pv:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,11 @@ func TestNumerical_Latest(t *testing.T) {
|
||||||
order: NumericalOrderDesc,
|
order: NumericalOrderDesc,
|
||||||
expectedVersion: "1",
|
expectedVersion: "1",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "With invalid numerical value",
|
||||||
|
versions: []string{"0", "1a", "b"},
|
||||||
|
expectErr: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Empty version list",
|
label: "Empty version list",
|
||||||
versions: []string{},
|
versions: []string{},
|
||||||
|
|
Loading…
Reference in New Issue