Skip to content

Commit

Permalink
log validation errors separately in deployableByOLM check
Browse files Browse the repository at this point in the history
Signed-off-by: Jose R. Gonzalez <jose@flutes.dev>
  • Loading branch information
komish authored and acornett21 committed Dec 5, 2022
1 parent c6fa6f6 commit 213d62b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion certification/internal/policy/operator/deployable_by_olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/operator-framework/api/pkg/manifests"
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
validationerrors "github.com/operator-framework/api/pkg/validation/errors"
log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -108,10 +109,22 @@ func (p *DeployableByOlmCheck) Validate(ctx context.Context, bundleRef certifica
return false, fmt.Errorf("%v", err)
}
p.initOpenShifeEngine()
if report, err := bundle.Validate(ctx, bundleRef.ImageFSPath); err != nil || !report.Passed {
report, err := bundle.Validate(ctx, bundleRef.ImageFSPath)
if err != nil {
return false, fmt.Errorf("%v", err)
}

if !report.Passed { // validation didn't throw an error, but it also didn't pass.
erroredValidations := []validationerrors.ManifestResult{}
for _, r := range report.Results {
if r.HasError() {
erroredValidations = append(erroredValidations, r)
}
}

return false, fmt.Errorf("the bundle cannot be deployed because deployment validation has failed: %+v", erroredValidations)
}

// gather the list of registry and pod images
beforeOperatorImages, err := p.getImages(ctx)
if err != nil {
Expand Down

0 comments on commit 213d62b

Please sign in to comment.