Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log validation errors separately in deployableByOLM check #847

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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