Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions central/clustercveedge/datastore/datastore_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (ds *datastoreImpl) filterReadable(ctx context.Context, ids []string) ([]st

func (ds *datastoreImpl) Upsert(ctx context.Context, parts ...converter.ClusterCVEParts) error {
if env.PostgresDatastoreEnabled.BooleanSetting() {
return utils.Should(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
return utils.ShouldErr(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
}
if len(parts) == 0 {
return nil
Expand All @@ -121,7 +121,7 @@ func (ds *datastoreImpl) Upsert(ctx context.Context, parts ...converter.ClusterC

func (ds *datastoreImpl) Delete(ctx context.Context, ids ...string) error {
if env.PostgresDatastoreEnabled.BooleanSetting() {
return utils.Should(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
return utils.ShouldErr(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
}
if ok, err := clustersSAC.WriteAllowed(ctx); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions central/clustercveedge/datastore/store/postgres/full_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ type fullStoreImpl struct {

func (f *fullStoreImpl) Upsert(_ context.Context, _ ...converter.ClusterCVEParts) error {
if env.PostgresDatastoreEnabled.BooleanSetting() {
return utils.Should(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
return utils.ShouldErr(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
}
return nil
}

func (f *fullStoreImpl) Delete(_ context.Context, _ ...string) error {
if env.PostgresDatastoreEnabled.BooleanSetting() {
return utils.Should(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
return utils.ShouldErr(errors.New("Unexpected cluster-cve edge upsert when running on Postgres"))
}
return nil
}
4 changes: 2 additions & 2 deletions central/globaldb/v2backuprestore/manager/restore_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type restoreProcess struct {
func newRestoreProcess(ctx context.Context, id string, header *v1.DBRestoreRequestHeader, handlerFuncs []common.RestoreFileHandlerFunc, data io.Reader) (*restoreProcess, error) {
mfFiles := header.GetManifest().GetFiles()
if len(mfFiles) != len(handlerFuncs) {
return nil, utils.Should(errors.Errorf("mismatch: %d handler functions provided for %d files in the manifest", len(handlerFuncs), len(mfFiles)))
return nil, utils.ShouldErr(errors.Errorf("mismatch: %d handler functions provided for %d files in the manifest", len(handlerFuncs), len(mfFiles)))
}

files := make([]*restoreFile, 0, len(mfFiles))
Expand All @@ -99,7 +99,7 @@ func newRestoreProcess(ctx context.Context, id string, header *v1.DBRestoreReque

resumableDataReader, initAttach, detachEvents := ioutils.NewResumableReader(crc32.NewIEEE())
if err := initAttach.Attach(data, 0, nil); err != nil {
return nil, utils.Should(errors.Wrap(err, "could not attach initial reader to resumable reader"))
return nil, utils.ShouldErr(errors.Wrap(err, "could not attach initial reader to resumable reader"))
}

p := &restoreProcess{
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/cluster_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func withOpenShiftTypeFiltering(q string) string {

func (resolver *clusterCVEResolver) clusterVulnerabilityScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func (resolver *clusterResolver) NodeVulnerabilityCounter(ctx context.Context, a

func (resolver *clusterResolver) clusterScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func (resolver *deploymentResolver) ImageVulnerabilityCounter(ctx context.Contex

func (resolver *deploymentResolver) deploymentScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Utility Functions

func (resolver *imageComponentResolver) imageComponentScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func imageCveToVulnerabilityWithSeverity(in []*storage.ImageCVE) []Vulnerability

func (resolver *imageCVEResolver) imageVulnerabilityScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (resolver *imageResolver) ImageComponentCount(ctx context.Context, args Raw

func (resolver *imageResolver) imageScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (resolver *namespaceResolver) ImageComponentCount(ctx context.Context, args

func (resolver *namespaceResolver) namespaceScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/node_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func queryWithNodeIDRegexFilter(q string) string {

func (resolver *nodeComponentResolver) nodeComponentScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/node_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func withNodeCveTypeFiltering(q string) string {

func (resolver *nodeCVEResolver) nodeVulnerabilityScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ func (resolver *nodeResolver) UnusedVarSink(_ context.Context, _ RawQuery) *int3

func (resolver *nodeResolver) nodeScopeContext(ctx context.Context) context.Context {
if ctx == nil {
err := utils.Should(errors.New("argument 'ctx' is nil"))
err := utils.ShouldErr(errors.New("argument 'ctx' is nil"))
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion central/image/service/service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (s *serviceImpl) GetImageVulnerabilitiesInternal(ctx context.Context, reque
func (s *serviceImpl) acquireScanSemaphore() error {
if err := s.internalScanSemaphore.Acquire(concurrency.AsContext(concurrency.Timeout(maxSemaphoreWaitTime)), 1); err != nil {
s, err := status.New(codes.Unavailable, err.Error()).WithDetails(&v1.ScanImageInternalResponseDetails_TooManyParallelScans{})
if pkgUtils.Should(err) == nil {
if pkgUtils.ShouldErr(err) == nil {
return s.Err()
}
}
Expand Down
4 changes: 2 additions & 2 deletions central/integrationhealth/datastore/datastore_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func writeAllowed(ctx context.Context, typ storage.IntegrationHealth_Type) (bool
if typ != storage.IntegrationHealth_IMAGE_INTEGRATION &&
typ != storage.IntegrationHealth_NOTIFIER &&
typ != storage.IntegrationHealth_BACKUP {
return false, utils.Should(errors.New("Unknown integration type"))
return false, utils.ShouldErr(errors.New("Unknown integration type"))
}
return integrationSAC.WriteAllowed(ctx)
}
Expand All @@ -100,7 +100,7 @@ func readAllowed(ctx context.Context, typ storage.IntegrationHealth_Type) (bool,
if typ != storage.IntegrationHealth_IMAGE_INTEGRATION &&
typ != storage.IntegrationHealth_NOTIFIER &&
typ != storage.IntegrationHealth_BACKUP {
return false, utils.Should(errors.New("Unknown integration type"))
return false, utils.ShouldErr(errors.New("Unknown integration type"))
}
return integrationSAC.ReadAllowed(ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion central/networkbaseline/manager/manager_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (m *manager) ProcessBaselineStatusUpdate(ctx context.Context, modifyRequest
}
}
default:
return utils.Should(errors.Errorf("unknown status: %v", peerAndStatus.GetStatus()))
return utils.ShouldErr(errors.Errorf("unknown status: %v", peerAndStatus.GetStatus()))
}
}
if err := m.persistNetworkBaselines(modifiedDeploymentIDs, nil); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion central/policy/service/service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ func (s *serviceImpl) ExportPolicies(ctx context.Context, request *v1.ExportPoli
if len(missingIndices) > 0 {
statusMsg, err := status.New(codes.InvalidArgument, "Some policies could not be retrieved. Check the error details for a list of policies that could not be found").WithDetails(errDetails)
if err != nil {
return nil, utils.Should(errors.Errorf("unexpected error creating status proto: %v", err))
return nil, utils.ShouldErr(errors.Errorf("unexpected error creating status proto: %v", err))
}
return nil, statusMsg.Err()
}
Expand Down
2 changes: 1 addition & 1 deletion central/risk/handlers/timeline/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func CSVHandler() http.HandlerFunc {
var podName, podUID, deploymentID, podStartTime, podContainerCount string

if podID, err := podUtils.ParsePodID(containerResolver.PodID()); err != nil {
log.Errorf("Unable to generate full CSV row for container %s: %v", containerName, utils.Should(err))
log.Errorf("Unable to generate full CSV row for container %s: %v", containerName, utils.ShouldErr(err))
} else {
podName = podID.Name
podUID = string(podID.UID)
Expand Down
4 changes: 2 additions & 2 deletions central/sac/authorizer/builtin_scoped_authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (a *resourceLevelScopeCheckerCore) Allowed() bool {
}
for _, role := range a.roles {
scope, err := a.cache.getEffectiveAccessScope(role.GetAccessScope())
if utils.Should(err) != nil {
if utils.ShouldErr(err) != nil {
return false
}
if scope.State == effectiveaccessscope.Included {
Expand Down Expand Up @@ -235,7 +235,7 @@ type clusterNamespaceLevelScopeCheckerCore struct {
func (a *clusterNamespaceLevelScopeCheckerCore) Allowed() bool {
for _, role := range a.roles {
scope, err := a.cache.getEffectiveAccessScope(role.GetAccessScope())
if utils.Should(err) != nil {
if utils.ShouldErr(err) != nil {
return false
}
if effectiveAccessScopeAllows(scope, a.resource, a.clusterID, a.namespace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func validateTimeouts(t timeoutProvider) error {

func newWithTimeoutProvider(clusterID string, storage ClusterStorage, autoTriggerEnabledFlag *concurrency.Flag, timeouts timeoutProvider) (UpgradeController, error) {
if err := validateTimeouts(timeouts); err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}

u := &upgradeController{
Expand Down
2 changes: 1 addition & 1 deletion central/sensor/telemetry/controller_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (c *controller) PullClusterInfo(ctx context.Context, cb ClusterInfoCallback
func (c *controller) ProcessTelemetryDataResponse(resp *central.PullTelemetryDataResponse) error {
requestID := resp.GetRequestId()
if resp.GetPayload() == nil {
return utils.Should(errors.Errorf("received a telemetry response with an empty payload for requested ID %s", requestID))
return utils.ShouldErr(errors.Errorf("received a telemetry response with an empty payload for requested ID %s", requestID))
}

var retC chan *central.TelemetryResponsePayload
Expand Down
2 changes: 1 addition & 1 deletion central/sensorupgrade/controlservice/service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *service) UpgradeCheckInFromSensor(ctx context.Context, req *central.Upg
if err := s.connectionManager.ProcessUpgradeCheckInFromSensor(ctx, clusterID, req); err != nil {
if errors.Is(err, upgradecontroller.ErrNoUpgradeInProgress) {
s, err := status.New(codes.Internal, err.Error()).WithDetails(&central.UpgradeCheckInResponseDetails_NoUpgradeInProgress{})
if utils.Should(err) == nil {
if utils.ShouldErr(err) == nil {
return nil, s.Err()
}
}
Expand Down
2 changes: 1 addition & 1 deletion compliance/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func runRecv(ctx context.Context, client sensor.ComplianceService_CommunicateCli
}
}
default:
_ = utils.Should(errors.Errorf("Unhandled msg type: %T", t))
utils.Should(errors.Errorf("Unhandled msg type: %T", t))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/common/extensions/secret_reconciliator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (r *SecretReconciliator) ReconcileSecret(ctx context.Context, name string,
}

if generate == nil {
return pkgUtils.Should(errors.Errorf("secret %s should exist, but no generation logic has been specified", name))
return pkgUtils.ShouldErr(errors.Errorf("secret %s should exist, but no generation logic has been specified", name))
}

// Try to generate the secret, in order to fix it.
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/authproviders/provider_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (p *providerImpl) GetOrCreateBackend(ctx context.Context) (Backend, error)
backend = p.backend
})
if backend == nil {
return nil, utils.Should(errors.New("unexpected: backend was nil"))
return nil, utils.ShouldErr(errors.New("unexpected: backend was nil"))
}
return backend, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/authproviders/userpki/backend_factory_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (f *factory) ProcessHTTPRequest(w http.ResponseWriter, r *http.Request) (pr

restURL := strings.TrimPrefix(r.URL.Path, f.callbackURLPath)
if len(restURL) == len(r.URL.Path) {
return "", "", utils.Should(httputil.Errorf(http.StatusNotFound, "invalid path %q, expected sub-path of %q", r.URL.Path, f.callbackURLPath))
return "", "", utils.ShouldErr(httputil.Errorf(http.StatusNotFound, "invalid path %q, expected sub-path of %q", r.URL.Path, f.callbackURLPath))
}

if restURL == "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/authproviders/userpki/backend_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (p *backendImpl) RefreshURL() string {
func (p *backendImpl) ProcessHTTPRequest(w http.ResponseWriter, r *http.Request) (*authproviders.AuthResponse, error) {
restPath := strings.TrimPrefix(r.URL.Path, p.pathPrefix)
if len(restPath) == len(r.URL.Path) {
return nil, utils.Should(httputil.Errorf(http.StatusNotFound,
return nil, utils.ShouldErr(httputil.Errorf(http.StatusNotFound,
"invalid URL %q, expected sub-path of %q", r.URL.Path, p.pathPrefix))
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/booleanpolicy/augmentedobjs/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ConstructDeploymentWithProcess(deployment *storage.Deployment, images []*st
pathutil.FieldStep("Containers"), pathutil.IndexStep(matchingContainerIdx), pathutil.FieldStep(processAugmentKey),
)
if err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}
return obj, nil
}
Expand All @@ -61,7 +61,7 @@ func ConstructKubeResourceWithEvent(kubeResource interface{}, event *storage.Kub
}

if err := obj.AddPlainObjAt(event, pathutil.FieldStep(kubeEventAugKey)); err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}
return obj, nil
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func ConstructDeployment(deployment *storage.Deployment, images []*storage.Image

appliedPolicies := pathutil.NewAugmentedObj(applied)
if err := obj.AddAugmentedObjAt(appliedPolicies, pathutil.FieldStep(networkPoliciesAppliedKey)); err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}

for i, image := range images {
Expand All @@ -159,7 +159,7 @@ func ConstructDeployment(deployment *storage.Deployment, images []*storage.Image
pathutil.FieldStep("Containers"), pathutil.IndexStep(i), pathutil.FieldStep(imageAugmentKey),
)
if err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}
}

Expand All @@ -173,7 +173,7 @@ func ConstructDeployment(deployment *storage.Deployment, images []*storage.Image
)

if err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func ConstructImage(image *storage.Image) (*pathutil.AugmentedObj, error) {
pathutil.IndexStep(i), pathutil.FieldStep(dockerfileLineAugmentKey),
)
if err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}
}

Expand All @@ -230,7 +230,7 @@ func ConstructImage(image *storage.Image) (*pathutil.AugmentedObj, error) {
pathutil.FieldStep(componentAndVersionAugmentKey),
)
if err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}
}

Expand All @@ -247,7 +247,7 @@ func ConstructImage(image *storage.Image) (*pathutil.AugmentedObj, error) {
},
pathutil.FieldStep("SignatureVerificationData"),
pathutil.FieldStep(imageSignatureVerifiedKey)); err != nil {
return nil, utils.Should(err)
return nil, utils.ShouldErr(err)
}

return obj, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/booleanpolicy/evaluator/pathutil/filter_linked.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func FilterMatchesToResults(fieldsToPathsAndValues map[string][]PathAndValueHold
// Panics will only happen with invalid inputs, which is always a programming error.
defer func() {
if r := recover(); r != nil {
err = utils.Should(errors.Errorf("invalid input: %v", r))
err = utils.ShouldErr(errors.Errorf("invalid input: %v", r))
}
}()
t := newTree()
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudproviders/azure/attested_vmid.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type attestedMetadata struct {
func getAttestedVMID(ctx context.Context) (string, error) {
req, err := http.NewRequest(http.MethodGet, attestedMetadataBaseURL, nil)
if err != nil {
return "", utils.Should(err)
return "", utils.ShouldErr(err)
}
req = req.WithContext(ctx)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudproviders/gcp/cert_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *certSet) Fetch(ctx context.Context) error {

req, err := http.NewRequest(http.MethodGet, certsURL, nil)
if err != nil {
return utils.Should(err)
return utils.ShouldErr(err)
}
req = req.WithContext(ctx)
resp, err := certificateHTTPClient.Do(req)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudproviders/gcp/identity_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type identityTokenClaims struct {
func getIdentityToken(ctx context.Context, audience string) (string, error) {
req, err := http.NewRequest(http.MethodGet, baseIdentityURL, nil)
if err != nil {
return "", utils.Should(err)
return "", utils.ShouldErr(err)
}
req = req.WithContext(ctx)
q := req.URL.Query()
Expand Down
Loading