Compare commits

...

3 commits

Author SHA1 Message Date
4b1986c645
chore(deps): update golangci/golangci-lint docker tag to v2
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/test unknown status
ci/woodpecker/push/build unknown status
2025-04-09 01:04:23 +00:00
3648b17149 Merge pull request 'feat(grafana): add new api response for dashboard versions' (#65) from tn-fix-breaking-api-change into main
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
Reviewed-on: #65
2025-04-09 02:07:12 +02:00
5106b946f3
feat(grafana): add new api response for dashboard versions
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
2025-04-09 01:57:33 +02:00
3 changed files with 26 additions and 8 deletions

View file

@ -13,7 +13,7 @@ steps:
when: when:
- event: push - event: push
- name: golangci-linter - name: golangci-linter
image: golangci/golangci-lint:v1.64.8 image: golangci/golangci-lint:v2.0.2
commands: commands:
- golangci-lint run ./... - golangci-lint run ./...
when: when:

View file

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"strconv" "strconv"
"strings"
"time" "time"
"git.ar21.de/yolokube/grafana-backuper/pkg/grafana/schema" "git.ar21.de/yolokube/grafana-backuper/pkg/grafana/schema"
@ -167,15 +168,25 @@ func (c *DashboardVersionClient) list(
return nil, nil, err return nil, nil, err
} }
var body schema.DashboardVersionListResponse var versions schema.DashboardVersionListResponseV10
body := schema.DashboardVersionListResponse{}
resp, err := c.client.do(req, &body) resp, err := c.client.do(req, &body)
if err != nil {
if !strings.Contains(err.Error(), "cannot unmarshal object") {
return nil, resp, err
}
bodyV10 := schema.DashboardVersionListResponseV10{}
resp, err = c.client.do(req, &bodyV10)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
versions = bodyV10
} else {
versions = body.Versions
}
dashboardVersions := make([]*DashboardVersion, 0, len(body)) dashboardVersions := make([]*DashboardVersion, 0, len(versions))
for _, dashboardVersion := range body { for _, dashboardVersion := range versions {
dashboardVersions = append(dashboardVersions, DashboardVersionFromSchema(dashboardVersion)) dashboardVersions = append(dashboardVersions, DashboardVersionFromSchema(dashboardVersion))
} }

View file

@ -1,6 +1,8 @@
package schema package schema
import "time" import (
"time"
)
type DashboardVersion struct { type DashboardVersion struct {
ID uint `json:"id"` ID uint `json:"id"`
@ -15,4 +17,9 @@ type DashboardVersion struct {
Data any `json:"data"` Data any `json:"data"`
} }
type DashboardVersionListResponse []DashboardVersion type DashboardVersionListResponseV10 []DashboardVersion
type DashboardVersionListResponse struct {
ContinueToken string `json:"continueToken"`
Versions DashboardVersionListResponseV10 `json:"versions"`
}