Skip to content

Commit

Permalink
return pointer to string in httpclient resp body
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-carlton committed Oct 13, 2024
1 parent 8358b76 commit 16fc273
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 3,085 deletions.
6 changes: 6 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.21.6
use ./pkg/logging
use ./pkg/httpclient
use ./pkg/httpserver
use ./pkg/testutils
use ./pkg/mocks/logr
224 changes: 224 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pkg/httpclient/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type ReqResp interface {
HTTPreq() error
getRespBody() error
CloseBody()
RespBody() string
RespBody() *string
ResponseCode() int
}

Expand Down Expand Up @@ -223,7 +223,7 @@ func (r *reqResp) HTTPreq() error { //nolint:funlen,gocyclo // ok
return nil
}

return requestError(fmt.Sprintf("failed: %s %s", r.resp.Status, r.RespBody()))
return requestError(fmt.Sprintf("failed: %s %s", r.resp.Status, *r.RespBody()))
}
}

Expand All @@ -243,16 +243,16 @@ func (r *reqResp) getRespBody() error {
}

// RespBody is used to return the response body as a string.
func (r *reqResp) RespBody() string {
func (r *reqResp) RespBody() *string {
if r.respText == nil {
if err := r.getRespBody(); err != nil {
r.logger.Error(err, "failed to retrieve response body")

return ""
return nil
}
}

return *r.respText
return r.respText
}

// RespCode is used to return the response code.
Expand Down
72 changes: 0 additions & 72 deletions pkg/kubectl/execProvider.go

This file was deleted.

45 changes: 0 additions & 45 deletions pkg/kubectl/export_test.go

This file was deleted.

39 changes: 0 additions & 39 deletions pkg/kubectl/go.mod

This file was deleted.

Loading

0 comments on commit 16fc273

Please sign in to comment.