-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for filtering for datasource
- Loading branch information
1 parent
a8bf102
commit 6a9719d
Showing
12 changed files
with
113 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,8 @@ | |
"mode": "debug", | ||
"program": "${workspaceFolder}", | ||
"args": [ | ||
"dash", | ||
"export", | ||
// "-f", | ||
// "'General'", | ||
"-d", | ||
"monitored-query-diagnostics" | ||
// "--context", | ||
// "prod" | ||
"users", | ||
"list", | ||
//"promote", | ||
//"-u", | ||
//"[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package api | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/netsage-project/grafana-dashboard-manager/config" | ||
) | ||
|
||
type DashboardFilter struct { | ||
FolderFilter string // Name of Folder | ||
DashFilter string //name of dashboard | ||
} | ||
|
||
//GetFolders splits the comma delimited folder list and returns a slice | ||
func (s *DashboardFilter) GetFolders() []string { | ||
if s.FolderFilter == "" { | ||
return config.GetDefaultGrafanaConfig().GetMonitoredFolders() | ||
} | ||
s.FolderFilter = quoteRegex.ReplaceAllString(s.FolderFilter, "") | ||
|
||
return strings.Split(s.FolderFilter, ",") | ||
} | ||
|
||
func (s DashboardFilter) ValidateDashboard(dashUid string) bool { | ||
if s.DashFilter == "" { | ||
return true | ||
} | ||
return dashUid == s.DashFilter | ||
} | ||
|
||
func (s DashboardFilter) Validate(folder, dashUid string) bool { | ||
return s.ValidateDashboard(dashUid) && s.ValidateFolder(folder) | ||
} | ||
|
||
func (s DashboardFilter) ValidateFolder(folder string) bool { | ||
if s.FolderFilter == "" { | ||
return true | ||
} | ||
return folder == s.FolderFilter | ||
} | ||
|
||
type DatasourceFilter struct { | ||
Name string //name of datasource | ||
} | ||
|
||
func (s DatasourceFilter) ValidateDatasource(name string) bool { | ||
if s.Name == "" { | ||
return true | ||
} | ||
return name == s.Name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters