refactor: move from io/ioutil to io and os package (#2236)
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -18,7 +18,6 @@ package mqtrigger
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -87,7 +86,7 @@ func readSecrets(logger *zap.Logger, secretsPath string) (map[string][]byte, err
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
secretFiles, err := ioutil.ReadDir(secretsPath)
|
secretFiles, err := os.ReadDir(secretsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,7 @@ func readSecrets(logger *zap.Logger, secretsPath string) (map[string][]byte, err
|
|||||||
logger.Info(fmt.Sprintf("Reading secret from %s", fileName))
|
logger.Info(fmt.Sprintf("Reading secret from %s", fileName))
|
||||||
|
|
||||||
filePath := path.Join(secretsPath, fileName)
|
filePath := path.Join(secretsPath, fileName)
|
||||||
secret, fileReadErr := ioutil.ReadFile(filePath)
|
secret, fileReadErr := os.ReadFile(filePath)
|
||||||
if fileReadErr != nil {
|
if fileReadErr != nil {
|
||||||
return nil, fileReadErr
|
return nil, fileReadErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@@ -98,7 +97,7 @@ func (builder *Builder) Handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// parse request
|
// parse request
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e := "error reading request body"
|
e := "error reading request body"
|
||||||
builder.logger.Error(e, zap.Error(err))
|
builder.logger.Error(e, zap.Error(err))
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -31,7 +31,7 @@ import (
|
|||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"golang.org/x/net/context/ctxhttp"
|
"golang.org/x/net/context/ctxhttp"
|
||||||
|
|
||||||
builder "github.com/fission/fission/pkg/builder"
|
"github.com/fission/fission/pkg/builder"
|
||||||
ferror "github.com/fission/fission/pkg/error"
|
ferror "github.com/fission/fission/pkg/error"
|
||||||
otelUtils "github.com/fission/fission/pkg/utils/otel"
|
otelUtils "github.com/fission/fission/pkg/utils/otel"
|
||||||
"github.com/fission/fission/pkg/utils/tracing"
|
"github.com/fission/fission/pkg/utils/tracing"
|
||||||
@@ -91,7 +91,7 @@ func (c *Client) Build(ctx context.Context, req *builder.PackageBuildRequest) (*
|
|||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
rBody, err := ioutil.ReadAll(resp.Body)
|
rBody, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error reading resp body", zap.Error(err))
|
logger.Error("error reading resp body", zap.Error(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -396,7 +396,7 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
assert(found, "incorrect response content type")
|
assert(found, "incorrect response content type")
|
||||||
|
|
||||||
_, err = ioutil.ReadAll(resp.Body)
|
_, err = io.ReadAll(resp.Body)
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
@@ -108,7 +108,7 @@ func (a *API) CanaryConfigApiCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -202,7 +202,7 @@ func (a *API) CanaryConfigApiUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ func (c *RESTClient) Delete(relativeUrl string) error {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error deleting")
|
return errors.Wrap(err, "error deleting")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -88,7 +87,7 @@ func (c *Misc) GetSvcURL(label string) (string, error) {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -105,7 +104,7 @@ func (c *Misc) ServerInfo() (*info.ServerInfo, error) {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
ferror "github.com/fission/fission/pkg/error"
|
ferror "github.com/fission/fission/pkg/error"
|
||||||
@@ -87,7 +87,7 @@ func handleResponse(resp *http.Response) ([]byte, error) {
|
|||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return nil, ferror.MakeErrorFromHTTP(resp)
|
return nil, ferror.MakeErrorFromHTTP(resp)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
return body, err
|
return body, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +95,6 @@ func handleCreateResponse(resp *http.Response) ([]byte, error) {
|
|||||||
if resp.StatusCode != 201 {
|
if resp.StatusCode != 201 {
|
||||||
return nil, ferror.MakeErrorFromHTTP(resp)
|
return nil, ferror.MakeErrorFromHTTP(resp)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
return body, err
|
return body, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
@@ -123,7 +123,7 @@ func (a *API) EnvironmentApiList(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) EnvironmentApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) EnvironmentApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -188,7 +188,7 @@ func (a *API) EnvironmentApiUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
name := vars["environment"]
|
name := vars["environment"]
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -134,7 +133,7 @@ func (a *API) FunctionApiList(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) FunctionApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) FunctionApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -196,7 +195,7 @@ func (a *API) FunctionApiUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
name := vars["function"]
|
name := vars["function"]
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ func (a *API) checkHTTPTriggerDuplicates(ctx context.Context, t *fv1.HTTPTrigger
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) HTTPTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) HTTPTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -228,7 +228,7 @@ func (a *API) HTTPTriggerApiUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
name := vars["httpTrigger"]
|
name := vars["httpTrigger"]
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
@@ -119,7 +119,7 @@ func (a *API) MessageQueueTriggerApiList(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) MessageQueueTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) MessageQueueTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -179,7 +179,7 @@ func (a *API) MessageQueueTriggerApiUpdate(w http.ResponseWriter, r *http.Reques
|
|||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
name := vars["mqTrigger"]
|
name := vars["mqTrigger"]
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
@@ -121,7 +121,7 @@ func (a *API) PackageApiList(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) PackageApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) PackageApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -203,7 +203,7 @@ func (a *API) PackageApiUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
name := vars["package"]
|
name := vars["package"]
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
@@ -121,7 +121,7 @@ func (a *API) TimeTriggerApiList(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) TimeTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) TimeTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
@@ -192,7 +192,7 @@ func (a *API) TimeTriggerApiUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
name := vars["timeTrigger"]
|
name := vars["timeTrigger"]
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
@@ -120,7 +120,7 @@ func (a *API) WatchApiList(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) WatchApiCreate(w http.ResponseWriter, r *http.Request) {
|
func (a *API) WatchApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package error
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -66,7 +66,7 @@ func MakeErrorFromHTTP(resp *http.Response) error {
|
|||||||
|
|
||||||
msg := resp.Status
|
msg := resp.Status
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err == nil && len(body) > 0 {
|
if err == nil && len(body) > 0 {
|
||||||
msg = strings.TrimSpace(string(body))
|
msg = strings.TrimSpace(string(body))
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -21,7 +21,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ import (
|
|||||||
|
|
||||||
func (executor *Executor) getServiceForFunctionAPI(w http.ResponseWriter, r *http.Request) {
|
func (executor *Executor) getServiceForFunctionAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Failed to read request", http.StatusInternalServerError)
|
http.Error(w, "Failed to read request", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -170,7 +170,7 @@ func (executor *Executor) tapServices(w http.ResponseWriter, r *http.Request) {
|
|||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
logger := otelUtils.LoggerWithTraceID(ctx, executor.logger)
|
logger := otelUtils.LoggerWithTraceID(ctx, executor.logger)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("failed to read tap service request", zap.Error(err))
|
logger.Error("failed to read tap service request", zap.Error(err))
|
||||||
http.Error(w, "Failed to read request", http.StatusInternalServerError)
|
http.Error(w, "Failed to read request", http.StatusInternalServerError)
|
||||||
@@ -222,7 +222,7 @@ func (executor *Executor) healthHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
func (executor *Executor) unTapService(w http.ResponseWriter, r *http.Request) {
|
func (executor *Executor) unTapService(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Failed to read request", http.StatusInternalServerError)
|
http.Error(w, "Failed to read request", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -95,7 +95,7 @@ func (c *Client) GetServiceForFunction(ctx context.Context, fn *fv1.Function) (s
|
|||||||
return "", ferror.MakeErrorFromHTTP(resp)
|
return "", ferror.MakeErrorFromHTTP(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
svcName, err := ioutil.ReadAll(resp.Body)
|
svcName, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "error reading response body from getting service for function")
|
return "", errors.Wrap(err, "error reading response body from getting service for function")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package featureconfig
|
|||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
)
|
)
|
||||||
@@ -27,7 +27,7 @@ import (
|
|||||||
// GetFeatureConfig reads the configMap file and unmarshals the config into a feature config struct
|
// GetFeatureConfig reads the configMap file and unmarshals the config into a feature config struct
|
||||||
func GetFeatureConfig() (*FeatureConfig, error) {
|
func GetFeatureConfig() (*FeatureConfig, error) {
|
||||||
// read the file
|
// read the file
|
||||||
b64EncodedContent, err := ioutil.ReadFile(FeatureConfigFile)
|
b64EncodedContent, err := os.ReadFile(FeatureConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error reading YAML file %s: %v", FeatureConfigFile, err)
|
return nil, fmt.Errorf("error reading YAML file %s: %v", FeatureConfigFile, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -94,7 +94,7 @@ func sendRequest(logger *zap.Logger, ctx context.Context, httpClient *http.Clien
|
|||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error reading response body", zap.Error(err))
|
logger.Error("error reading response body", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -97,12 +97,12 @@ func MakeFetcher(logger *zap.Logger, sharedVolumePath string, sharedSecretPath s
|
|||||||
return nil, errors.Wrap(err, "error making the fission / kube client")
|
return nil, errors.Wrap(err, "error making the fission / kube client")
|
||||||
}
|
}
|
||||||
|
|
||||||
name, err := ioutil.ReadFile(fv1.PodInfoMount + "/name")
|
name, err := os.ReadFile(fv1.PodInfoMount + "/name")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error reading pod name from downward volume")
|
return nil, errors.Wrap(err, "error reading pod name from downward volume")
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, err := ioutil.ReadFile(fv1.PodInfoMount + "/namespace")
|
namespace, err := os.ReadFile(fv1.PodInfoMount + "/namespace")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error reading pod namespace from downward volume")
|
return nil, errors.Wrap(err, "error reading pod namespace from downward volume")
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ func verifyChecksum(fileChecksum, checksum *fv1.Checksum) error {
|
|||||||
func writeSecretOrConfigMap(dataMap map[string][]byte, dirPath string) error {
|
func writeSecretOrConfigMap(dataMap map[string][]byte, dirPath string) error {
|
||||||
for key, val := range dataMap {
|
for key, val := range dataMap {
|
||||||
writeFilePath := filepath.Join(dirPath, key)
|
writeFilePath := filepath.Join(dirPath, key)
|
||||||
err := ioutil.WriteFile(writeFilePath, val, 0750)
|
err := os.WriteFile(writeFilePath, val, 0750)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "Failed to write file %s", writeFilePath)
|
return errors.Wrapf(err, "Failed to write file %s", writeFilePath)
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ func (fetcher *Fetcher) FetchHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// parse request
|
// parse request
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error reading request body", zap.Error(err))
|
logger.Error("error reading request body", zap.Error(err))
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
@@ -226,7 +226,7 @@ func (fetcher *Fetcher) SpecializeHandler(w http.ResponseWriter, r *http.Request
|
|||||||
logger := otelUtils.LoggerWithTraceID(ctx, fetcher.logger)
|
logger := otelUtils.LoggerWithTraceID(ctx, fetcher.logger)
|
||||||
|
|
||||||
// parse request
|
// parse request
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error reading request body", zap.Error(err))
|
logger.Error("error reading request body", zap.Error(err))
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
@@ -313,7 +313,7 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, pkg *fv1.Package, req Functio
|
|||||||
// get package data as literal or by url
|
// get package data as literal or by url
|
||||||
if len(archive.Literal) > 0 {
|
if len(archive.Literal) > 0 {
|
||||||
// write pkg.Literal into tmpPath
|
// write pkg.Literal into tmpPath
|
||||||
err := ioutil.WriteFile(tmpPath, archive.Literal, 0600)
|
err := os.WriteFile(tmpPath, archive.Literal, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e := "failed to write file"
|
e := "failed to write file"
|
||||||
logger.Error(e, zap.Error(err), zap.String("location", tmpPath))
|
logger.Error(e, zap.Error(err), zap.String("location", tmpPath))
|
||||||
@@ -515,7 +515,7 @@ func (fetcher *Fetcher) UploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// parse request
|
// parse request
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error reading request body", zap.Error(err))
|
logger.Error("error reading request body", zap.Error(err))
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
@@ -614,7 +614,7 @@ func (fetcher *Fetcher) archive(src string, dst string) error {
|
|||||||
}
|
}
|
||||||
if target.IsDir() {
|
if target.IsDir() {
|
||||||
// list all
|
// list all
|
||||||
fs, _ := ioutil.ReadDir(src)
|
fs, _ := os.ReadDir(src)
|
||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
files = append(files, filepath.Join(src, f.Name()))
|
files = append(files, filepath.Join(src, f.Name()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package function
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -131,7 +131,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error reading response from function")
|
return errors.Wrap(err, "error reading response from function")
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ func printPodLogs(client client.Interface, fnMeta *metav1.ObjectMeta) (string, e
|
|||||||
}
|
}
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(reader)
|
body, err := io.ReadAll(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "error reading the response body")
|
return "", errors.Wrap(err, "error reading the response body")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -86,7 +85,7 @@ func UploadArchiveFile(ctx context.Context, client client.Interface, fileName st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetContents(filePath string) ([]byte, error) {
|
func GetContents(filePath string) ([]byte, error) {
|
||||||
code, err := ioutil.ReadFile(filePath)
|
code, err := os.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error reading %v", filePath)
|
return nil, errors.Wrapf(err, "error reading %v", filePath)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package spec
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -487,7 +486,7 @@ func localArchiveFromSpec(specDir string, aus *spectypes.ArchiveUploadSpec) (*fv
|
|||||||
|
|
||||||
if len(files) > 1 || !isSingleFile {
|
if len(files) > 1 || !isSingleFile {
|
||||||
// zip up the file list
|
// zip up the file list
|
||||||
archiveFile, err := ioutil.TempFile("", fmt.Sprintf("fission-archive-%v", aus.Name))
|
archiveFile, err := os.CreateTemp("", fmt.Sprintf("fission-archive-%v", aus.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package spec
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@@ -110,7 +109,7 @@ func (opts *InitSubCommand) run(input cli.Input) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a bit of documentation to the spec dir here
|
// Add a bit of documentation to the spec dir here
|
||||||
err := ioutil.WriteFile(readme, []byte(SPEC_README), 0644)
|
err := os.WriteFile(readme, []byte(SPEC_README), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -138,7 +137,7 @@ func writeDeploymentConfig(file string, dc *spectypes.DeploymentConfig) error {
|
|||||||
"# See the README in this directory for background and usage information.\n" +
|
"# See the README in this directory for background and usage information.\n" +
|
||||||
"# Do not edit the UID below: that will break 'fission spec apply'\n")
|
"# Do not edit the UID below: that will break 'fission spec apply'\n")
|
||||||
|
|
||||||
err = ioutil.WriteFile(file, append(msg, y...), 0644)
|
err = os.WriteFile(file, append(msg, y...), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package spec
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -234,7 +233,7 @@ func ReadSpecs(specDir string) (*FissionResources, error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// read
|
// read
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result = multierror.Append(result, err)
|
result = multierror.Append(result, err)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
@@ -55,7 +55,7 @@ func writeToFile(file string, obj interface{}) {
|
|||||||
// remove the empty byte from string.
|
// remove the empty byte from string.
|
||||||
file = string(utils.RemoveZeroBytes([]byte(file)))
|
file = string(utils.RemoveZeroBytes([]byte(file)))
|
||||||
|
|
||||||
err = ioutil.WriteFile(file, bs, 0644)
|
err = os.WriteFile(file, bs, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
console.Error(fmt.Sprintf("Error writing file %v: %v", file, err))
|
console.Error(fmt.Sprintf("Error writing file %v: %v", file, err))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -354,7 +354,7 @@ func invokeTriggeredFunction(conn AzureStorageConnection, sub *AzureQueueSubscri
|
|||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.logger.Error("failed to read response body from function invocation", zap.Error(err), zap.String("function_url", sub.functionURL))
|
conn.logger.Error("failed to read response body from function invocation", zap.Error(err), zap.String("function_url", sub.functionURL))
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package azurequeuestorage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -197,7 +197,7 @@ func TestAzureStorageQueuePoisonMessage(t *testing.T) {
|
|||||||
).Return(
|
).Return(
|
||||||
&http.Response{
|
&http.Response{
|
||||||
StatusCode: http.StatusInternalServerError,
|
StatusCode: http.StatusInternalServerError,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("server error")),
|
Body: io.NopCloser(strings.NewReader("server error")),
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
).Once()
|
).Once()
|
||||||
@@ -207,7 +207,7 @@ func TestAzureStorageQueuePoisonMessage(t *testing.T) {
|
|||||||
).Return(
|
).Return(
|
||||||
&http.Response{
|
&http.Response{
|
||||||
StatusCode: http.StatusNotFound,
|
StatusCode: http.StatusNotFound,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("not found")),
|
Body: io.NopCloser(strings.NewReader("not found")),
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
).Once()
|
).Once()
|
||||||
@@ -217,7 +217,7 @@ func TestAzureStorageQueuePoisonMessage(t *testing.T) {
|
|||||||
).Return(
|
).Return(
|
||||||
&http.Response{
|
&http.Response{
|
||||||
StatusCode: http.StatusBadRequest,
|
StatusCode: http.StatusBadRequest,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("bad request")),
|
Body: io.NopCloser(strings.NewReader("bad request")),
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
).Once()
|
).Once()
|
||||||
@@ -227,7 +227,7 @@ func TestAzureStorageQueuePoisonMessage(t *testing.T) {
|
|||||||
).Return(
|
).Return(
|
||||||
&http.Response{
|
&http.Response{
|
||||||
StatusCode: http.StatusForbidden,
|
StatusCode: http.StatusForbidden,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("not authorized")),
|
Body: io.NopCloser(strings.NewReader("not authorized")),
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
).Once()
|
).Once()
|
||||||
@@ -339,10 +339,10 @@ func TestAzureStorageQueuePoisonMessage(t *testing.T) {
|
|||||||
func httpRequestMatcher(t *testing.T, queue string, responseQueue string, retry string, contentType string, functionName string, body string) func(*http.Request) bool {
|
func httpRequestMatcher(t *testing.T, queue string, responseQueue string, retry string, contentType string, functionName string, body string) func(*http.Request) bool {
|
||||||
expectedURL := fmt.Sprintf("%s/fission-function/%s", DummyRouterURL, functionName)
|
expectedURL := fmt.Sprintf("%s/fission-function/%s", DummyRouterURL, functionName)
|
||||||
return func(req *http.Request) bool {
|
return func(req *http.Request) bool {
|
||||||
requestBody, err := ioutil.ReadAll(req.Body)
|
requestBody, err := io.ReadAll(req.Body)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
req.Body = ioutil.NopCloser(strings.NewReader(string(requestBody)))
|
req.Body = io.NopCloser(strings.NewReader(string(requestBody)))
|
||||||
|
|
||||||
return queue == req.Header.Get("X-Fission-MQTrigger-Topic") &&
|
return queue == req.Header.Get("X-Fission-MQTrigger-Topic") &&
|
||||||
responseQueue == req.Header.Get("X-Fission-MQTrigger-RespTopic") &&
|
responseQueue == req.Header.Get("X-Fission-MQTrigger-RespTopic") &&
|
||||||
@@ -372,7 +372,7 @@ func runAzureStorageQueueTest(t *testing.T, count int, output bool) {
|
|||||||
// Mock a HTTP client that returns http.StatusOK with "output" for the body
|
// Mock a HTTP client that returns http.StatusOK with "output" for the body
|
||||||
httpClient := new(azureHTTPClientMock)
|
httpClient := new(azureHTTPClientMock)
|
||||||
httpClient.bodyHandler = func(res *http.Response) {
|
httpClient.bodyHandler = func(res *http.Response) {
|
||||||
res.Body = ioutil.NopCloser(strings.NewReader(FunctionResponse))
|
res.Body = io.NopCloser(strings.NewReader(FunctionResponse))
|
||||||
}
|
}
|
||||||
httpClient.On(
|
httpClient.On(
|
||||||
"Do",
|
"Do",
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
sarama "github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
cluster "github.com/bsm/sarama-cluster"
|
cluster "github.com/bsm/sarama-cluster"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@@ -307,7 +307,7 @@ func kafkaMsgHandler(kafka *Kafka, producer sarama.SyncProducer, trigger *fv1.Me
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
kafka.logger.Debug("got response from function invocation",
|
kafka.logger.Debug("got response from function invocation",
|
||||||
zap.String("function_url", url),
|
zap.String("function_url", url),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package nats
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -192,7 +192,7 @@ func msgHandler(nats *Nats, trigger *fv1.MessageQueueTrigger) func(*ns.Msg) {
|
|||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, bodyErr := ioutil.ReadAll(resp.Body)
|
body, bodyErr := io.ReadAll(resp.Body)
|
||||||
if bodyErr != nil {
|
if bodyErr != nil {
|
||||||
nats.logger.Error("error reading function invocation response",
|
nats.logger.Error("error reading function invocation response",
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@@ -108,7 +107,7 @@ func FindAll() map[string]*Metadata {
|
|||||||
|
|
||||||
dirs := strings.Split(os.Getenv("PATH"), ":")
|
dirs := strings.Split(os.Getenv("PATH"), ":")
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
fs, err := ioutil.ReadDir(dir)
|
fs, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package plugin
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -47,7 +46,7 @@ func TestFind(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(testBinary, []byte(fmt.Sprintf("#!/bin/sh\necho '%v'", string(jsonMd))), os.ModePerm)
|
err = os.WriteFile(testBinary, []byte(fmt.Sprintf("#!/bin/sh\necho '%v'", string(jsonMd))), os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
@@ -89,7 +88,7 @@ func TestExec(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(testBinary, []byte(fmt.Sprintf("#!/bin/sh\necho '%v'", string(jsonMd))), os.ModePerm)
|
err = os.WriteFile(testBinary, []byte(fmt.Sprintf("#!/bin/sh\necho '%v'", string(jsonMd))), os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package publisher
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -112,7 +112,7 @@ func (p *WebhookPublisher) makeHTTPRequest(r *publishRequest) {
|
|||||||
fields = append(fields, zap.Error(err), zap.Any("request", r))
|
fields = append(fields, zap.Error(err), zap.Any("request", r))
|
||||||
} else {
|
} else {
|
||||||
var body []byte
|
var body []byte
|
||||||
body, err = ioutil.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fields = append(fields, zap.Error(err), zap.Any("request", r))
|
fields = append(fields, zap.Error(err), zap.Any("request", r))
|
||||||
msg = "read response body error"
|
msg = "read response body error"
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -242,7 +241,7 @@ func (roundTripper *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Re
|
|||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
ProtoMajor: req.ProtoMajor,
|
ProtoMajor: req.ProtoMajor,
|
||||||
ProtoMinor: req.ProtoMinor,
|
ProtoMinor: req.ProtoMinor,
|
||||||
Body: ioutil.NopCloser(bytes.NewBufferString(errMsg)),
|
Body: io.NopCloser(bytes.NewBufferString(errMsg)),
|
||||||
ContentLength: int64(len(errMsg)),
|
ContentLength: int64(len(errMsg)),
|
||||||
Request: req,
|
Request: req,
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
@@ -17,7 +17,7 @@ func testRequest(targetURL string, expectedResponse string) {
|
|||||||
log.Panicf("response status: %v", resp.StatusCode)
|
log.Panicf("response status: %v", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic("failed to read response")
|
log.Panic("failed to read response")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -101,7 +100,7 @@ func (c *Client) Upload(ctx context.Context, filePath string, metadata *map[stri
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -50,7 +49,7 @@ func panicIf(err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MakeTestFile(size int) *os.File {
|
func MakeTestFile(size int) *os.File {
|
||||||
f, err := ioutil.TempFile("", "storagesvc_test_")
|
f, err := os.CreateTemp("", "storagesvc_test_")
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
|
|
||||||
_, err = f.Write(bytes.Repeat([]byte("."), size))
|
_, err = f.Write(bytes.Repeat([]byte("."), size))
|
||||||
@@ -158,7 +157,7 @@ func TestS3StorageService(t *testing.T) {
|
|||||||
panicIf(err)
|
panicIf(err)
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
|
|
||||||
retThroughMinio, err := ioutil.TempFile("", "storagesvc_verify_minio_")
|
retThroughMinio, err := os.CreateTemp("", "storagesvc_verify_minio_")
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
defer os.Remove(retThroughMinio.Name())
|
defer os.Remove(retThroughMinio.Name())
|
||||||
|
|
||||||
@@ -170,7 +169,7 @@ func TestS3StorageService(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve file through API
|
// Retrieve file through API
|
||||||
retThroughAPI, err := ioutil.TempFile("", "storagesvc_verify_")
|
retThroughAPI, err := os.CreateTemp("", "storagesvc_verify_")
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
os.Remove(retThroughAPI.Name())
|
os.Remove(retThroughAPI.Name())
|
||||||
|
|
||||||
@@ -179,9 +178,9 @@ func TestS3StorageService(t *testing.T) {
|
|||||||
defer os.Remove(retThroughAPI.Name())
|
defer os.Remove(retThroughAPI.Name())
|
||||||
|
|
||||||
// compare contents
|
// compare contents
|
||||||
contentsMinio, err := ioutil.ReadFile(retThroughMinio.Name())
|
contentsMinio, err := os.ReadFile(retThroughMinio.Name())
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
contentsAPI, err := ioutil.ReadFile(retThroughAPI.Name())
|
contentsAPI, err := os.ReadFile(retThroughAPI.Name())
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
if !bytes.Equal(contentsMinio, contentsAPI) {
|
if !bytes.Equal(contentsMinio, contentsAPI) {
|
||||||
log.Panic("Contents don't match")
|
log.Panic("Contents don't match")
|
||||||
@@ -228,7 +227,7 @@ func TestLocalStorageService(t *testing.T) {
|
|||||||
panicIf(err)
|
panicIf(err)
|
||||||
|
|
||||||
// make a temp file for verification
|
// make a temp file for verification
|
||||||
retrievedfile, err := ioutil.TempFile("", "storagesvc_verify_")
|
retrievedfile, err := os.CreateTemp("", "storagesvc_verify_")
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
os.Remove(retrievedfile.Name())
|
os.Remove(retrievedfile.Name())
|
||||||
|
|
||||||
@@ -238,9 +237,9 @@ func TestLocalStorageService(t *testing.T) {
|
|||||||
defer os.Remove(retrievedfile.Name())
|
defer os.Remove(retrievedfile.Name())
|
||||||
|
|
||||||
// compare contents
|
// compare contents
|
||||||
contents1, err := ioutil.ReadFile(tmpfile.Name())
|
contents1, err := os.ReadFile(tmpfile.Name())
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
contents2, err := ioutil.ReadFile(retrievedfile.Name())
|
contents2, err := os.ReadFile(retrievedfile.Name())
|
||||||
panicIf(err)
|
panicIf(err)
|
||||||
if !bytes.Equal(contents1, contents2) {
|
if !bytes.Equal(contents1, contents2) {
|
||||||
log.Panic("Contents don't match")
|
log.Panic("Contents don't match")
|
||||||
|
|||||||
+1
-2
@@ -22,7 +22,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -65,7 +64,7 @@ func GetTempDir() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
tmpDir := id.String()
|
tmpDir := id.String()
|
||||||
dir, err := ioutil.TempDir("", tmpDir)
|
dir, err := os.MkdirTemp("", tmpDir)
|
||||||
return dir, err
|
return dir, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -163,7 +162,7 @@ func generateChart(title string, file string, format chart.RendererProvider, ser
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(file, buffer.Bytes(), 0644)
|
err = os.WriteFile(file, buffer.Bytes(), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user