Fix unmaarshal of double pointer (#47586)

* Fix unmaarshal of double pointer

* update sdk version
This commit is contained in:
ying-jeanne 2022-04-12 09:30:34 +02:00 committed by GitHub
parent 42431e6ad4
commit 0bf889e058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 20 additions and 15 deletions

4
go.mod
View File

@ -53,7 +53,7 @@ require (
github.com/grafana/cuetsy v0.0.0-20211119211437-8c25464cc9bf
github.com/grafana/grafana-aws-sdk v0.10.1
github.com/grafana/grafana-azure-sdk-go v1.1.0
github.com/grafana/grafana-plugin-sdk-go v0.129.0
github.com/grafana/grafana-plugin-sdk-go v0.131.0
github.com/grafana/loki v1.6.2-0.20211015002020-7832783b1caa
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/hashicorp/go-hclog v0.16.1
@ -272,7 +272,7 @@ require (
github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac // indirect
github.com/envoyproxy/go-control-plane v0.10.1 // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
github.com/getkin/kin-openapi v0.91.0 // indirect
github.com/getkin/kin-openapi v0.94.0 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
github.com/imdario/mergo v0.3.12 // indirect

4
go.sum
View File

@ -870,6 +870,8 @@ github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.91.0 h1:mOSAljTAQONM0YVtI3+LvIQaa0zPwa3SH6UuiyEnbYQ=
github.com/getkin/kin-openapi v0.91.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
github.com/getkin/kin-openapi v0.94.0 h1:bAxg2vxgnHHHoeefVdmGbR+oxtJlcv5HsJJa3qmAHuo=
github.com/getkin/kin-openapi v0.94.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/getsentry/sentry-go v0.10.0 h1:6gwY+66NHKqyZrdi6O2jGdo7wGdo9b3B69E01NFgT5g=
github.com/getsentry/sentry-go v0.10.0/go.mod h1:kELm/9iCblqUYh+ZRML7PNdCvEuw24wBvJPYyi86cws=
@ -1368,6 +1370,8 @@ github.com/grafana/grafana-plugin-sdk-go v0.114.0/go.mod h1:D7x3ah+1d4phNXpbnOax
github.com/grafana/grafana-plugin-sdk-go v0.125.0/go.mod h1:9YiJ5GUxIsIEUC0qR9+BJVP5M7mCSP6uc6Ne62YKkgc=
github.com/grafana/grafana-plugin-sdk-go v0.129.0 h1:apmA8x59QvW5Wov+FhAfM0IiNGjMi8V2Ou7xyMk1leE=
github.com/grafana/grafana-plugin-sdk-go v0.129.0/go.mod h1:4edtosZepfQF9jkQwRywJsNSJzXTHmzbmcVcAl8MEQc=
github.com/grafana/grafana-plugin-sdk-go v0.131.0 h1:8M+Qfch4WNi3PPpRhWtmcLFTCq8zlIjnxrc8iRigAY0=
github.com/grafana/grafana-plugin-sdk-go v0.131.0/go.mod h1:jmrxelOJKrIK0yrsIzcotS8pbqPZozbmJgGy7k3hK1k=
github.com/grafana/loki v1.6.2-0.20211015002020-7832783b1caa h1:+pXjAxavVR2FKKNsuuCXGCWEj8XGc1Af6SPiyBpzU2A=
github.com/grafana/loki v1.6.2-0.20211015002020-7832783b1caa/go.mod h1:0O8o/juxNSKN/e+DzWDTRkl7Zm8CkZcz0NDqEdojlrk=
github.com/grafana/saml v0.0.0-20211007135653-aed1b2edd86b h1:YiSGp34F4V0G08HHx1cJBf2GVgwYAkXQjzuVs1t8jYk=

View File

@ -453,9 +453,10 @@ func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response {
dash.Meta.IsHome = true
dash.Meta.CanEdit = c.SignedInUser.HasRole(models.ROLE_EDITOR)
dash.Meta.FolderTitle = "General"
dash.Dashboard = simplejson.New()
jsonParser := json.NewDecoder(file)
if err := jsonParser.Decode(&dash.Dashboard); err != nil {
if err := jsonParser.Decode(dash.Dashboard); err != nil {
return response.Error(500, "Failed to load home dashboard", err)
}

View File

@ -1095,8 +1095,8 @@ func restoreDashboardVersionScenario(t *testing.T, desc string, url string, rout
}
func (sc *scenarioContext) ToJSON() *simplejson.Json {
var result *simplejson.Json
err := json.NewDecoder(sc.resp.Body).Decode(&result)
result := simplejson.New()
err := json.NewDecoder(sc.resp.Body).Decode(result)
require.NoError(sc.t, err)
return result
}

View File

@ -73,11 +73,11 @@ func getUsageStats(t *testing.T, server *web.Mux) (*models.SystemStats, *httptes
recorder := httptest.NewRecorder()
server.ServeHTTP(recorder, req)
var usageStats *models.SystemStats
var usageStats models.SystemStats
if recorder.Code == http.StatusOK {
require.NoError(t, json.NewDecoder(recorder.Body).Decode(&usageStats))
}
return usageStats, recorder
return &usageStats, recorder
}
func setupTestServer(t *testing.T, user *models.SignedInUser, service *UsageStats) *web.Mux {

View File

@ -82,7 +82,7 @@ func readPluginManifest(body []byte) (*pluginManifest, error) {
}
// Convert to a well typed object
manifest := &pluginManifest{}
var manifest pluginManifest
err := json.Unmarshal(block.Plaintext, &manifest)
if err != nil {
return nil, errutil.Wrap("Error parsing manifest JSON", err)
@ -99,7 +99,7 @@ func readPluginManifest(body []byte) (*pluginManifest, error) {
return nil, errutil.Wrap("failed to check signature", err)
}
return manifest, nil
return &manifest, nil
}
func Calculate(mlog log.Logger, plugin *plugins.Plugin) (plugins.Signature, error) {

View File

@ -56,9 +56,9 @@ func (s Settings) Value() (driver.Value, error) {
func (s *Settings) Scan(value interface{}) error {
switch v := value.(type) {
case string:
return json.Unmarshal([]byte(v), &s)
return json.Unmarshal([]byte(v), s)
case []uint8:
return json.Unmarshal(v, &s)
return json.Unmarshal(v, s)
default:
return fmt.Errorf("type assertion on scan failed: got %T", value)
}

View File

@ -179,7 +179,7 @@ func (api *ServiceAccountsAPI) updateServiceAccount(c *models.ReqContext) respon
return response.Error(http.StatusBadRequest, "Service Account ID is invalid", err)
}
cmd := &serviceaccounts.UpdateServiceAccountForm{}
var cmd serviceaccounts.UpdateServiceAccountForm
if err := web.Bind(c.Req, &cmd); err != nil {
return response.Error(http.StatusBadRequest, "Bad request data", err)
}
@ -188,7 +188,7 @@ func (api *ServiceAccountsAPI) updateServiceAccount(c *models.ReqContext) respon
return response.Error(http.StatusBadRequest, "Invalid role specified", nil)
}
resp, err := api.store.UpdateServiceAccount(c.Req.Context(), c.OrgId, scopeID, cmd)
resp, err := api.store.UpdateServiceAccount(c.Req.Context(), c.OrgId, scopeID, &cmd)
if err != nil {
switch {
case errors.Is(err, serviceaccounts.ErrServiceAccountNotFound):

View File

@ -99,7 +99,7 @@ func TestServerClient(t *testing.T) {
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
var user *models.SignedInUser
var user models.SignedInUser
err = json.Unmarshal(bytes, &user)
require.NoError(t, err)
require.NotNil(t, user)
@ -121,7 +121,7 @@ func TestServerClient(t *testing.T) {
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
var user *models.SignedInUser
var user models.SignedInUser
err = json.Unmarshal(bytes, &user)
require.NoError(t, err)
require.NotNil(t, user)