Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sc-88216] Generate provider documentation #43

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ install-tools:
GOBIN=$(TOOLS_BIN) go install $(GOFLAGS) github.com/chronosphereio/terraform-provider-chronosphere/$(path); )

.PHONY: generate
generate: install-tools
generate: install-tools generate-docs
$(GO_GENERATE) ./...

# subset of generate that skips swagger since swagger is slow to generate.
.PHONY: generate-no-swagger
generate-no-swagger: install-tools
generate-no-swagger: install-tools generate-docs
$(GO_GENERATE) ./chronosphere ./chronosphere/intschema ./chronosphere/pagination

.PHONY: generate-docs
generate-docs: install-tools
@echo "--- generating terraform provider docs"
GOFLAGS=$(GOFLAGS) $(TOOLS_BIN)/tfplugindocs generate --examples-dir examples --provider-name chronosphere

.PHONY: test-generate
test-generate: generate
@echo "--- :golang: go mod tidy"
Expand Down
4 changes: 4 additions & 0 deletions doc_examples/data-sources/chronosphere_service/email.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "chronosphere_email_alert_notifier" "email" {
name = "Email Blackhole"
to = "[email protected]"
}
57 changes: 57 additions & 0 deletions doc_examples/data-sources/chronosphere_service/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This assumes the service is created out-of-band (see create-service.sh)
data "chronosphere_service" "gateway" {
slug = "gateway"
}

resource "chronosphere_monitor" "m" {
name = "Monitor in Gateway Service"
collection_id = data.chronosphere_service.gateway.id
notification_policy_id = chronosphere_notification_policy.np.id

query {
prometheus_expr = "up{foo=\"bar\"}"
}

series_conditions {
condition {
severity = "warn"
value = 2.0
op = "GT"
}
}
}


resource "chronosphere_dashboard" "dash_in_svc" {
name = "Native Dashboard in Gateway Service"
collection_id = data.chronosphere_service.gateway.id
dashboard_json = jsonencode({
kind : "Dashboard",
spec : {
}
})
}


resource "chronosphere_classic_dashboard" "dash_in_svc" {
collection_id = data.chronosphere_service.gateway.id
dashboard_json = jsonencode({
title : "Dashboard In Gateway Service",
panels : [{
"gridPos" : {
"h" : 12,
"w" : 24,
"x" : 0,
"y" : 0
},
id : 2,
targets : [
{
expr : "1",
}
],
title : "Panel Title",
type : "graph",
}],
})
}
17 changes: 17 additions & 0 deletions doc_examples/data-sources/chronosphere_service/policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "chronosphere_notification_policy" "np" {
team_id = chronosphere_team.t.id
name = "team NP"

route {
severity = "warn"
notifiers = [chronosphere_email_alert_notifier.email.id]
}
}

resource "chronosphere_collection" "infra" {
name = "Infrastructure Collection"
team_id = chronosphere_team.t.id
description = "Collection of resources related to infrastructure services."

notification_policy_id = chronosphere_notification_policy.np.id
}
4 changes: 4 additions & 0 deletions doc_examples/data-sources/chronosphere_service/team.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "chronosphere_team" "t" {
name = "Team"
description = "Optional Team Description"
}
9 changes: 9 additions & 0 deletions doc_examples/data-sources/data-bucket/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data "chronosphere_bucket" "default1" {
name = "Default"
}


data "chronosphere_bucket" "default2" {
slug = "default"
}

3 changes: 3 additions & 0 deletions doc_examples/data-sources/data-collection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "chronosphere_collection" "default" {
slug = "default"
}
5 changes: 5 additions & 0 deletions doc_examples/resources/chronosphere_bucket/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "chronosphere_bucket" "b" {
name = "Bucket"
description = "bucket created by terraform examples"
labels = { "foo" : "bar" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "chronosphere_bucket" "b" {
name = "bucket"
notification_policy_data = chronosphere_notification_policy.np.notification_policy_data
}

resource "chronosphere_email_alert_notifier" "email" {
name = "Email Blackhole"
to = "[email protected]"
}

resource "chronosphere_notification_policy" "np" {
route {
severity = "warn"
notifiers = [chronosphere_email_alert_notifier.email.id]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "chronosphere_team" "t" {
name = "team"
}

resource "chronosphere_collection" "c" {
name = "Bucket"
team_id = chronosphere_team.t.id
description = "collection created by terraform examples"
}

resource "chronosphere_classic_dashboard" "my_dashboard" {
collection_id = chronosphere_collection.c.id
dashboard_json = jsonencode({
title : "Dashboard",
panels : [{
"gridPos" : {
"h" : 12,
"w" : 24,
"x" : 0,
"y" : 0
},
id : 2,
targets : [
{
expr : "1",
}
],
title : "Panel Title",
type : "graph",
}],
})
}
10 changes: 10 additions & 0 deletions doc_examples/resources/chronosphere_collection/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "chronosphere_team" "t" {
name = "Team"
description = "Optional Team Description"
}

resource "chronosphere_collection" "infra" {
name = "Infrastructure Collection"
description = "Collection of resources related to infrastructure services."
team_id = chronosphere_team.t.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "chronosphere_collection" "infra" {
name = "Infrastructure Collection"
description = "Collection of resources related to infrastructure services."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource "chronosphere_team" "t" {
name = "Team"
description = "Optional Team Description"
}

resource "chronosphere_email_alert_notifier" "email" {
name = "Email Blackhole"
to = "[email protected]"
}

resource "chronosphere_notification_policy" "np" {
team_id = chronosphere_team.t.id
name = "team NP"

route {
severity = "warn"
notifiers = [chronosphere_email_alert_notifier.email.id]
}
}


resource "chronosphere_collection" "infra" {
name = "Infrastructure Collection"
team_id = chronosphere_team.t.id
description = "Collection of resources related to infrastructure services."

notification_policy_id = chronosphere_notification_policy.np.id
}
21 changes: 21 additions & 0 deletions doc_examples/resources/chronosphere_dashboard/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "chronosphere_team" "t" {
name = "Team"
description = "Optional Team Description"
}

resource "chronosphere_collection" "c" {
name = "Collection"
description = "collection created by terraform examples."
team_id = chronosphere_team.t.id
}

resource "chronosphere_dashboard" "my_dashboard" {
name = "Chrono Dashboard"
slug = "slug"
collection_id = chronosphere_collection.c.id
dashboard_json = jsonencode({
kind : "Dashboard",
spec : {
}
})
}
87 changes: 87 additions & 0 deletions doc_examples/resources/chronosphere_dataset/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
resource "chronosphere_dataset" "example_prod_payfe" {
name = "Production paymentfe Traces"
description = "Traces passing through the paymentfe service in production"
configuration {
type = "TRACES"

trace_dataset {
match_criteria {
span {
duration {
max_secs = 99
min_secs = 1
}

error {
value = true
}

match_type = "INCLUDE"

operation {
value = "importantop"
match = "EXACT"
}

parent_operation {
value = "payments/.*"
match = "REGEX"
}

parent_service {
value = "frontdoor-[east|west]"
match = "REGEX"
}

service {
value = "importantsvc"
match = "EXACT"
}

span_count {
max = 2
min = 1
}

tag {
key = "cool_tag"

value {
value = "coolvalue"
match = "EXACT"
}
}

tag {
key = "env_tag"

value {
value = "prod.*"
match = "REGEX"
}
}

tag {
key = "http.status_code"

numeric_value {
comparison = "GREATER_THAN"
value = 299
}
}
}

trace {
duration {
max_secs = 10
min_secs = 5
}

error {
value = true
}
}
}
}
}
}
Loading
Loading