From 344f5b32138dbd629c58d665d16275d73753f190 Mon Sep 17 00:00:00 2001 From: Derek Horton Date: Tue, 10 Dec 2024 13:10:23 -0600 Subject: [PATCH] Fix --- internal/api/middleware/pskAuth_test.go | 4 ++-- internal/api/tests/private/client.gen.go | 13 ++++++------- internal/api/tests/private/runsCreateV1_test.go | 4 ++-- internal/api/tests/private/runsCreateV2_test.go | 4 ++-- internal/api/tests/private/version_test.go | 4 ++-- internal/api/tests/public/client.gen.go | 6 +++--- internal/api/tests/public/middleware_test.go | 4 ++-- internal/api/tests/public/utils.go | 4 ++-- internal/common/ansible/runner_test.go | 4 ++-- internal/common/satellite/satellite_test.go | 4 ++-- internal/common/utils/test/client.go | 4 ++-- internal/common/utils/test/multiResponseClient.go | 4 ++-- internal/validator/handler_test.go | 4 ++-- internal/validator/storage.go | 3 +-- 14 files changed, 32 insertions(+), 34 deletions(-) diff --git a/internal/api/middleware/pskAuth_test.go b/internal/api/middleware/pskAuth_test.go index 2dbdb998..632dd2e6 100644 --- a/internal/api/middleware/pskAuth_test.go +++ b/internal/api/middleware/pskAuth_test.go @@ -3,7 +3,7 @@ package middleware import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "playbook-dispatcher/internal/common/utils" @@ -76,7 +76,7 @@ var _ = Describe("PSK auth middleware", func() { res, err := testPskAuth(req) Expect(err).ToNot(HaveOccurred()) Expect(res.Result().StatusCode).To(Equal(200)) - body, err := ioutil.ReadAll(res.Result().Body) + body, err := io.ReadAll(res.Result().Body) Expect(err).ToNot(HaveOccurred()) Expect(body).To(BeEquivalentTo("principal1")) }) diff --git a/internal/api/tests/private/client.gen.go b/internal/api/tests/private/client.gen.go index a5d4d65e..bc43e74d 100644 --- a/internal/api/tests/private/client.gen.go +++ b/internal/api/tests/private/client.gen.go @@ -9,7 +9,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -1038,7 +1037,7 @@ func (c *ClientWithResponses) ApiInternalVersionWithResponse(ctx context.Context // ParseApiInternalRunsCreateResponse parses an HTTP response from a ApiInternalRunsCreateWithResponse call func ParseApiInternalRunsCreateResponse(rsp *http.Response) (*ApiInternalRunsCreateResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err @@ -1071,7 +1070,7 @@ func ParseApiInternalRunsCreateResponse(rsp *http.Response) (*ApiInternalRunsCre // ParseApiInternalV2RunsCancelResponse parses an HTTP response from a ApiInternalV2RunsCancelWithResponse call func ParseApiInternalV2RunsCancelResponse(rsp *http.Response) (*ApiInternalV2RunsCancelResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err @@ -1104,7 +1103,7 @@ func ParseApiInternalV2RunsCancelResponse(rsp *http.Response) (*ApiInternalV2Run // ParseApiInternalHighlevelConnectionStatusResponse parses an HTTP response from a ApiInternalHighlevelConnectionStatusWithResponse call func ParseApiInternalHighlevelConnectionStatusResponse(rsp *http.Response) (*ApiInternalHighlevelConnectionStatusResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err @@ -1137,7 +1136,7 @@ func ParseApiInternalHighlevelConnectionStatusResponse(rsp *http.Response) (*Api // ParseApiInternalV2RunsCreateResponse parses an HTTP response from a ApiInternalV2RunsCreateWithResponse call func ParseApiInternalV2RunsCreateResponse(rsp *http.Response) (*ApiInternalV2RunsCreateResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err @@ -1163,7 +1162,7 @@ func ParseApiInternalV2RunsCreateResponse(rsp *http.Response) (*ApiInternalV2Run // ParseApiInternalV2RecipientsStatusResponse parses an HTTP response from a ApiInternalV2RecipientsStatusWithResponse call func ParseApiInternalV2RecipientsStatusResponse(rsp *http.Response) (*ApiInternalV2RecipientsStatusResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err @@ -1196,7 +1195,7 @@ func ParseApiInternalV2RecipientsStatusResponse(rsp *http.Response) (*ApiInterna // ParseApiInternalVersionResponse parses an HTTP response from a ApiInternalVersionWithResponse call func ParseApiInternalVersionResponse(rsp *http.Response) (*ApiInternalVersionResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err diff --git a/internal/api/tests/private/runsCreateV1_test.go b/internal/api/tests/private/runsCreateV1_test.go index 7101e2fd..c1a9de86 100644 --- a/internal/api/tests/private/runsCreateV1_test.go +++ b/internal/api/tests/private/runsCreateV1_test.go @@ -2,7 +2,7 @@ package private import ( "context" - "io/ioutil" + "io" "net/http" "playbook-dispatcher/internal/api/controllers/public" dbModel "playbook-dispatcher/internal/common/model/db" @@ -212,7 +212,7 @@ var _ = Describe("runsCreate V1", func() { resp, err := client.ApiInternalRunsCreateWithBody(test.TestContext(), "application/json", strings.NewReader(payload)) Expect(err).ToNot(HaveOccurred()) Expect(resp.StatusCode).To(Equal(http.StatusBadRequest)) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(ContainSubstring(expected)) }, diff --git a/internal/api/tests/private/runsCreateV2_test.go b/internal/api/tests/private/runsCreateV2_test.go index d6552b27..eaecee6c 100644 --- a/internal/api/tests/private/runsCreateV2_test.go +++ b/internal/api/tests/private/runsCreateV2_test.go @@ -2,7 +2,7 @@ package private import ( "context" - "io/ioutil" + "io" "net/http" "playbook-dispatcher/internal/api/controllers/public" dbModel "playbook-dispatcher/internal/common/model/db" @@ -318,7 +318,7 @@ var _ = Describe("runsCreate V2", func() { resp, err := client.ApiInternalV2RunsCreateWithBody(test.TestContext(), "application/json", strings.NewReader(payload)) Expect(err).ToNot(HaveOccurred()) Expect(resp.StatusCode).To(Equal(http.StatusBadRequest)) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) Expect(err).ToNot(HaveOccurred()) Expect(string(body)).To(ContainSubstring(expected)) }, diff --git a/internal/api/tests/private/version_test.go b/internal/api/tests/private/version_test.go index c2f88c63..97d01075 100644 --- a/internal/api/tests/private/version_test.go +++ b/internal/api/tests/private/version_test.go @@ -2,7 +2,7 @@ package private import ( "bytes" - "io/ioutil" + "io" "net/http" "playbook-dispatcher/internal/common/utils/test" @@ -22,7 +22,7 @@ var _ = Describe("Version", func() { Expect(err).ToNot(HaveOccurred()) Expect(res.StatusCode).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(res.Body) + data, err := io.ReadAll(res.Body) Expect(err).ToNot(HaveOccurred()) // Remove quotes and newline from the returned data diff --git a/internal/api/tests/public/client.gen.go b/internal/api/tests/public/client.gen.go index 37f5da66..37d9657f 100644 --- a/internal/api/tests/public/client.gen.go +++ b/internal/api/tests/public/client.gen.go @@ -7,7 +7,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strings" @@ -821,7 +821,7 @@ func (c *ClientWithResponses) ApiRunsListWithResponse(ctx context.Context, param // ParseApiRunHostsListResponse parses an HTTP response from a ApiRunHostsListWithResponse call func ParseApiRunHostsListResponse(rsp *http.Response) (*ApiRunHostsListResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err @@ -861,7 +861,7 @@ func ParseApiRunHostsListResponse(rsp *http.Response) (*ApiRunHostsListResponse, // ParseApiRunsListResponse parses an HTTP response from a ApiRunsListWithResponse call func ParseApiRunsListResponse(rsp *http.Response) (*ApiRunsListResponse, error) { - bodyBytes, err := ioutil.ReadAll(rsp.Body) + bodyBytes, err := io.ReadAll(rsp.Body) defer rsp.Body.Close() if err != nil { return nil, err diff --git a/internal/api/tests/public/middleware_test.go b/internal/api/tests/public/middleware_test.go index a8e78ee5..9a9de7c0 100644 --- a/internal/api/tests/public/middleware_test.go +++ b/internal/api/tests/public/middleware_test.go @@ -3,7 +3,7 @@ package public import ( "bytes" "encoding/json" - "io/ioutil" + "io" "net/http" "playbook-dispatcher/internal/common/utils/test" @@ -59,7 +59,7 @@ var _ = Describe("Middleware", func() { Expect(err).ToNot(HaveOccurred()) Expect(res.StatusCode).To(Equal(http.StatusBadRequest)) - data, _ := ioutil.ReadAll(res.Body) + data, _ := io.ReadAll(res.Body) defer res.Body.Close() Expect(data).To(BeEquivalentTo("Bad Request: missing x-rh-identity header\n")) diff --git a/internal/api/tests/public/utils.go b/internal/api/tests/public/utils.go index 390e4a85..68841221 100644 --- a/internal/api/tests/public/utils.go +++ b/internal/api/tests/public/utils.go @@ -2,7 +2,7 @@ package public import ( "encoding/json" - "io/ioutil" + "io" "net/http" "playbook-dispatcher/internal/common/utils" "playbook-dispatcher/internal/common/utils/test" @@ -16,7 +16,7 @@ func fieldTester(fn func(params ...interface{}) *http.Response) func(...string) res := fn(params...) Expect(res.StatusCode).To(Equal(http.StatusOK)) - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) Expect(err).ToNot(HaveOccurred()) defer res.Body.Close() diff --git a/internal/common/ansible/runner_test.go b/internal/common/ansible/runner_test.go index 3ee83c81..b0f9e974 100644 --- a/internal/common/ansible/runner_test.go +++ b/internal/common/ansible/runner_test.go @@ -2,8 +2,8 @@ package ansible import ( "encoding/json" - "io/ioutil" messageModel "playbook-dispatcher/internal/common/model/message" + "os" "strings" . "github.com/onsi/ginkgo" @@ -11,7 +11,7 @@ import ( ) func loadFile(path string) (events []messageModel.PlaybookRunResponseMessageYamlEventsElem) { - file, err := ioutil.ReadFile(path) + file, err := os.ReadFile(path) Expect(err).ToNot(HaveOccurred()) lines := strings.Split(string(file), "\n") diff --git a/internal/common/satellite/satellite_test.go b/internal/common/satellite/satellite_test.go index bf24f1ca..64ba959f 100644 --- a/internal/common/satellite/satellite_test.go +++ b/internal/common/satellite/satellite_test.go @@ -2,8 +2,8 @@ package satellite import ( "encoding/json" - "io/ioutil" messageModel "playbook-dispatcher/internal/common/model/message" + "os" "strings" . "github.com/onsi/ginkgo" @@ -11,7 +11,7 @@ import ( ) func loadFile(path string) (events []messageModel.PlaybookSatRunResponseMessageYamlEventsElem) { - file, err := ioutil.ReadFile(path) + file, err := os.ReadFile(path) Expect(err).ToNot(HaveOccurred()) lines := strings.Split(string(file), "\n") diff --git a/internal/common/utils/test/client.go b/internal/common/utils/test/client.go index 302eb399..99711ed9 100644 --- a/internal/common/utils/test/client.go +++ b/internal/common/utils/test/client.go @@ -2,7 +2,7 @@ package test import ( "bytes" - "io/ioutil" + "io" "net/http" ) @@ -19,7 +19,7 @@ func (this *mockHttpRequestDoer) Do(req *http.Request) (*http.Response, error) { func MockHttpClient(statusCode int, body string) mockHttpRequestDoer { response := http.Response{ StatusCode: statusCode, - Body: ioutil.NopCloser(bytes.NewReader([]byte(body))), + Body: io.NopCloser(bytes.NewReader([]byte(body))), Header: http.Header{ "Content-Type": []string{"application/json"}, }, diff --git a/internal/common/utils/test/multiResponseClient.go b/internal/common/utils/test/multiResponseClient.go index 7adb0d8f..b0597b1c 100644 --- a/internal/common/utils/test/multiResponseClient.go +++ b/internal/common/utils/test/multiResponseClient.go @@ -2,7 +2,7 @@ package test import ( "bytes" - "io/ioutil" + "io" "net/http" ) @@ -31,7 +31,7 @@ func MockMultiResponseHttpClient(mockResponses ...MockHttpResponse) *mockMultiRe for i := range mockResponses { response := http.Response{ StatusCode: mockResponses[i].StatusCode, - Body: ioutil.NopCloser(bytes.NewReader([]byte(mockResponses[i].Body))), + Body: io.NopCloser(bytes.NewReader([]byte(mockResponses[i].Body))), Header: http.Header{ "Content-Type": []string{"application/json"}, }, diff --git a/internal/validator/handler_test.go b/internal/validator/handler_test.go index 614e3b91..93afbd36 100644 --- a/internal/validator/handler_test.go +++ b/internal/validator/handler_test.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/base64" "encoding/json" - "io/ioutil" + "os" "playbook-dispatcher/internal/common/constants" kafkaUtils "playbook-dispatcher/internal/common/kafka" messageModel "playbook-dispatcher/internal/common/model/message" @@ -27,7 +27,7 @@ var _ = Describe("Handler", func() { for _, filePath := range []string{"../../schema/ansibleRunnerJobEvent.yaml", "../../schema/rhcsatJobEvent.yaml"} { var schema jsonschema.Schema - file, err := ioutil.ReadFile(filePath) + file, err := os.ReadFile(filePath) Expect(err).ToNot(HaveOccurred()) err = yaml.Unmarshal(file, &schema) Expect(err).ToNot(HaveOccurred()) diff --git a/internal/validator/storage.go b/internal/validator/storage.go index cc770bd0..f8b15aa8 100644 --- a/internal/validator/storage.go +++ b/internal/validator/storage.go @@ -4,7 +4,6 @@ import ( "bufio" "compress/gzip" "io" - "io/ioutil" "net/http" commonInstrumentation "playbook-dispatcher/internal/common/instrumentation" "playbook-dispatcher/internal/common/utils" @@ -98,5 +97,5 @@ func readFile(reader io.Reader) (result []byte, err error) { } } - return ioutil.ReadAll(reader) + return io.ReadAll(reader) }