Skip to content

Commit

Permalink
generate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nieomylnieja committed Jul 2, 2024
1 parent 875c41a commit 7bed7bf
Show file tree
Hide file tree
Showing 51 changed files with 917 additions and 7 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ check/format:
$(call _print_check_step,Checking if files are formatted)
./scripts/check-formatting.sh

.PHONY: generate generate/code generate/diagrams
.PHONY: generate generate/code generate/examples generate/plantuml
## Auto generate files.
generate: generate/code generate/plantuml
generate: generate/code generate/examples generate/plantuml

## Generate Golang code.
generate/code:
Expand All @@ -119,6 +119,11 @@ generate/code:
go generate ./... ./docs/mock_example
${MAKE} format/go

## Generate examples from code.
generate/examples:
echo "Generating examples..."
go run internal/cmd/examplegen/main.go

PLANTUML_JAR_URL := https://sourceforge.net/projects/plantuml/files/plantuml.jar/download
PLANTUML_JAR := $(BIN_DIR)/plantuml.jar
DIAGRAMS_PATH ?= .
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/examplegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func getV1alphaExamplesConfigs() []examplesGeneratorConfig {
v1alphaExamples.Service(),
v1alphaExamples.AlertMethod(),
v1alphaExamples.SLO(),
v1alphaExamples.Agent(),
v1alphaExamples.Direct(),
}
for _, examples := range allExamples {
object := examples[0].GetObject().(manifest.Object)
Expand Down Expand Up @@ -104,11 +106,13 @@ func getV1alphaExamplesConfigs() []examplesGeneratorConfig {
configs = append(configs, config)
}
}
// config = append(config, getV1alphaSLOExamplesConfigs(path)...)
return configs
}

func writeExamples(v any, path string, comments yaml.CommentMap) error {
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
return err
}
file, err := os.Create(path)
if err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions internal/manifest/v1alpha/examples/alert_policy.go
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
package v1alphaExamples


