-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of screenboards
This commit is huge since I found an issue with dependencies, and decided to migrate go-api to github based tracking, and introduce `dep`. This is also the first commit with tests! :) Related: #10
- Loading branch information
Showing
414 changed files
with
237,399 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
# Ignore all | ||
* | ||
|
||
# Unignore all with extensions and templates directory | ||
!*.* | ||
!tmpl/ | ||
bin/ |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,46 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/sirupsen/logrus" | ||
version = "1.2.0" | ||
|
||
[[constraint]] | ||
name = "github.com/spf13/pflag" | ||
version = "1.0.3" | ||
|
||
[[constraint]] | ||
name = "github.com/zorkian/go-datadog-api" | ||
version = "2.18.0" | ||
|
||
[[constraint]] | ||
name = "gopkg.in/zorkian/go-datadog-api.v2" | ||
version = "2.18.0" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
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,39 @@ | ||
//go:generate go-bindata -o tpl.go tmpl | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/zorkian/go-datadog-api" | ||
) | ||
|
||
type ScreenBoard struct { | ||
} | ||
|
||
func (s ScreenBoard) getElement(client datadog.Client, id int) (interface{}, error) { | ||
elem, err := client.GetScreenboard(*datadog.Int(id)) | ||
return elem, err | ||
} | ||
|
||
func (s ScreenBoard) getAsset() string { | ||
return "tmpl/screenboard.tmpl" | ||
} | ||
|
||
func (s ScreenBoard) getName() string { | ||
return "screenboards" | ||
} | ||
|
||
func (s ScreenBoard) String() string { | ||
return s.getName() | ||
} | ||
|
||
func (s ScreenBoard) getAllElements(client datadog.Client) ([]Item, error) { | ||
var ids []Item | ||
dashboards, err := client.GetScreenboards() | ||
if err != nil { | ||
return ids, err | ||
} | ||
for _, elem := range dashboards { | ||
ids = append(ids, Item{id: *elem.Id, d: ScreenBoard{}}) | ||
} | ||
return ids, nil | ||
} |
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,104 @@ | ||
//go:generate go-bindata -o tpl.go tmpl | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/zorkian/go-datadog-api" | ||
) | ||
|
||
var exampleScreenboard = datadog.Screenboard{ | ||
Id: datadog.Int(1), | ||
Title: datadog.String("Test"), | ||
Shared: datadog.Bool(false), | ||
Widgets: []datadog.Widget{ | ||
{ | ||
Type: datadog.String("query_value"), | ||
X: datadog.Int(1), | ||
Y: datadog.Int(1), | ||
Width: datadog.Int(5), | ||
Height: datadog.Int(5), | ||
Title: datadog.Bool(true), | ||
TitleText: datadog.String("Test title"), | ||
TitleSize: datadog.Int(16), | ||
TitleAlign: datadog.String("right"), | ||
Legend: datadog.Bool(true), | ||
LegendSize: datadog.String("16"), | ||
Time: &datadog.Time{ | ||
LiveSpan: datadog.String("1d"), | ||
}, | ||
TileDef: &datadog.TileDef{ | ||
Viz: datadog.String("query_value"), | ||
Requests: []datadog.TileDefRequest{{ | ||
Query: datadog.String("avg:system.cpu.user{*}"), | ||
Type: datadog.String("line"), | ||
Style: &datadog.TileDefRequestStyle{ | ||
Palette: datadog.String("purple"), | ||
Type: datadog.String("dashed"), | ||
Width: datadog.String("thin"), | ||
}, | ||
ConditionalFormats: []datadog.ConditionalFormat{ | ||
{ | ||
Comparator: datadog.String(">="), | ||
Value: datadog.String("1"), | ||
Palette: datadog.String("white_on_red"), | ||
}}, | ||
Aggregator: datadog.String("max"), | ||
}}, | ||
CustomUnit: datadog.String("%"), | ||
Autoscale: datadog.Bool(false), | ||
TextAlign: datadog.String("right"), | ||
}, | ||
Logset: datadog.String("test"), | ||
}, | ||
}, | ||
} | ||
|
||
func Example() { | ||
config := LocalConfig{files: false} | ||
item := Item{id: 1, d: ScreenBoard{}} | ||
item.renderElement(exampleScreenboard, config) | ||
|
||
// Unordered output: | ||
// resource "datadog_screenboard" "1" { | ||
// title = "Test" | ||
// shared = false | ||
// widget { | ||
// type = "query_value" | ||
// x = "1" | ||
// y = "1" | ||
// title = "true" | ||
// title_text = "Test title" | ||
// title_size = "16" | ||
// height = "5" | ||
// width = "5" | ||
// title_align = "right" | ||
// time { | ||
// live_span = "1d" | ||
// } | ||
// tile_def { | ||
// viz = "query_value" | ||
// custom_unit = "%" | ||
// autoscale = "false" | ||
// text_align = "right" | ||
// request { | ||
// q = "avg:system.cpu.user{*}" | ||
// type = "line" | ||
// aggregator = "max" | ||
// conditional_format { | ||
// palette = "white_on_red" | ||
// comparator = ">=" | ||
// value = "1" | ||
// } | ||
// style { | ||
// palette = "purple" | ||
// type = "dashed" | ||
// width = "thin" | ||
// } //style | ||
// } //request | ||
// } //tile_def | ||
// legend = "true" | ||
// legend_size = "16" | ||
// logset = "test" | ||
// } //widget | ||
// } | ||
} |
Oops, something went wrong.