Skip to content

Commit

Permalink
Merge pull request #13 from kubermatic/2022-03-30-upstream-update
Browse files Browse the repository at this point in the history
Update to upstream, fix statPanel marshalling
  • Loading branch information
Rastislav Szabo authored Mar 31, 2022
2 parents 3988a0a + 56a4d4e commit c2e84f5
Show file tree
Hide file tree
Showing 30 changed files with 1,222 additions and 47,873 deletions.
25 changes: 25 additions & 0 deletions board_visual_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sdk_test
import (
"context"
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -62,6 +63,11 @@ func TestSinglestatPanel(t *testing.T) {
panel.SinglestatPanel.ValueName = "avg"

r.Add(panel)

textPanel := sdk.NewText("text")
textPanel.TextPanel.Content = "content"
textPanel.TextPanel.Mode = "markdown"
r.Add(textPanel)
cl := getClient(t)

db, err := cl.SetDashboard(context.TODO(), *b, sdk.SetDashboardParams{
Expand All @@ -71,6 +77,12 @@ func TestSinglestatPanel(t *testing.T) {
if err != nil {
t.Fatalf("failed setting dashboard: %v", err)
}
t.Cleanup(func() {
_, err := cl.DeleteDashboardByUID(context.TODO(), *db.UID)
if err != nil {
t.Fatal("failed cleaning up due to", err.Error())
}
})

durl := getDebugURL(t)

Expand Down Expand Up @@ -105,4 +117,17 @@ func TestSinglestatPanel(t *testing.T) {
if res == "" {
t.Fatalf("expected single-stat panel to have some value")
}

err = chromedp.Run(ctx,
chromedp.Navigate(fullAddr),
chromedp.WaitReady(`grafana-app`),
chromedp.TextContent(`p.markdown-html`, &res, chromedp.NodeVisible, chromedp.ByQuery),
)
if err != nil {
t.Fatalf("running chromedp has failed: %v", err)
}

if strings.TrimSpace(res) != `content` {
t.Fatalf("expected text panel to have the correct value, got: %s", res)
}
}
9 changes: 9 additions & 0 deletions dashboard-unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ func TestUnmarshal_DashboardWithGraphWithTargets26(t *testing.T) {
if len(panel.GraphPanel.Targets) != 2 {
t.Errorf("panel has 2 targets but got %d", len(panel.GraphPanel.Targets))
}
if len(panel.GraphPanel.Targets[1].Tags) != 1 {
t.Fatalf("should be 1 but got %d", len(panel.GraphPanel.Targets[0].Tags))
}
var tag = panel.GraphPanel.Targets[1].Tags[0]

if tag.Key != "key" && tag.Operator != "=" && tag.Value != "testvalue" {
t.Fatalf("Unexpected Target Tags: got %s", tag)
}

}

func TestUnmarshal_DashboardWithEmptyPanels30(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ type Datasource struct {
OrgID uint `json:"orgId"`
Name string `json:"name"`
Type string `json:"type"`
TypeLogoURL string `json:"typeLogoUrl"`
Access string `json:"access"` // direct or proxy
URL string `json:"url"`
Password *string `json:"password,omitempty"`
User *string `json:"user,omitempty"`
Database *string `json:"database,omitempty"`
BasicAuth *bool `json:"basicAuth,omitempty"`
ReadOnly *bool `json:"readOnly,omitempty"`
BasicAuthUser *string `json:"basicAuthUser,omitempty"`
BasicAuthPassword *string `json:"basicAuthPassword,omitempty"`
IsDefault bool `json:"isDefault"`
Expand Down
46 changes: 46 additions & 0 deletions folder-permissions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package sdk

/*
Copyright 2016 Alexander I.Grafov <[email protected]>
Copyright 2016-2022 The Grafana SDK authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
ॐ तारे तुत्तारे तुरे स्व
*/

type PermissionType uint

const PermissionView = PermissionType(1)
const PermissionEdit = PermissionType(2)
const PermissionAdmin = PermissionType(4)

type FolderPermission struct {
Id uint `json:"id"`
FolderId uint `json:"folderId"`
Created string `json:"created"`
Updated string `json:"updated"`
UserId uint `json:"userId,omitempty"`
UserLogin string `json:"userLogin,omitempty"`
UserEmail string `json:"userEmail,omitempty"`
TeamId uint `json:"teamId,omitempty"`
Team string `json:"team,omitempty"`
Role string `json:"role,omitempty"`
Permission PermissionType `json:"permission"`
PermissionName string `json:"permissionName"`
Uid string `json:"uid,omitempty"`
Title string `json:"title,omitempty"`
Slug string `json:"slug,omitempty"`
IsFolder bool `json:"isFolder"`
Url string `json:"url,omitempty"`
}
Loading

0 comments on commit c2e84f5

Please sign in to comment.