From 1ca489ad2e578b8cc9713d00a96b54af6512ec40 Mon Sep 17 00:00:00 2001 From: zachary-walters Date: Tue, 3 Oct 2023 08:42:30 -0500 Subject: [PATCH] Replaced deprecated io/ioutil package with proper implementations of io/os packages. As of Go v1.16, the io/ioutil package has been deprecated and replaced with io and os implementations. https://go.dev/doc/go1.16#ioutil --- .schema/openapi/templates/go/api.mustache | 8 +++--- .schema/openapi/templates/go/signing.mustache | 3 +-- internal/httpclient/api_metadata.go | 14 +++++----- internal/httpclient/api_permission.go | 22 ++++++++-------- internal/httpclient/api_relationship.go | 26 +++++++++---------- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.schema/openapi/templates/go/api.mustache b/.schema/openapi/templates/go/api.mustache index 63f93b1b8..6ee735a7f 100644 --- a/.schema/openapi/templates/go/api.mustache +++ b/.schema/openapi/templates/go/api.mustache @@ -5,7 +5,7 @@ package {{packageName}} import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "net/url" {{#imports}} "{{import}}" @@ -243,7 +243,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class } {{/required}} if localVarFile != nil { - fbs, _ := ioutil.ReadAll(localVarFile) + fbs, _ := io.ReadAll(localVarFile) localVarFileBytes = fbs localVarFileName = localVarFile.Name() localVarFile.Close() @@ -321,9 +321,9 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err } diff --git a/.schema/openapi/templates/go/signing.mustache b/.schema/openapi/templates/go/signing.mustache index db486a16b..6202dea1d 100644 --- a/.schema/openapi/templates/go/signing.mustache +++ b/.schema/openapi/templates/go/signing.mustache @@ -14,7 +14,6 @@ import ( "encoding/pem" "fmt" "io" - "io/ioutil" "net/http" "net/textproto" "os" @@ -178,7 +177,7 @@ func (h *HttpSignatureAuth) loadPrivateKey() (err error) { err = file.Close() }() var priv []byte - priv, err = ioutil.ReadAll(file) + priv, err = io.ReadAll(file) if err != nil { return err } diff --git a/internal/httpclient/api_metadata.go b/internal/httpclient/api_metadata.go index c43a17e3d..747f25253 100644 --- a/internal/httpclient/api_metadata.go +++ b/internal/httpclient/api_metadata.go @@ -14,7 +14,7 @@ package client import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "net/url" ) @@ -172,9 +172,9 @@ func (a *MetadataApiService) GetVersionExecute(r MetadataApiApiGetVersionRequest return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -281,9 +281,9 @@ func (a *MetadataApiService) IsAliveExecute(r MetadataApiApiIsAliveRequest) (*In return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -397,9 +397,9 @@ func (a *MetadataApiService) IsReadyExecute(r MetadataApiApiIsReadyRequest) (*In return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } diff --git a/internal/httpclient/api_permission.go b/internal/httpclient/api_permission.go index af71574a4..27e1e70a1 100644 --- a/internal/httpclient/api_permission.go +++ b/internal/httpclient/api_permission.go @@ -14,7 +14,7 @@ package client import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "net/url" ) @@ -239,9 +239,9 @@ func (a *PermissionApiService) CheckPermissionExecute(r PermissionApiApiCheckPer return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -422,9 +422,9 @@ func (a *PermissionApiService) CheckPermissionOrErrorExecute(r PermissionApiApiC return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -586,9 +586,9 @@ func (a *PermissionApiService) ExpandPermissionsExecute(r PermissionApiApiExpand return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -730,9 +730,9 @@ func (a *PermissionApiService) PostCheckPermissionExecute(r PermissionApiApiPost return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -864,9 +864,9 @@ func (a *PermissionApiService) PostCheckPermissionOrErrorExecute(r PermissionApi return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } diff --git a/internal/httpclient/api_relationship.go b/internal/httpclient/api_relationship.go index 72e7e97ea..bf226421d 100644 --- a/internal/httpclient/api_relationship.go +++ b/internal/httpclient/api_relationship.go @@ -14,7 +14,7 @@ package client import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "net/url" ) @@ -194,9 +194,9 @@ func (a *RelationshipApiService) CheckOplSyntaxExecute(r RelationshipApiApiCheck return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -320,9 +320,9 @@ func (a *RelationshipApiService) CreateRelationshipExecute(r RelationshipApiApiC return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -493,9 +493,9 @@ func (a *RelationshipApiService) DeleteRelationshipsExecute(r RelationshipApiApi return localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -675,9 +675,9 @@ func (a *RelationshipApiService) GetRelationshipsExecute(r RelationshipApiApiGet return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -793,9 +793,9 @@ func (a *RelationshipApiService) ListRelationshipNamespacesExecute(r Relationshi return localVarReturnValue, localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -907,9 +907,9 @@ func (a *RelationshipApiService) PatchRelationshipsExecute(r RelationshipApiApiP return localVarHTTPResponse, err } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err }