Skip to content

Commit

Permalink
Merge pull request #32 from rikonen/prometheus-support
Browse files Browse the repository at this point in the history
Support for Prometheus integration

#32 (review)
  • Loading branch information
Mika Eloranta authored Nov 15, 2018
2 parents dc7fc56 + d54f54d commit 5f4c2bf
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

[[constraint]]
name = "github.com/aiven/aiven-go-client"
revision = "ec0871c583db5c4c154c68d814099fedacfc8ba5"
revision = "1229534dc578f64766c377491fd727d08fd95ac5"
source = "github.com/aiven/aiven-go-client"

[prune]
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ update-vendor:
#################################################

bins: vendor
packr build -o terraform-provider-aiven .
GOOS=linux GOARCH=amd64 packr build -o terraform-provider-aiven-linux_amd64 .
GOOS=darwin GOARCH=amd64 packr build -o terraform-provider-aiven-darwin_amd64 .

#################################################
# Testing and linting
Expand Down
24 changes: 24 additions & 0 deletions resource_service_integration_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func resourceServiceIntegrationEndpoint() *schema.Resource {
Required: true,
Type: schema.TypeString,
},
"endpoint_config": {
Description: "Integration endpoint specific backend configuration",
Computed: true,
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
},
"datadog_user_config": {
Description: "Datadog specific user configurable settings",
Elem: &schema.Resource{
Expand All @@ -49,6 +55,16 @@ func resourceServiceIntegrationEndpoint() *schema.Resource {
Optional: true,
Type: schema.TypeList,
},
"prometheus_user_config": {
Description: "Prometheus specific user configurable settings",
Elem: &schema.Resource{
Schema: GenerateTerraformUserConfigSchema(
GetUserConfigSchema("endpoint")["prometheus"].(map[string]interface{})),
},
MaxItems: 1,
Optional: true,
Type: schema.TypeList,
},
},
}
}
Expand Down Expand Up @@ -156,6 +172,14 @@ func copyServiceIntegrationEndpointPropertiesFromAPIResponseToTerraform(
if len(userConfig) > 0 {
d.Set(endpointType+"_user_config", userConfig)
}
// Must coerse all values into strings
endpointConfig := map[string]string{}
if len(endpoint.EndpointConfig) > 0 {
for key, value := range endpoint.EndpointConfig {
endpointConfig[key] = fmt.Sprintf("%v", value)
}
}
d.Set("endpoint_config", endpointConfig)

return nil
}
20 changes: 20 additions & 0 deletions templates/integration_endpoints_user_config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,25 @@
"datadog_api_key"
],
"type": "object"
},
"prometheus": {
"additionalProperties": false,
"properties": {
"basic_auth_password": {
"example": "fhyFNBjj3R",
"maxLength": 64,
"minLength": 8,
"title": "Prometheus basic authentication password",
"type": "string"
},
"basic_auth_username": {
"example": "prom4851",
"maxLength": 32,
"minLength": 5,
"title": "Prometheus basic authentication username",
"type": "string"
}
},
"type": "object"
}
}
5 changes: 5 additions & 0 deletions templates/integrations_user_config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@
}
},
"type": "object"
},
"prometheus": {
"additionalProperties": true,
"title": "Integration user config",
"type": "object"
}
}
35 changes: 34 additions & 1 deletion templates/service_user_config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,38 @@
"title": "Enable Kafka-REST service",
"type": "boolean"
},
"kafka_rest_config": {
"additionalProperties": false,
"properties": {
"consumer_request_max_bytes": {
"default": 67108864,
"maximum": 671088640,
"minimum": 0,
"title": "Maximum number of bytes in unencoded message keys and values by a single request",
"type": "integer"
},
"producer_acks": {
"default": "1",
"enum": [
"all",
"-1",
"0",
"1"
],
"title": "The number of acknowledgments the producer requires the leader to have received before considering a request complete. If set to 'all' or '-1', the leader will wait for the full set of in-sync replicas to acknowledge the record.",
"type": "string"
},
"producer_linger_ms": {
"default": 0,
"maximum": 5000,
"minimum": 0,
"title": "Wait for up to the given delay to allow batching records together",
"type": "integer"
}
},
"title": "Kafka REST configuration",
"type": "object"
},
"kafka_version": {
"enum": [
"1.0",
Expand Down Expand Up @@ -756,7 +788,8 @@
"9.3",
"9.5",
"9.6",
"10"
"10",
"11"
],
"title": "PostgreSQL major version",
"type": [
Expand Down

0 comments on commit 5f4c2bf

Please sign in to comment.