Skip to content

Commit 71cd88b

Browse files
authored
Chore: Fix DeepCopyInto for DataQuery (#1081)
1 parent 84021fd commit 71cd88b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

experimental/apis/data/v0alpha1/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (g *DataQuery) DeepCopyInto(out *DataQuery) {
246246
out.additional = map[string]any{}
247247
if len(g.additional) > 0 {
248248
jj, err := json.Marshal(g.additional)
249-
if err != nil {
249+
if err == nil {
250250
_ = json.Unmarshal(jj, &out.additional)
251251
}
252252
}

experimental/apis/data/v0alpha1/query_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func TestParseQueriesIntoQueryDataRequest(t *testing.T) {
2020
"spreadsheet": "spreadsheetID",
2121
"datasourceId": 4,
2222
"intervalMs": 30000,
23-
"maxDataPoints": 794
23+
"maxDataPoints": 794,
24+
"expr": "{filename=\"/var/log/docker/2e21a640173f1f3359e2a178905dad6b1b56e2da6e3d53dbdba0a1123cdcb4fe/json.log\"} | logfmt"
2425
},
2526
{
2627
"refId": "Z",
@@ -75,6 +76,11 @@ func TestParseQueriesIntoQueryDataRequest(t *testing.T) {
7576
}`, string(out))
7677
})
7778

79+
t.Run("verify deep copy", func(t *testing.T) {
80+
cpy := req.DeepCopy()
81+
require.Equal(t, req, cpy)
82+
})
83+
7884
t.Run("same results from either parser", func(t *testing.T) {
7985
typed := &QueryDataRequest{}
8086
err = json.Unmarshal(request, typed)

0 commit comments

Comments
 (0)