mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
Refactor: move from io/ioutil to io and os package (#2234)
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 <zerjun@beatchain.co>
This commit is contained in:
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package assemble
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@@ -43,7 +43,7 @@ var _ = Describe("Test Assemble Options", func() {
|
||||
)
|
||||
|
||||
appRev := &v1beta1.ApplicationRevision{}
|
||||
b, err := ioutil.ReadFile("./testdata/apprevision.yaml")
|
||||
b, err := os.ReadFile("./testdata/apprevision.yaml")
|
||||
/* appRevision test data is generated based on below application
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
@@ -156,7 +156,7 @@ var _ = Describe("Test Assemble Options", func() {
|
||||
compName = "frontend"
|
||||
)
|
||||
appRev := &v1beta1.ApplicationRevision{}
|
||||
b, err := ioutil.ReadFile("./testdata/filter_annotations.yaml")
|
||||
b, err := os.ReadFile("./testdata/filter_annotations.yaml")
|
||||
getKeys := func(m map[string]string) []string {
|
||||
var keys []string
|
||||
for k := range m {
|
||||
|
||||
@@ -19,7 +19,7 @@ package assemble
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
@@ -49,7 +49,7 @@ var _ = Describe("Test WorkloadOption", func() {
|
||||
|
||||
BeforeEach(func() {
|
||||
appRev = &v1beta1.ApplicationRevision{}
|
||||
b, err := ioutil.ReadFile("./testdata/apprevision.yaml")
|
||||
b, err := os.ReadFile("./testdata/apprevision.yaml")
|
||||
Expect(err).Should(BeNil())
|
||||
err = yaml.Unmarshal(b, appRev)
|
||||
Expect(err).Should(BeNil())
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
@@ -61,7 +61,7 @@ func (c *ComponentHandler) customComponentRevisionHook(relatedApps []reconcile.R
|
||||
}
|
||||
//nolint:errcheck
|
||||
defer resp.Body.Close()
|
||||
respData, err := ioutil.ReadAll(resp.Body)
|
||||
respData, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package applicationconfiguration
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
|
||||
var RevisionHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var req RevisionHookRequest
|
||||
data, err := ioutil.ReadAll(r.Body)
|
||||
data, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user