2 changes: 1 addition & 1 deletion internal/manifest/v1alpha/examples/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const gcloudServiceAccountKey = `{
"type": "service_account",
"project_id": "prod-app",
"private_key_id": "669180ba44964eddba9e2f6623721381",
"private_key": "-----BEGIN PRIVATE KEY-----\nKEY_GOES_HERE\n-----END PRIVATE KEY-----\n",
"private_key": "-----BEGIN PRIVATE KEY-----\nSECRET_KEY_GOES_HERE\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "eddba9e2f66237213812",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
Expand Down
2 changes: 1 addition & 1 deletion internal/manifest/v1alpha/examples/direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestDirect_SupportsAllDirectTypes(t *testing.T) {
variants := Direct()
for _, typ := range v1alpha.DataSourceTypeValues() {
if !v1alphaDirect.IsValidDirectType(typ) {
continue
continue
}
if !slices.ContainsFunc(variants, func(e Example) bool {
return e.(directExample).typ == typ
Expand Down
23 changes: 23 additions & 0 deletions manifest/v1alpha/agent/examples/amazonprometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: amazonprometheus
displayName: AmazonPrometheus Agent
project: default
spec:
description: Example AmazonPrometheus Agent
releaseChannel: stable
amazonPrometheus:
url: https://aps-workspaces.us-east-1.amazonaws.com/workspaces/ws-f49ecf99-6dfa-4b00-9f94-a50b10a3010b
region: us-east-1
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 1
unit: Second
22 changes: 22 additions & 0 deletions manifest/v1alpha/agent/examples/appdynamics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: appdynamics
displayName: AppDynamics Agent
project: default
spec:
description: Example AppDynamics Agent
releaseChannel: stable
appDynamics:
url: https://my-org.saas.appdynamics.com
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 2
unit: Minute
22 changes: 22 additions & 0 deletions manifest/v1alpha/agent/examples/azuremonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: azuremonitor
displayName: AzureMonitor Agent
project: default
spec:
description: Example AzureMonitor Agent
releaseChannel: stable
azureMonitor:
tenantId: 5cdecca3-c2c5-4072-89dd-5555faf05202
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 6
unit: Minute
23 changes: 23 additions & 0 deletions manifest/v1alpha/agent/examples/azureprometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: azureprometheus
displayName: AzurePrometheus Agent
project: default
spec:
description: Example AzurePrometheus Agent
releaseChannel: stable
azurePrometheus:
url: https://defaultazuremonitorworkspace-westus2-szxw.westus2.prometheus.monitor.azure.com
tenantId: 41372654-f4b6-4bd1-a3fe-75629c024df1
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 1
unit: Second
14 changes: 14 additions & 0 deletions manifest/v1alpha/agent/examples/bigquery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: bigquery
displayName: BigQuery Agent
project: default
spec:
description: Example BigQuery Agent
releaseChannel: stable
bigQuery: {}
queryDelay:
duration:
value: 1
unit: Second
21 changes: 21 additions & 0 deletions manifest/v1alpha/agent/examples/cloudwatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: cloudwatch
displayName: CloudWatch Agent
project: default
spec:
description: Example CloudWatch Agent
releaseChannel: stable
cloudWatch: {}
historicalDataRetrieval:
maxDuration:
value: 15
unit: Day
defaultDuration:
value: 7
unit: Day
queryDelay:
duration:
value: 2
unit: Minute
22 changes: 22 additions & 0 deletions manifest/v1alpha/agent/examples/datadog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: datadog
displayName: Datadog Agent
project: default
spec:
description: Example Datadog Agent
releaseChannel: stable
datadog:
site: com
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 2
unit: Minute
22 changes: 22 additions & 0 deletions manifest/v1alpha/agent/examples/dynatrace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: dynatrace
displayName: Dynatrace Agent
project: default
spec:
description: Example Dynatrace Agent
releaseChannel: stable
dynatrace:
url: https://zvf10945.live.dynatrace.com/
historicalDataRetrieval:
maxDuration:
value: 28
unit: Day
defaultDuration:
value: 14
unit: Day
queryDelay:
duration:
value: 3
unit: Minute
15 changes: 15 additions & 0 deletions manifest/v1alpha/agent/examples/elasticsearch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: elasticsearch
displayName: Elasticsearch Agent
project: default
spec:
description: Example Elasticsearch Agent
releaseChannel: stable
elasticsearch:
url: http://elasticsearch-main.elasticsearch:9200
queryDelay:
duration:
value: 2
unit: Minute
14 changes: 14 additions & 0 deletions manifest/v1alpha/agent/examples/generic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: generic
displayName: Generic Agent
project: default
spec:
description: Example Generic Agent
releaseChannel: stable
generic: {}
queryDelay:
duration:
value: 1
unit: Second
21 changes: 21 additions & 0 deletions manifest/v1alpha/agent/examples/googlecloudmonitoring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: googlecloudmonitoring
displayName: GoogleCloudMonitoring Agent
project: default
spec:
description: Example GoogleCloudMonitoring Agent
releaseChannel: stable
gcm: {}
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 3
unit: Minute
15 changes: 15 additions & 0 deletions manifest/v1alpha/agent/examples/grafanaloki.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: grafanaloki
displayName: GrafanaLoki Agent
project: default
spec:
description: Example GrafanaLoki Agent
releaseChannel: stable
grafanaLoki:
url: http://grafana-loki.loki:3100
queryDelay:
duration:
value: 2
unit: Minute
22 changes: 22 additions & 0 deletions manifest/v1alpha/agent/examples/graphite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: graphite
displayName: Graphite Agent
project: default
spec:
description: Example Graphite Agent
releaseChannel: stable
graphite:
url: http://graphite.graphite:8080/render
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
duration:
value: 2
unit: Minute
21 changes: 21 additions & 0 deletions manifest/v1alpha/agent/examples/honeycomb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: honeycomb
displayName: Honeycomb Agent
project: default
spec:
description: Example Honeycomb Agent
releaseChannel: stable
honeycomb: {}
historicalDataRetrieval:
maxDuration:
value: 7
unit: Day
defaultDuration:
value: 3
unit: Day
queryDelay:
duration:
value: 6
unit: Minute
15 changes: 15 additions & 0 deletions manifest/v1alpha/agent/examples/influxdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: influxdb
displayName: InfluxDB Agent
project: default
spec:
description: Example InfluxDB Agent
releaseChannel: stable
influxdb:
url: https://us-west-2-2.aws.cloud2.influxdata.com
queryDelay:
duration:
value: 2
unit: Minute
15 changes: 15 additions & 0 deletions manifest/v1alpha/agent/examples/instana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- apiVersion: n9/v1alpha
kind: Agent
metadata:
name: instana
displayName: Instana Agent
project: default
spec:
description: Example Instana Agent
releaseChannel: stable
instana:
url: https://orange-my-org12.instana.io
queryDelay:
duration:
value: 2
unit: Minute
Loading

0 comments on commit 7bed7bf

Please sign in to comment.