Skip to content

Commit 5d2f1fb

Browse files
Cleanup (#2670)
Co-authored-by: Jarosław Pieszka <jaroslaw.pieszka@sap.com>
1 parent 62ed619 commit 5d2f1fb

File tree

10 files changed

+68
-75
lines changed

10 files changed

+68
-75
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ require (
2323
github.com/kyma-project/infrastructure-manager v0.0.0-20251105085636-90cfe5ee0c7b
2424
github.com/lib/pq v1.10.9
2525
github.com/pivotal-cf/brokerapi/v12 v12.0.1
26-
github.com/pkg/errors v0.9.1
2726
github.com/prometheus/client_golang v1.23.2
2827
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
2928
github.com/sebdah/goldie/v2 v2.8.0
@@ -110,6 +109,7 @@ require (
110109
github.com/onsi/ginkgo v1.16.5 // indirect
111110
github.com/opencontainers/go-digest v1.0.0 // indirect
112111
github.com/opencontainers/image-spec v1.1.1 // indirect
112+
github.com/pkg/errors v0.9.1 // indirect
113113
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
114114
github.com/prometheus/client_model v0.6.2 // indirect
115115
github.com/prometheus/common v0.67.4 // indirect

internal/broker/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package broker
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"io"
89
"log/slog"
@@ -11,7 +12,6 @@ import (
1112

1213
"github.com/kyma-project/kyma-environment-broker/internal"
1314
"github.com/pivotal-cf/brokerapi/v12/domain/apiresponses"
14-
"github.com/pkg/errors"
1515
"golang.org/x/oauth2/clientcredentials"
1616
)
1717

internal/process/staged_manager.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111

1212
"github.com/kyma-project/kyma-environment-broker/internal/storage/dberr"
1313

14-
"github.com/pkg/errors"
15-
1614
"github.com/kyma-project/kyma-environment-broker/internal"
1715
kebError "github.com/kyma-project/kyma-environment-broker/internal/error"
1816
"github.com/kyma-project/kyma-environment-broker/internal/event"
@@ -220,7 +218,7 @@ func (m *StagedManager) runStep(step Step, operation internal.Operation, logger
220218
defer func() {
221219
if pErr := recover(); pErr != nil {
222220
logger.Info(fmt.Sprintf("panic in RunStep in staged manager: %v", pErr))
223-
err = errors.New(fmt.Sprintf("%v", pErr))
221+
err = fmt.Errorf("%v", pErr)
224222
om := NewOperationManager(m.operationStorage, step.Name(), kebError.KEBDependency)
225223
processedOperation, _, _ = om.OperationFailed(operation, "recovered from panic", err, m.log)
226224
}

testing/e2e/provisioning/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/kyma-project/kyma-environment-broker v0.0.0-20251126071514-1b3cee15b0cb
88
github.com/ory/hydra-maester v0.0.40
99
github.com/pivotal-cf/brokerapi/v7 v7.5.0
10-
github.com/pkg/errors v0.9.1
1110
github.com/stretchr/testify v1.11.1
1211
github.com/thanhpk/randstr v1.0.6
1312
github.com/vrischmann/envconfig v1.4.1
@@ -44,6 +43,7 @@ require (
4443
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4544
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
4645
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
46+
github.com/pkg/errors v0.9.1 // indirect
4747
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4848
github.com/spf13/pflag v1.0.10 // indirect
4949
github.com/x448/float16 v0.8.4 // indirect

testing/e2e/provisioning/pkg/client/broker/broker_client.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7+
"errors"
78
"fmt"
89
"io"
910
"io/ioutil"
@@ -15,7 +16,6 @@ import (
1516

1617
"github.com/google/uuid"
1718
"github.com/pivotal-cf/brokerapi/v7/domain"
18-
"github.com/pkg/errors"
1919
"github.com/thanhpk/randstr"
2020
"golang.org/x/oauth2/clientcredentials"
2121
"k8s.io/apimachinery/pkg/util/wait"
@@ -111,7 +111,7 @@ func (c *Client) ProvisionRuntime(kymaVersion string) (string, error) {
111111
c.log.Info(fmt.Sprintf("Provisioning Runtime [instanceID: %s, NAME: %s]", c.InstanceID(), c.ClusterName()))
112112
requestByte, err := c.prepareProvisionDetails(kymaVersion)
113113
if err != nil {
114-
return "", errors.Wrap(err, "while preparing provision details")
114+
return "", fmt.Errorf("while preparing provision details: %w", err)
115115
}
116116
c.log.Info(fmt.Sprintf("Provisioning parameters: %v", string(requestByte)))
117117

@@ -120,7 +120,7 @@ func (c *Client) ProvisionRuntime(kymaVersion string) (string, error) {
120120
err = wait.PollUntilContextTimeout(context.Background(), time.Second, time.Second*5, false, func(ctx context.Context) (bool, error) {
121121
err := c.executeRequest(http.MethodPut, provisionURL, http.StatusAccepted, bytes.NewReader(requestByte), &response)
122122
if err != nil {
123-
c.log.Warn(errors.Wrap(err, "while executing request").Error())
123+
c.log.Warn(fmt.Errorf("while executing request: %w", err).Error())
124124
return false, nil
125125
}
126126
if response.Operation == "" {
@@ -130,7 +130,7 @@ func (c *Client) ProvisionRuntime(kymaVersion string) (string, error) {
130130
return true, nil
131131
})
132132
if err != nil {
133-
return "", errors.Wrap(err, "while waiting for successful provision call")
133+
return "", fmt.Errorf("while waiting for successful provision call: %w", err)
134134
}
135135
c.log.Info(fmt.Sprintf("Successfully send provision request, got operation ID %s", response.Operation))
136136

@@ -146,13 +146,13 @@ func (c *Client) DeprovisionRuntime() (string, error) {
146146
err := wait.PollUntilContextTimeout(context.Background(), time.Second, time.Second*5, false, func(ctx context.Context) (bool, error) {
147147
err := c.executeRequest(http.MethodDelete, deprovisionURL, http.StatusAccepted, nil, &response)
148148
if err != nil {
149-
c.log.Warn(errors.Wrap(err, "while executing request").Error())
149+
c.log.Warn(fmt.Errorf("while executing request: %w", err).Error())
150150
return false, nil
151151
}
152152
return true, nil
153153
})
154154
if err != nil {
155-
return "", errors.Wrap(err, "while waiting for successful deprovision call")
155+
return "", fmt.Errorf("while waiting for successful deprovision call: %w", err)
156156
}
157157
c.log.Info(fmt.Sprintf("Successfully send deprovision request, got operation ID %s", response.Operation))
158158
return response.Operation, nil
@@ -162,7 +162,7 @@ func (c *Client) SuspendRuntime() error {
162162
c.log.Info(fmt.Sprintf("Suspending Runtime [instanceID: %s, NAME: %s]", c.instanceID, c.clusterName))
163163
requestByte, err := c.prepareUpdateDetails(BoolPtr(false))
164164
if err != nil {
165-
return errors.Wrap(err, "while preparing update details")
165+
return fmt.Errorf("while preparing update details: %w", err)
166166
}
167167
c.log.Info(fmt.Sprintf("Suspension parameters: %v", string(requestByte)))
168168

@@ -173,13 +173,13 @@ func (c *Client) SuspendRuntime() error {
173173
err = wait.PollUntilContextTimeout(context.Background(), time.Second, time.Second*5, false, func(ctx context.Context) (bool, error) {
174174
err := c.executeRequest(http.MethodPatch, suspensionURL, http.StatusOK, bytes.NewReader(requestByte), &suspensionResponse)
175175
if err != nil {
176-
c.log.Warn(errors.Wrap(err, "while executing request").Error())
176+
c.log.Warn(fmt.Errorf("while executing request: %w", err).Error())
177177
return false, nil
178178
}
179179
return true, nil
180180
})
181181
if err != nil {
182-
return errors.Wrap(err, "while waiting for successful suspension call")
182+
return fmt.Errorf("while waiting for successful suspension call: %w", err)
183183
}
184184
c.log.Info(fmt.Sprintf("Successfully send suspension request for %s", suspensionResponse))
185185
return nil
@@ -189,7 +189,7 @@ func (c *Client) UnsuspendRuntime() error {
189189
c.log.Info(fmt.Sprintf("Unsuspending Runtime [instanceID: %s, NAME: %s]", c.InstanceID(), c.ClusterName()))
190190
requestByte, err := c.prepareUpdateDetails(BoolPtr(true))
191191
if err != nil {
192-
return errors.Wrap(err, "while preparing update details")
192+
return fmt.Errorf("while preparing update details: %w", err)
193193
}
194194
c.log.Info(fmt.Sprintf("Unsuspension parameters: %v", string(requestByte)))
195195

@@ -200,13 +200,13 @@ func (c *Client) UnsuspendRuntime() error {
200200
err = wait.PollUntilContextTimeout(context.Background(), time.Second, time.Second*5, false, func(ctx context.Context) (bool, error) {
201201
err := c.executeRequest(http.MethodPatch, suspensionURL, http.StatusOK, bytes.NewReader(requestByte), &unsuspensionResponse)
202202
if err != nil {
203-
c.log.Warn(errors.Wrap(err, "while executing request").Error())
203+
c.log.Warn(fmt.Errorf("while executing request: %w", err).Error())
204204
return false, nil
205205
}
206206
return true, nil
207207
})
208208
if err != nil {
209-
return errors.Wrap(err, "while waiting for successful unsuspension call")
209+
return fmt.Errorf("while waiting for successful unsuspension call: %w", err)
210210
}
211211
c.log.Info(fmt.Sprintf("Successfully send unsuspension request for %s", unsuspensionResponse))
212212
return nil
@@ -248,7 +248,7 @@ func (c *Client) AwaitOperationSucceeded(operationID string, timeout time.Durati
248248
err := wait.PollUntilContextTimeout(context.Background(), 5*time.Minute, timeout, false, func(ctx context.Context) (bool, error) {
249249
err := c.executeRequest(http.MethodGet, lastOperationURL, http.StatusOK, nil, &response)
250250
if err != nil {
251-
c.log.Warn(errors.Wrap(err, "while executing request").Error())
251+
c.log.Warn(fmt.Errorf("while executing request: %w", err).Error())
252252
return false, nil
253253
}
254254
c.log.Info(fmt.Sprintf("Last operation status: %s", response.State))
@@ -270,7 +270,7 @@ func (c *Client) AwaitOperationSucceeded(operationID string, timeout time.Durati
270270
}
271271
})
272272
if err != nil {
273-
return errors.Wrap(err, "while waiting for succeeded last operation")
273+
return fmt.Errorf("while waiting for succeeded last operation: %w", err)
274274
}
275275
return nil
276276
}
@@ -283,7 +283,7 @@ func (c *Client) FetchDashboardURL() (string, error) {
283283
err := wait.PollUntilContextTimeout(context.Background(), time.Second, time.Second*5, false, func(ctx context.Context) (bool, error) {
284284
err := c.executeRequest(http.MethodGet, instanceDetailsURL, http.StatusOK, nil, &response)
285285
if err != nil {
286-
c.log.Warn(errors.Wrap(err, "while executing request").Error())
286+
c.log.Warn(fmt.Errorf("while executing request: %w", err).Error())
287287
return false, nil
288288
}
289289
if response.DashboardURL == "" {
@@ -293,7 +293,7 @@ func (c *Client) FetchDashboardURL() (string, error) {
293293
return true, nil
294294
})
295295
if err != nil {
296-
return "", errors.Wrap(err, "while waiting for dashboardURL")
296+
return "", fmt.Errorf("while waiting for dashboardURL: %w", err)
297297
}
298298
c.log.Info(fmt.Sprintf("Successfully fetched dashboard URL: %s", response.DashboardURL))
299299

@@ -316,11 +316,11 @@ func (c *Client) prepareProvisionDetails(customVersion string) ([]byte, error) {
316316
}
317317
rawParameters, err := json.Marshal(parameters)
318318
if err != nil {
319-
return nil, errors.Wrap(err, "while marshalling parameters body")
319+
return nil, fmt.Errorf("while marshalling parameters body: %w", err)
320320
}
321321
rawContext, err := json.Marshal(ctx)
322322
if err != nil {
323-
return nil, errors.Wrap(err, "while marshalling context body")
323+
return nil, fmt.Errorf("while marshalling context body: %w", err)
324324
}
325325
requestBody := domain.ProvisionDetails{
326326
ServiceID: kymaClassID,
@@ -337,7 +337,7 @@ func (c *Client) prepareProvisionDetails(customVersion string) ([]byte, error) {
337337

338338
requestByte, err := json.Marshal(requestBody)
339339
if err != nil {
340-
return nil, errors.Wrap(err, "while marshalling request body")
340+
return nil, fmt.Errorf("while marshalling request body: %w", err)
341341
}
342342
return requestByte, nil
343343
}
@@ -351,7 +351,7 @@ func (c *Client) prepareUpdateDetails(active *bool) ([]byte, error) {
351351
}
352352
rawContext, err := json.Marshal(ctx)
353353
if err != nil {
354-
return nil, errors.Wrap(err, "while marshalling context body")
354+
return nil, fmt.Errorf("while marshalling context body: %w", err)
355355
}
356356
requestBody := domain.UpdateDetails{
357357
ServiceID: kymaClassID,
@@ -364,21 +364,21 @@ func (c *Client) prepareUpdateDetails(active *bool) ([]byte, error) {
364364
}
365365
requestByte, err := json.Marshal(requestBody)
366366
if err != nil {
367-
return nil, errors.Wrap(err, "while marshalling request body")
367+
return nil, fmt.Errorf("while marshalling request body: %w", err)
368368
}
369369
return requestByte, nil
370370
}
371371

372372
func (c *Client) executeRequest(method, url string, expectedStatus int, body io.Reader, responseBody interface{}) error {
373373
request, err := http.NewRequest(method, url, body)
374374
if err != nil {
375-
return errors.Wrap(err, "while creating request for provisioning")
375+
return fmt.Errorf("while creating request for provisioning: %w", err)
376376
}
377377
request.Header.Set("X-Broker-API-Version", "2.14")
378378

379379
resp, err := c.client.Do(request)
380380
if err != nil {
381-
return errors.Wrapf(err, "while executing request URL: %s", url)
381+
return fmt.Errorf("while executing request URL: %s: %w", url, err)
382382
}
383383
defer c.warnOnError(resp.Body.Close)
384384
if resp.StatusCode != expectedStatus {
@@ -389,12 +389,12 @@ func (c *Client) executeRequest(method, url string, expectedStatus int, body io.
389389
}
390390
bodyString := string(bodyBytes)
391391
c.log.Warn(fmt.Sprintf("%s", bodyString))
392-
return errors.Errorf("got unexpected status code while calling Kyma Environment Broker: want: %d, got: %d (url=%s)", expectedStatus, resp.StatusCode, url)
392+
return fmt.Errorf("got unexpected status code while calling Kyma Environment Broker: want: %d, got: %d (url=%s)", expectedStatus, resp.StatusCode, url)
393393
}
394394

395395
err = json.NewDecoder(resp.Body).Decode(responseBody)
396396
if err != nil {
397-
return errors.Wrapf(err, "while decoding body")
397+
return fmt.Errorf("while decoding body: %w", err)
398398
}
399399

400400
return nil

0 commit comments

Comments
 (0)