From 35957f9b9d7f43f31bd4aa14fbeac4ba34cb136f Mon Sep 17 00:00:00 2001 From: kpango Date: Fri, 10 Mar 2023 10:07:49 +0900 Subject: [PATCH 1/2] Refactor conv.go Update conv.go Signed-off-by: kpango --- example/client/go.mod | 4 +- example/client/go.sum | 8 +-- go.mod | 42 ++++++++-------- go.sum | 50 +++++++++---------- hack/helm/schema/crd/main.go | 3 +- hack/helm/schema/gen/main.go | 3 +- internal/config/config.go | 2 +- internal/conv/conv.go | 34 ++++--------- .../blob/cloudstorage/urlopener/urlopener.go | 2 +- internal/encoding/json/json_test.go | 3 +- internal/net/dialer_test.go | 8 ++- internal/net/http/dump/dump_test.go | 3 +- internal/net/net_test.go | 8 ++- internal/runner/runner.go | 5 +- internal/safety/safety.go | 3 +- internal/tls/tls.go | 2 +- internal/tls/tls_test.go | 7 +-- tests/e2e/performance/max_vector_dim_test.go | 3 +- versions/HELM_VERSION | 2 +- versions/PROMETHEUS_STACK_VERSION | 2 +- versions/VALDCLI_VERSION | 2 +- 21 files changed, 99 insertions(+), 97 deletions(-) diff --git a/example/client/go.mod b/example/client/go.mod index 8d11bd8769..50580f6d94 100644 --- a/example/client/go.mod +++ b/example/client/go.mod @@ -5,7 +5,7 @@ go 1.20 replace ( github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.9.1 github.com/goccy/go-json => github.com/goccy/go-json v0.10.0 - github.com/golang/protobuf => github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf => github.com/golang/protobuf v1.5.3 github.com/kpango/glg => github.com/kpango/glg v1.6.14 github.com/pkg/sftp => github.com/pkg/sftp v1.13.5 golang.org/x/crypto => golang.org/x/crypto v0.7.0 @@ -13,7 +13,7 @@ replace ( golang.org/x/text => golang.org/x/text v0.8.0 google.golang.org/genproto => google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 google.golang.org/grpc => google.golang.org/grpc v1.53.0 - google.golang.org/protobuf => google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf => google.golang.org/protobuf v1.29.0 gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1 ) diff --git a/example/client/go.sum b/example/client/go.sum index 0326ec869d..67288746ea 100644 --- a/example/client/go.sum +++ b/example/client/go.sum @@ -2,8 +2,8 @@ github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22 github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/kpango/fastime v1.1.6 h1:lAw1Tiwnlbsx1xZs6W9eM7/8niwabknewbmLkh/yTVo= @@ -31,5 +31,5 @@ google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0= +google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/go.mod b/go.mod index fa14f641af..7bc9938e78 100755 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ replace ( github.com/armon/go-radix => github.com/armon/go-radix v1.0.0 github.com/armon/go-socks5 => github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 github.com/asaskevich/govalidator => github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 - github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.216 + github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.218 github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.17.5 github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.18.15 @@ -113,8 +113,8 @@ replace ( github.com/containerd/go-runc => github.com/containerd/go-runc v1.0.0 github.com/containerd/imgcrypt => github.com/containerd/imgcrypt v1.1.7 github.com/containerd/nri => github.com/containerd/nri v0.3.0 - github.com/containerd/stargz-snapshotter/estargz => github.com/containerd/stargz-snapshotter/estargz v0.14.2 - github.com/containerd/ttrpc => github.com/containerd/ttrpc v1.2.0 + github.com/containerd/stargz-snapshotter/estargz => github.com/containerd/stargz-snapshotter/estargz v0.14.3 + github.com/containerd/ttrpc => github.com/containerd/ttrpc v1.2.1 github.com/containerd/typeurl => github.com/containerd/typeurl v1.0.2 github.com/containerd/zfs => github.com/containerd/zfs v1.0.0 github.com/containernetworking/cni => github.com/containernetworking/cni v1.1.2 @@ -149,7 +149,7 @@ replace ( github.com/edsrzf/mmap-go => github.com/edsrzf/mmap-go v1.1.0 github.com/elazarl/goproxy => github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 github.com/emicklei/go-restful => github.com/emicklei/go-restful v2.16.0+incompatible - github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.1 + github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.2 github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.11.0 github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.9.1 github.com/evanphx/json-patch => github.com/evanphx/json-patch v0.5.2 @@ -214,7 +214,7 @@ replace ( github.com/golang/glog => github.com/golang/glog v1.1.0 github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/golang/mock => github.com/golang/mock v1.6.0 - github.com/golang/protobuf => github.com/golang/protobuf v1.5.2 + github.com/golang/protobuf => github.com/golang/protobuf v1.5.3 github.com/golang/snappy => github.com/golang/snappy v0.0.4 github.com/google/btree => github.com/google/btree v1.1.2 github.com/google/gnostic => github.com/google/gnostic v0.6.9 @@ -226,12 +226,12 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v1.2.0 github.com/google/martian => github.com/google/martian v2.1.0+incompatible github.com/google/martian/v3 => github.com/google/martian/v3 v3.3.2 - github.com/google/pprof => github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 + github.com/google/pprof => github.com/google/pprof v0.0.0-20230309165930-d61513b1440d github.com/google/shlex => github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/subcommands => github.com/google/subcommands v1.2.0 github.com/google/uuid => github.com/google/uuid v1.3.0 github.com/google/wire => github.com/google/wire v0.5.0 - github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.7.0 + github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.7.1 github.com/gorilla/mux => github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket => github.com/gorilla/websocket v1.5.0 github.com/grafana/regexp => github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd @@ -290,7 +290,7 @@ replace ( github.com/julienschmidt/httprouter => github.com/julienschmidt/httprouter v1.3.0 github.com/kisielk/errcheck => github.com/kisielk/errcheck v1.6.3 github.com/kisielk/gotool => github.com/kisielk/gotool v1.0.0 - github.com/klauspost/compress => github.com/klauspost/compress v1.16.1-0.20230307192655-0ba001030d7c + github.com/klauspost/compress => github.com/klauspost/compress v1.16.1-0.20230308121633-3588812afd49 github.com/klauspost/cpuid/v2 => github.com/klauspost/cpuid/v2 v2.2.4 github.com/kolo/xmlrpc => github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b github.com/kpango/fastime => github.com/kpango/fastime v1.1.7 @@ -354,10 +354,10 @@ replace ( github.com/prometheus/alertmanager => github.com/prometheus/alertmanager v0.25.0 github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.14.0 github.com/prometheus/client_model => github.com/prometheus/client_model v0.3.0 - github.com/prometheus/common => github.com/prometheus/common v0.41.0 + github.com/prometheus/common => github.com/prometheus/common v0.42.0 github.com/prometheus/common/assets => github.com/prometheus/common/assets v0.2.0 github.com/prometheus/common/sigv4 => github.com/prometheus/common/sigv4 v0.1.0 - github.com/prometheus/exporter-toolkit => github.com/prometheus/exporter-toolkit v0.9.0 + github.com/prometheus/exporter-toolkit => github.com/prometheus/exporter-toolkit v0.9.1 github.com/prometheus/procfs => github.com/prometheus/procfs v0.9.0 github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.99.0 github.com/prometheus/prometheus/v2 => github.com/prometheus/prometheus/v2 v2.35.0-retract @@ -373,9 +373,9 @@ replace ( github.com/russross/blackfriday/v2 => github.com/russross/blackfriday/v2 v2.1.0 github.com/ruudk/golang-pdf417 => github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245 github.com/ryanuber/columnize => github.com/ryanuber/columnize v2.1.2+incompatible - github.com/safchain/ethtool => github.com/safchain/ethtool v0.2.0 + github.com/safchain/ethtool => github.com/safchain/ethtool v0.3.0 github.com/satori/go.uuid => github.com/satori/go.uuid v1.2.0 - github.com/scaleway/scaleway-sdk-go => github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13 + github.com/scaleway/scaleway-sdk-go => github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14 github.com/schollz/progressbar/v2 => github.com/schollz/progressbar/v2 v2.15.0 github.com/scylladb/go-reflectx => github.com/scylladb/go-reflectx v1.0.1 github.com/scylladb/gocqlx => github.com/scylladb/gocqlx v1.5.0 @@ -397,7 +397,7 @@ replace ( github.com/stoewer/go-strcase => github.com/stoewer/go-strcase v1.2.1 github.com/stretchr/objx => github.com/stretchr/objx v0.5.0 github.com/stretchr/testify => github.com/stretchr/testify v1.8.2 - github.com/ugorji/go/codec => github.com/ugorji/go/codec v1.2.10 + github.com/ugorji/go/codec => github.com/ugorji/go/codec v1.2.11 github.com/vdaas/vald-client-go => github.com/vdaas/vald-client-go v1.7.2 github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0 github.com/vishvananda/netns => github.com/vishvananda/netns v0.0.4 @@ -408,7 +408,7 @@ replace ( github.com/xeipuuv/gojsonreference => github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 github.com/xeipuuv/gojsonschema => github.com/xeipuuv/gojsonschema v1.2.0 github.com/xiang90/probing => github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 - github.com/xlab/treeprint => github.com/xlab/treeprint v1.1.0 + github.com/xlab/treeprint => github.com/xlab/treeprint v1.2.0 github.com/zeebo/assert => github.com/zeebo/assert v1.3.1 github.com/zeebo/xxh3 => github.com/zeebo/xxh3 v1.0.2 go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.7 @@ -438,7 +438,7 @@ replace ( go.uber.org/atomic => go.uber.org/atomic v1.10.0 go.uber.org/automaxprocs => go.uber.org/automaxprocs v1.5.1 go.uber.org/goleak => go.uber.org/goleak v1.2.1 - go.uber.org/multierr => go.uber.org/multierr v1.9.0 + go.uber.org/multierr => go.uber.org/multierr v1.10.0 go.uber.org/zap => go.uber.org/zap v1.24.0 gocloud.dev => gocloud.dev v0.29.0 golang.org/x/crypto => golang.org/x/crypto v0.7.0 @@ -461,12 +461,12 @@ replace ( gonum.org/v1/gonum => gonum.org/v1/gonum v0.12.0 gonum.org/v1/hdf5 => gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 gonum.org/v1/plot => gonum.org/v1/plot v0.12.0 - google.golang.org/api => google.golang.org/api v0.111.0 + google.golang.org/api => google.golang.org/api v0.112.0 google.golang.org/appengine => google.golang.org/appengine v1.6.7 google.golang.org/genproto => google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 google.golang.org/grpc => google.golang.org/grpc v1.53.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc => google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 - google.golang.org/protobuf => google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf => google.golang.org/protobuf v1.29.0 gopkg.in/alecthomas/kingpin.v2 => gopkg.in/alecthomas/kingpin.v2 v2.3.2 gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c gopkg.in/gcfg.v1 => gopkg.in/gcfg.v1 v1.2.3 @@ -489,7 +489,7 @@ replace ( k8s.io/gengo => k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4 k8s.io/klog => k8s.io/klog v1.0.0 k8s.io/klog/v2 => k8s.io/klog/v2 v2.90.1 - k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d + k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a k8s.io/kubernetes => k8s.io/kubernetes v0.26.2 k8s.io/metrics => k8s.io/metrics v0.26.2 nhooyr.io/websocket => nhooyr.io/websocket v1.8.7 @@ -545,14 +545,14 @@ require ( gocloud.dev v0.0.0-00010101000000-000000000000 golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 golang.org/x/net v0.8.0 - golang.org/x/oauth2 v0.5.0 + golang.org/x/oauth2 v0.6.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.6.0 golang.org/x/text v0.8.0 golang.org/x/tools v0.6.0 gonum.org/v1/hdf5 v0.0.0-00010101000000-000000000000 gonum.org/v1/plot v0.10.1 - google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 + google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488 google.golang.org/grpc v1.53.0 google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 v2.4.0 @@ -648,7 +648,7 @@ require ( golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect - google.golang.org/api v0.110.0 // indirect + google.golang.org/api v0.111.0 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 5f2579b97f..80a1510358 100644 --- a/go.sum +++ b/go.sum @@ -200,8 +200,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/aws/aws-sdk-go v1.44.216 h1:nDL5hEGBlUNHXMWbpP4dIyP8IB5tvRgksWE7biVu8JY= -github.com/aws/aws-sdk-go v1.44.216/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.218 h1:p707+xOCazWhkSpZOeyhtTcg7Z+asxxvueGgYPSitn4= +github.com/aws/aws-sdk-go v1.44.218/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.5 h1:TzCUW1Nq4H8Xscph5M/skINUitxM5UBAyvm2s7XBzL4= github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= @@ -287,8 +287,8 @@ github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5O github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= +github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.11.0/go.mod h1:VnHyVMpzcLvCFt9yUz1UnCwHLhwx1WguiVDV7pTG/tI= github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= @@ -383,8 +383,8 @@ github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= @@ -404,8 +404,8 @@ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPg github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= -github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20230309165930-d61513b1440d h1:um9/pc7tKMINFfP1eE7Wv6PRGXlcCSJkVajF7KJw3uQ= +github.com/google/pprof v0.0.0-20230309165930-d61513b1440d/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= @@ -417,8 +417,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/ github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/gax-go/v2 v2.7.0 h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1YupQSSQ= -github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= +github.com/googleapis/gax-go/v2 v2.7.1 h1:gF4c0zjUP2H/s/hEGyLA3I0fA2ZWjzYiONAD6cvPr8A= +github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= @@ -476,8 +476,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C github.com/kisielk/errcheck v1.6.3/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= -github.com/klauspost/compress v1.16.1-0.20230307192655-0ba001030d7c h1:UoniMrMMfNJ6aA7gYFfIclP5soXOYoxV2dhOQb/dfNc= -github.com/klauspost/compress v1.16.1-0.20230307192655-0ba001030d7c/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.1-0.20230308121633-3588812afd49 h1:Sl4uyozPjbMhEl0Sz+E89gLPh5bYrPwQ7HD3w068/4w= +github.com/klauspost/compress v1.16.1-0.20230308121633-3588812afd49/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kpango/fastime v1.1.7 h1:xaWENHzTrfzAmqhLayoLVJFF0MBf1EGZL9FL6V/OyDo= @@ -564,8 +564,8 @@ github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.41.0 h1:npo01n6vUlRViIj5fgwiK8vlNIh8bnoxqh3gypKsyAw= -github.com/prometheus/common v0.41.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/prometheus v1.99.0/go.mod h1:Sw35iJlN8dvKz51BtqxhXpNLIfqNn9IFAo64r7XL9Bw= @@ -613,15 +613,15 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.10/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/vdaas/vald-client-go v1.7.2 h1:+rP/RZCU2EfRbH9J3xSUeFk57Di60lwvagpZ+/VmgpY= github.com/vdaas/vald-client-go v1.7.2/go.mod h1:12JFkKHaCTYH7GrMWt1p+GkfSdmYCOtVJydNZtBaY0k= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk= -github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= +github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= +github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= github.com/yuin/goldmark v1.3.8/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.10/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -663,8 +663,8 @@ go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= gocloud.dev v0.29.0 h1:fBy0jwJSmxs0IjT0fE32MO+Mj+307VZQwyHaTyFZbC4= @@ -709,8 +709,8 @@ gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 h1:vJpL69PeUullhJyKtTjHjENE gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= gonum.org/v1/plot v0.12.0 h1:y1ZNmfz/xHuHvtgFe8USZVyykQo5ERXPnspQNVK15Og= gonum.org/v1/plot v0.12.0/go.mod h1:PgiMf9+3A3PnZdJIciIXmyN1FwdAA6rXELSN761oQkw= -google.golang.org/api v0.111.0 h1:bwKi+z2BsdwYFRKrqwutM+axAlYLz83gt5pDSXCJT+0= -google.golang.org/api v0.111.0/go.mod h1:qtFHvU9mhgTJegR31csQ+rwxyUTHOKFqCKWp1J0fdw0= +google.golang.org/api v0.112.0 h1:iDmzvZ4C086R3+en4nSyIf07HlQKMOX1Xx2dmia/+KQ= +google.golang.org/api v0.112.0/go.mod h1:737UfWHNsOq4F3REUTmb+GN9pugkgNLCayLTfoIKpPc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= @@ -718,8 +718,8 @@ google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVix google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0= +google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inconshreveable/log15.v2 v2.16.0/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= @@ -747,8 +747,8 @@ k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI= k8s.io/component-base v0.26.2/go.mod h1:DxbuIe9M3IZPRxPIzhch2m1eT7uFrSBJUBuVCQEBivs= k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d h1:VcFq5n7wCJB2FQMCIHfC+f+jNcGgNMar1uKd6rVlifU= -k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= +k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg= +k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= k8s.io/metrics v0.26.2 h1:2gUvUWWnHPdE2tyA5DvyHC8HGryr+izhY9i5dzLP06s= k8s.io/metrics v0.26.2/go.mod h1:PX1wm9REV9hSGuw9GcXTFNDgab1KRXck3mNeiLYbRho= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= diff --git a/hack/helm/schema/crd/main.go b/hack/helm/schema/crd/main.go index 0294cf4dfa..6c3a0eda13 100644 --- a/hack/helm/schema/crd/main.go +++ b/hack/helm/schema/crd/main.go @@ -24,6 +24,7 @@ import ( "os" "strconv" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/strings" @@ -154,7 +155,7 @@ func genSchema(path string, nindent int) error { return errors.Errorf("error: %s", err) } - fmt.Println(indent(string(yaml), nindent)) + fmt.Println(indent(conv.Btoa(yaml), nindent)) return nil } diff --git a/hack/helm/schema/gen/main.go b/hack/helm/schema/gen/main.go index 8d237bec4a..571ef6ddc0 100644 --- a/hack/helm/schema/gen/main.go +++ b/hack/helm/schema/gen/main.go @@ -24,6 +24,7 @@ import ( "os" "regexp" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/strings" @@ -179,7 +180,7 @@ func genJSONSchema(path string) error { return errors.Errorf("error: %s", err) } - fmt.Println(string(json)) + fmt.Println(conv.Btoa(json)) return nil } diff --git a/internal/config/config.go b/internal/config/config.go index a142da159b..04d64285f8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -99,7 +99,7 @@ func GetActualValue(val string) (res string) { res = os.ExpandEnv(val) if strings.HasPrefix(res, fileValuePrefix) { body, err := file.ReadFile(strings.TrimPrefix(res, fileValuePrefix)) - if err != nil { + if err != nil || body == nil { return } res = conv.Btoa(body) diff --git a/internal/conv/conv.go b/internal/conv/conv.go index 75287b7862..62fcc92bd1 100644 --- a/internal/conv/conv.go +++ b/internal/conv/conv.go @@ -15,7 +15,6 @@ package conv import ( "io" - "reflect" "strings" "unsafe" @@ -25,39 +24,26 @@ import ( // Btoa converts from byte slice to string. func Btoa(b []byte) (s string) { + if b == nil || len(b) == 0 { + return "" + } // skipcq: GSC-G103 - slh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - // skipcq: GSC-G103 - sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) - sh.Data = slh.Data - sh.Len = slh.Len - return s + return unsafe.String(&b[0], len(b)) } // Atobs converts from string to byte slice. func Atob(s string) (b []byte) { + if s == "" { + return nil + } // skipcq: GSC-G103 - sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) - // skipcq: GSC-G103 - slh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - slh.Data = sh.Data - slh.Len = sh.Len - slh.Cap = sh.Len - return b + return unsafe.Slice(unsafe.StringData(s), len(s)) } // F32stos converts from float32 slice to type string. func F32stos(fs []float32) (s string) { - lf := 4 * len(fs) - // skipcq: GSC-G103 - buf := (*(*[1]byte)(unsafe.Pointer(&(fs[0]))))[:] - // skipcq: GSC-G103 - addr := unsafe.Pointer(&buf) - // skipcq: GSC-G103 - (*(*int)(unsafe.Pointer(uintptr(addr) + uintptr(8)))) = lf // skipcq: GSC-G103 - (*(*int)(unsafe.Pointer(uintptr(addr) + uintptr(16)))) = lf - return Btoa(buf) + return Btoa(unsafe.Slice((*byte)(unsafe.Pointer(&fs[0])), len(fs)*4)) } // Utf8ToSjis converts a UTF8 string to sjis string. @@ -75,5 +61,5 @@ func encode(r io.Reader, t transform.Transformer) (string, error) { if err != nil { return "", err } - return string(b), nil + return Btoa(b), nil } diff --git a/internal/db/storage/blob/cloudstorage/urlopener/urlopener.go b/internal/db/storage/blob/cloudstorage/urlopener/urlopener.go index 296acdb08c..84c4b8936c 100644 --- a/internal/db/storage/blob/cloudstorage/urlopener/urlopener.go +++ b/internal/db/storage/blob/cloudstorage/urlopener/urlopener.go @@ -62,7 +62,7 @@ func (uo *urlOpener) URLOpener(ctx context.Context) (guo *gcsblob.URLOpener, err switch { case len(uo.credentialsFilePath) != 0: data, err := file.ReadFile(uo.credentialsFilePath) - if err != nil { + if err != nil || data == nil { return nil, err } creds, err = google.CredentialsFromJSON(ctx, data, scope) diff --git a/internal/encoding/json/json_test.go b/internal/encoding/json/json_test.go index 0d361281f9..0b9274a21c 100644 --- a/internal/encoding/json/json_test.go +++ b/internal/encoding/json/json_test.go @@ -18,6 +18,7 @@ import ( "reflect" "testing" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/io" ) @@ -191,7 +192,7 @@ func TestMarshalIndent(t *testing.T) { } if got, want := data, []byte("{\n\"name\": \"vald\"\n}"); !reflect.DeepEqual(got, want) { - return errors.Errorf("data not equals. want: %v, got: %v", string(want), string(got)) + return errors.Errorf("data not equals. want: %v, got: %v", conv.Btoa(want), conv.Btoa(got)) } return nil diff --git a/internal/net/dialer_test.go b/internal/net/dialer_test.go index 18171c1c6b..4952c1f42b 100644 --- a/internal/net/dialer_test.go +++ b/internal/net/dialer_test.go @@ -34,6 +34,7 @@ import ( "github.com/vdaas/vald/internal/cache" "github.com/vdaas/vald/internal/cache/cacher" "github.com/vdaas/vald/internal/cache/gache" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/io" "github.com/vdaas/vald/internal/strings" @@ -1165,8 +1166,11 @@ func Test_dialer_cachedDialer(t *testing.T) { // read the output from the server and check if it is equals to the count fmt.Fprintf(gotConn, "GET / HTTP/1.0\r\n\r\n") - buf, _ := io.ReadAll(gotConn) - content := strings.Split(string(buf), "\n")[5] // skip HTTP header + buf, err := io.ReadAll(gotConn) + if err != nil || buf == nil { + return errors.Errorf("error or buffer is nil,\terror: %v, buf: %v", err, buf) + } + content := strings.Split(conv.Btoa(buf), "\n")[5] // skip HTTP header if content != srvContent { return errors.Errorf("excepted output from server, got: %v, want: %v", content, srvContent) } diff --git a/internal/net/http/dump/dump_test.go b/internal/net/http/dump/dump_test.go index 2c24a18025..6eeda60c11 100644 --- a/internal/net/http/dump/dump_test.go +++ b/internal/net/http/dump/dump_test.go @@ -18,6 +18,7 @@ import ( "net/url" "testing" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/encoding/json" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/test/goleak" @@ -78,7 +79,7 @@ func TestRequest(t *testing.T) { } str := `{"host":"hoge","uri":"uri","url":"http:","method":"GET","proto":"proto","header":{},"transfer_encoding":["trans1"],"remote_addr":"0.0.0.0","content_length":1234,"body":{"name":"vald"},"values":{"version":"1.0.0"}}` - if got, want := string(b), str; got != want { + if got, want := conv.Btoa(b), str; got != want { return errors.Errorf("response not equals. want: %v, got: %v", want, got) } diff --git a/internal/net/net_test.go b/internal/net/net_test.go index ef5d08e680..6d9c22e677 100644 --- a/internal/net/net_test.go +++ b/internal/net/net_test.go @@ -27,6 +27,7 @@ import ( "reflect" "testing" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/io" "github.com/vdaas/vald/internal/log" @@ -186,8 +187,11 @@ func TestDialContext(t *testing.T) { // read the output from the server and check if it is equals to the count fmt.Fprintf(gotConn, "GET / HTTP/1.0\r\n\r\n") - buf, _ := io.ReadAll(gotConn) - content := strings.Split(string(buf), "\n")[5] // skip HTTP header + buf, err := io.ReadAll(gotConn) + if err != nil || buf == nil { + return errors.Errorf("error or buffer is nil,\terror: %v, buf: %v", err, buf) + } + content := strings.Split(conv.Btoa(buf), "\n")[5] // skip HTTP header if content != srvContent { return errors.Errorf("invalid content, got: %v, want: %v", content, srvContent) } diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 7d26c97dde..fd6da03e7b 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -24,6 +24,7 @@ import ( "syscall" "github.com/vdaas/vald/internal/config" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/encoding/json" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" @@ -102,13 +103,13 @@ func Do(ctx context.Context, opts ...Option) error { if err != nil { return "failed to serialize build information" } - return string(b) + return conv.Btoa(b) }(), func() string { b, err := json.Marshal(cfg) if err != nil { return "failed to serialize configuration" } - return string(b) + return conv.Btoa(b) }()) // set location temporary for initialization logging diff --git a/internal/safety/safety.go b/internal/safety/safety.go index 69bee06aa2..f073c422bc 100644 --- a/internal/safety/safety.go +++ b/internal/safety/safety.go @@ -21,6 +21,7 @@ import ( "runtime" "runtime/debug" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" @@ -38,7 +39,7 @@ func recoverFn(fn func() error, withPanic bool) func() error { return func() (err error) { defer func() { if r := recover(); r != nil { - stack := string(debug.Stack()) + stack := conv.Btoa(debug.Stack()) log.Warnf("recovered: %#v\nstacktrace:\n%s", r, stack) switch x := r.(type) { case runtime.Error: diff --git a/internal/tls/tls.go b/internal/tls/tls.go index aedade8464..25e122176c 100644 --- a/internal/tls/tls.go +++ b/internal/tls/tls.go @@ -107,7 +107,7 @@ func NewClientConfig(opts ...Option) (*Config, error) { // The CertPool will read the certificate from the path, and append the content to the system certificate pool, and return. func NewX509CertPool(path string) (pool *x509.CertPool, err error) { c, err := file.ReadFile(path) - if err != nil { + if err != nil || c == nil { return nil, err } if err == nil && c != nil { diff --git a/internal/tls/tls_test.go b/internal/tls/tls_test.go index 361f5f1302..b1e7b849d6 100644 --- a/internal/tls/tls_test.go +++ b/internal/tls/tls_test.go @@ -24,6 +24,7 @@ import ( "reflect" "testing" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/file" testdata "github.com/vdaas/vald/internal/test" @@ -93,8 +94,8 @@ func TestNew(t *testing.T) { return errors.New("Certificates length is wrong") } - want := string(w.want.Certificates[0].Certificate[0]) - got := string(c.Certificates[0].Certificate[0]) + want := conv.Btoa(w.want.Certificates[0].Certificate[0]) + got := conv.Btoa(c.Certificates[0].Certificate[0]) if want != got { return errors.Errorf("Certificates[0] want: %v, but got: %v", want, got) } @@ -341,7 +342,7 @@ func TestNewX509CertPool(t *testing.T) { pool = x509.NewCertPool() } b, err := file.ReadFile(path) - if err == nil { + if err == nil && b != nil { pool.AppendCertsFromPEM(b) } return pool diff --git a/tests/e2e/performance/max_vector_dim_test.go b/tests/e2e/performance/max_vector_dim_test.go index 7eb6808774..9af756cf68 100644 --- a/tests/e2e/performance/max_vector_dim_test.go +++ b/tests/e2e/performance/max_vector_dim_test.go @@ -30,6 +30,7 @@ import ( "github.com/vdaas/vald-client-go/v1/payload" "github.com/vdaas/vald-client-go/v1/vald" + "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/core/algorithm" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/file" @@ -183,7 +184,7 @@ func TestE2EInsertOnlyWithOneVectorAndSearch(t *testing.T) { t.Fatalf("TestE2EInsertOnlyWithOneVectorAndSearch\tMarshalIndent Error: %v", err) } t.Logf("[Pass] SearchByID process (Bit = %d)", bit) - if string(b) != "" { + if conv.Btoa(b) != "" { os.WriteFile(fileName, []byte("OK"), os.ModePerm) return } diff --git a/versions/HELM_VERSION b/versions/HELM_VERSION index c431007116..89d85a8a9b 100644 --- a/versions/HELM_VERSION +++ b/versions/HELM_VERSION @@ -1 +1 @@ -v3.11.1 +v3.11.2 diff --git a/versions/PROMETHEUS_STACK_VERSION b/versions/PROMETHEUS_STACK_VERSION index 66230c6fc3..87425129cb 100644 --- a/versions/PROMETHEUS_STACK_VERSION +++ b/versions/PROMETHEUS_STACK_VERSION @@ -1 +1 @@ -45.6.0 +45.7.1 diff --git a/versions/VALDCLI_VERSION b/versions/VALDCLI_VERSION index a97fc4411a..3b34d22941 100644 --- a/versions/VALDCLI_VERSION +++ b/versions/VALDCLI_VERSION @@ -1 +1 @@ -v1.7.1 +v1.7.2 From eccba1bfe712c37c181c6cfb5199dd13fb1883f2 Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Fri, 10 Mar 2023 12:26:15 +0900 Subject: [PATCH 2/2] Update internal/conv/conv.go Co-authored-by: Kiichiro YUKAWA --- internal/conv/conv.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/conv/conv.go b/internal/conv/conv.go index 62fcc92bd1..300bc12a94 100644 --- a/internal/conv/conv.go +++ b/internal/conv/conv.go @@ -24,7 +24,7 @@ import ( // Btoa converts from byte slice to string. func Btoa(b []byte) (s string) { - if b == nil || len(b) == 0 { + if len(b) == 0 { return "" } // skipcq: GSC-G103