diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ab9867ce..2895856c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ nav_order: 1
- Use new user config generator to generate service integration configs
- Fix `aiven_kafka_schema` version update
+- Add `external_aws_cloudwatch_logs`, `external_elasticsearch_logs_user_config`, `external_opensearch_logs_user_config`,
+ `prometheus_user_config` service integration configs
## [4.14.0] - 2024-02-20
diff --git a/docs/data-sources/service_integration.md b/docs/data-sources/service_integration.md
index 07991487e..41e2c61a4 100644
--- a/docs/data-sources/service_integration.md
+++ b/docs/data-sources/service_integration.md
@@ -27,7 +27,7 @@ data "aiven_service_integration" "myintegration" {
### Required
- `destination_service_name` (String) Destination service for the integration (if any)
-- `integration_type` (String) Type of the service integration. Possible values: `alertmanager`, `cassandra_cross_service_cluster`, `clickhouse_kafka`, `clickhouse_postgresql`, `dashboard`, `datadog`, `datasource`, `external_aws_cloudwatch_logs`, `external_aws_cloudwatch_metrics`, `external_elasticsearch_logs`, `external_google_cloud_logging`, `external_opensearch_logs`, `flink`, `internal_connectivity`, `jolokia`, `kafka_connect`, `kafka_logs`, `kafka_mirrormaker`, `logs`, `m3aggregator`, `m3coordinator`, `metrics`, `opensearch_cross_cluster_replication`, `opensearch_cross_cluster_search`, `prometheus`, `read_replica`, `rsyslog`, `schema_registry_proxy`
+- `integration_type` (String) Type of the service integration. Possible values: `alertmanager`, `autoscaler`, `caching`, `cassandra_cross_service_cluster`, `clickhouse_credentials`, `clickhouse_kafka`, `clickhouse_postgresql`, `dashboard`, `datadog`, `datasource`, `external_aws_cloudwatch_logs`, `external_aws_cloudwatch_metrics`, `external_elasticsearch_logs`, `external_google_cloud_logging`, `external_opensearch_logs`, `flink`, `flink_external_bigquery`, `flink_external_kafka`, `internal_connectivity`, `jolokia`, `kafka_connect`, `kafka_logs`, `kafka_mirrormaker`, `logs`, `m3aggregator`, `m3coordinator`, `metrics`, `opensearch_cross_cluster_replication`, `opensearch_cross_cluster_search`, `prometheus`, `read_replica`, `rsyslog`, `schema_registry_proxy`, `stresstester`, `thanoscompactor`, `thanosquery`, `thanosstore`, `vector`, `vmalert`
- `project` (String) Project the integration belongs to
- `source_service_name` (String) Source service for the integration (if any)
@@ -37,7 +37,10 @@ data "aiven_service_integration" "myintegration" {
- `clickhouse_postgresql_user_config` (List of Object) ClickhousePostgresql user configurable settings (see [below for nested schema](#nestedatt--clickhouse_postgresql_user_config))
- `datadog_user_config` (List of Object) Datadog user configurable settings (see [below for nested schema](#nestedatt--datadog_user_config))
- `destination_endpoint_id` (String) Destination endpoint for the integration (if any)
+- `external_aws_cloudwatch_logs_user_config` (List of Object) ExternalAwsCloudwatchLogs user configurable settings (see [below for nested schema](#nestedatt--external_aws_cloudwatch_logs_user_config))
- `external_aws_cloudwatch_metrics_user_config` (List of Object) ExternalAwsCloudwatchMetrics user configurable settings (see [below for nested schema](#nestedatt--external_aws_cloudwatch_metrics_user_config))
+- `external_elasticsearch_logs_user_config` (List of Object) ExternalElasticsearchLogs user configurable settings (see [below for nested schema](#nestedatt--external_elasticsearch_logs_user_config))
+- `external_opensearch_logs_user_config` (List of Object) ExternalOpensearchLogs user configurable settings (see [below for nested schema](#nestedatt--external_opensearch_logs_user_config))
- `id` (String) The ID of this resource.
- `integration_id` (String) Service Integration Id at aiven
- `kafka_connect_user_config` (List of Object) KafkaConnect user configurable settings (see [below for nested schema](#nestedatt--kafka_connect_user_config))
@@ -45,6 +48,7 @@ data "aiven_service_integration" "myintegration" {
- `kafka_mirrormaker_user_config` (List of Object) KafkaMirrormaker user configurable settings (see [below for nested schema](#nestedatt--kafka_mirrormaker_user_config))
- `logs_user_config` (List of Object) Logs user configurable settings (see [below for nested schema](#nestedatt--logs_user_config))
- `metrics_user_config` (List of Object) Metrics user configurable settings (see [below for nested schema](#nestedatt--metrics_user_config))
+- `prometheus_user_config` (List of Object) Prometheus user configurable settings (see [below for nested schema](#nestedatt--prometheus_user_config))
- `source_endpoint_id` (String) Source endpoint for the integration (if any)
@@ -153,6 +157,14 @@ Read-Only:
+
+### Nested Schema for `external_aws_cloudwatch_logs_user_config`
+
+Read-Only:
+
+- `selected_log_fields` (List of String)
+
+
### Nested Schema for `external_aws_cloudwatch_metrics_user_config`
@@ -180,6 +192,22 @@ Read-Only:
+
+### Nested Schema for `external_elasticsearch_logs_user_config`
+
+Read-Only:
+
+- `selected_log_fields` (List of String)
+
+
+
+### Nested Schema for `external_opensearch_logs_user_config`
+
+Read-Only:
+
+- `selected_log_fields` (List of String)
+
+
### Nested Schema for `kafka_connect_user_config`
@@ -278,3 +306,40 @@ Read-Only:
- `perf_events_statements_limit` (Number)
- `perf_events_statements_time_limit` (Number)
+
+
+
+
+### Nested Schema for `prometheus_user_config`
+
+Read-Only:
+
+- `source_mysql` (List of Object) (see [below for nested schema](#nestedobjatt--prometheus_user_config--source_mysql))
+
+
+### Nested Schema for `prometheus_user_config.source_mysql`
+
+Read-Only:
+
+- `telegraf` (List of Object) (see [below for nested schema](#nestedobjatt--prometheus_user_config--source_mysql--telegraf))
+
+
+### Nested Schema for `prometheus_user_config.source_mysql.telegraf`
+
+Read-Only:
+
+- `gather_event_waits` (Boolean)
+- `gather_file_events_stats` (Boolean)
+- `gather_index_io_waits` (Boolean)
+- `gather_info_schema_auto_inc` (Boolean)
+- `gather_innodb_metrics` (Boolean)
+- `gather_perf_events_statements` (Boolean)
+- `gather_process_list` (Boolean)
+- `gather_slave_status` (Boolean)
+- `gather_table_io_waits` (Boolean)
+- `gather_table_lock_waits` (Boolean)
+- `gather_table_schema` (Boolean)
+- `perf_events_statements_digest_text_limit` (Number)
+- `perf_events_statements_limit` (Number)
+- `perf_events_statements_time_limit` (Number)
+
diff --git a/docs/resources/service_integration.md b/docs/resources/service_integration.md
index ca6150a6f..8c0a6e836 100644
--- a/docs/resources/service_integration.md
+++ b/docs/resources/service_integration.md
@@ -28,7 +28,7 @@ resource "aiven_service_integration" "my_integration_metrics" {
### Required
-- `integration_type` (String) Type of the service integration. Possible values: `alertmanager`, `cassandra_cross_service_cluster`, `clickhouse_kafka`, `clickhouse_postgresql`, `dashboard`, `datadog`, `datasource`, `external_aws_cloudwatch_logs`, `external_aws_cloudwatch_metrics`, `external_elasticsearch_logs`, `external_google_cloud_logging`, `external_opensearch_logs`, `flink`, `internal_connectivity`, `jolokia`, `kafka_connect`, `kafka_logs`, `kafka_mirrormaker`, `logs`, `m3aggregator`, `m3coordinator`, `metrics`, `opensearch_cross_cluster_replication`, `opensearch_cross_cluster_search`, `prometheus`, `read_replica`, `rsyslog`, `schema_registry_proxy`
+- `integration_type` (String) Type of the service integration. Possible values: `alertmanager`, `autoscaler`, `caching`, `cassandra_cross_service_cluster`, `clickhouse_credentials`, `clickhouse_kafka`, `clickhouse_postgresql`, `dashboard`, `datadog`, `datasource`, `external_aws_cloudwatch_logs`, `external_aws_cloudwatch_metrics`, `external_elasticsearch_logs`, `external_google_cloud_logging`, `external_opensearch_logs`, `flink`, `flink_external_bigquery`, `flink_external_kafka`, `internal_connectivity`, `jolokia`, `kafka_connect`, `kafka_logs`, `kafka_mirrormaker`, `logs`, `m3aggregator`, `m3coordinator`, `metrics`, `opensearch_cross_cluster_replication`, `opensearch_cross_cluster_search`, `prometheus`, `read_replica`, `rsyslog`, `schema_registry_proxy`, `stresstester`, `thanoscompactor`, `thanosquery`, `thanosstore`, `vector`, `vmalert`
- `project` (String) Project the integration belongs to
### Optional
@@ -38,12 +38,16 @@ resource "aiven_service_integration" "my_integration_metrics" {
- `datadog_user_config` (Block List, Max: 1) Datadog user configurable settings (see [below for nested schema](#nestedblock--datadog_user_config))
- `destination_endpoint_id` (String) Destination endpoint for the integration (if any)
- `destination_service_name` (String) Destination service for the integration (if any)
+- `external_aws_cloudwatch_logs_user_config` (Block List, Max: 1) ExternalAwsCloudwatchLogs user configurable settings (see [below for nested schema](#nestedblock--external_aws_cloudwatch_logs_user_config))
- `external_aws_cloudwatch_metrics_user_config` (Block List, Max: 1) ExternalAwsCloudwatchMetrics user configurable settings (see [below for nested schema](#nestedblock--external_aws_cloudwatch_metrics_user_config))
+- `external_elasticsearch_logs_user_config` (Block List, Max: 1) ExternalElasticsearchLogs user configurable settings (see [below for nested schema](#nestedblock--external_elasticsearch_logs_user_config))
+- `external_opensearch_logs_user_config` (Block List, Max: 1) ExternalOpensearchLogs user configurable settings (see [below for nested schema](#nestedblock--external_opensearch_logs_user_config))
- `kafka_connect_user_config` (Block List, Max: 1) KafkaConnect user configurable settings (see [below for nested schema](#nestedblock--kafka_connect_user_config))
- `kafka_logs_user_config` (Block List, Max: 1) KafkaLogs user configurable settings (see [below for nested schema](#nestedblock--kafka_logs_user_config))
- `kafka_mirrormaker_user_config` (Block List, Max: 1) KafkaMirrormaker user configurable settings (see [below for nested schema](#nestedblock--kafka_mirrormaker_user_config))
- `logs_user_config` (Block List, Max: 1) Logs user configurable settings (see [below for nested schema](#nestedblock--logs_user_config))
- `metrics_user_config` (Block List, Max: 1) Metrics user configurable settings (see [below for nested schema](#nestedblock--metrics_user_config))
+- `prometheus_user_config` (Block List, Max: 1) Prometheus user configurable settings (see [below for nested schema](#nestedblock--prometheus_user_config))
- `source_endpoint_id` (String) Source endpoint for the integration (if any)
- `source_service_name` (String) Source service for the integration (if any)
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
@@ -165,6 +169,14 @@ Optional:
+
+### Nested Schema for `external_aws_cloudwatch_logs_user_config`
+
+Optional:
+
+- `selected_log_fields` (List of String) The list of logging fields that will be sent to the integration logging service. The MESSAGE and timestamp fields are always sent.
+
+
### Nested Schema for `external_aws_cloudwatch_metrics_user_config`
@@ -192,6 +204,22 @@ Required:
+
+### Nested Schema for `external_elasticsearch_logs_user_config`
+
+Optional:
+
+- `selected_log_fields` (List of String) The list of logging fields that will be sent to the integration logging service. The MESSAGE and timestamp fields are always sent.
+
+
+
+### Nested Schema for `external_opensearch_logs_user_config`
+
+Optional:
+
+- `selected_log_fields` (List of String) The list of logging fields that will be sent to the integration logging service. The MESSAGE and timestamp fields are always sent.
+
+
### Nested Schema for `kafka_connect_user_config`
@@ -296,6 +324,43 @@ Optional:
+
+### Nested Schema for `prometheus_user_config`
+
+Optional:
+
+- `source_mysql` (Block List, Max: 1) Configuration options for metrics where source service is MySQL (see [below for nested schema](#nestedblock--prometheus_user_config--source_mysql))
+
+
+### Nested Schema for `prometheus_user_config.source_mysql`
+
+Optional:
+
+- `telegraf` (Block List, Max: 1) Configuration options for Telegraf MySQL input plugin (see [below for nested schema](#nestedblock--prometheus_user_config--source_mysql--telegraf))
+
+
+### Nested Schema for `prometheus_user_config.source_mysql.telegraf`
+
+Optional:
+
+- `gather_event_waits` (Boolean) Gather metrics from PERFORMANCE_SCHEMA.EVENT_WAITS.
+- `gather_file_events_stats` (Boolean) gather metrics from PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME.
+- `gather_index_io_waits` (Boolean) Gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE.
+- `gather_info_schema_auto_inc` (Boolean) Gather auto_increment columns and max values from information schema.
+- `gather_innodb_metrics` (Boolean) Gather metrics from INFORMATION_SCHEMA.INNODB_METRICS.
+- `gather_perf_events_statements` (Boolean) Gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST.
+- `gather_process_list` (Boolean) Gather thread state counts from INFORMATION_SCHEMA.PROCESSLIST.
+- `gather_slave_status` (Boolean) Gather metrics from SHOW SLAVE STATUS command output.
+- `gather_table_io_waits` (Boolean) Gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE.
+- `gather_table_lock_waits` (Boolean) Gather metrics from PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS.
+- `gather_table_schema` (Boolean) Gather metrics from INFORMATION_SCHEMA.TABLES.
+- `perf_events_statements_digest_text_limit` (Number) Truncates digest text from perf_events_statements into this many characters.
+- `perf_events_statements_limit` (Number) Limits metrics from perf_events_statements.
+- `perf_events_statements_time_limit` (Number) Only include perf_events_statements whose last seen is less than this many seconds.
+
+
+
+
### Nested Schema for `timeouts`
diff --git a/go.mod b/go.mod
index 0f1a661a3..498707fde 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,7 @@ go 1.22
require (
github.com/aiven/aiven-go-client/v2 v2.12.0
+ github.com/aiven/go-client-codegen v0.2.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/dave/jennifer v1.7.0
github.com/docker/go-units v0.5.0
@@ -19,8 +20,8 @@ require (
github.com/samber/lo v1.39.0
github.com/stoewer/go-strcase v1.3.0
github.com/stretchr/testify v1.8.4
- golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
- golang.org/x/tools v0.13.0
+ golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
+ golang.org/x/tools v0.17.0
gopkg.in/yaml.v3 v3.0.1
)
@@ -37,7 +38,7 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
- golang.org/x/sync v0.5.0 // indirect
+ golang.org/x/sync v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
@@ -81,7 +82,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
- github.com/mattn/go-isatty v0.0.19 // indirect
+ github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
@@ -98,7 +99,7 @@ require (
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/mod v0.14.0 // indirect
- golang.org/x/net v0.18.0 // indirect
+ golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
diff --git a/go.sum b/go.sum
index abf7e0741..fd9716cbe 100644
--- a/go.sum
+++ b/go.sum
@@ -201,6 +201,8 @@ github.com/aiven/aiven-go-client/v2 v2.12.0 h1:VxOfn61AtfLjy2B+DdXF2/7OHyyFZ1aQa
github.com/aiven/aiven-go-client/v2 v2.12.0/go.mod h1:x0xhzxWEKAwKv0xY5FvECiI6tesWshcPHvjwl0B/1SU=
github.com/aiven/go-api-schemas v1.60.0 h1:R5p3V028HX2BLayO2E24SFs0GehJWTfo7L/vfrTa72Y=
github.com/aiven/go-api-schemas v1.60.0/go.mod h1:/bPxBUHza/2Aeer6hIIdB++GxKiw9K1KCBtRa2rtZ5I=
+github.com/aiven/go-client-codegen v0.2.0 h1:f82CHhXCBbrBIUa3yworytXjiolp/Q73epnbRjQIwBk=
+github.com/aiven/go-client-codegen v0.2.0/go.mod h1:qQ5dwRfNnGS4eAYk7JdC5htQI85g7eA/e71ZLyY8pQw=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
@@ -486,8 +488,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
-github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
-github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 h1:ofNAzWCcyTALn2Zv40+8XitdzCgXY6e9qvXwN9W0YXg=
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
@@ -603,8 +605,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
-golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U=
-golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
+golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o=
+golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -685,8 +687,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
-golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
-golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
+golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
+golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -729,8 +731,8 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
-golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
+golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -883,8 +885,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
-golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
-golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
+golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
+golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/internal/sdkprovider/service/serviceintegration/service_integration.go b/internal/sdkprovider/service/serviceintegration/service_integration.go
index a5d6a6c27..aca26c537 100644
--- a/internal/sdkprovider/service/serviceintegration/service_integration.go
+++ b/internal/sdkprovider/service/serviceintegration/service_integration.go
@@ -8,6 +8,7 @@ import (
"time"
"github.com/aiven/aiven-go-client/v2"
+ codegenintegrations "github.com/aiven/go-client-codegen/handler/serviceintegration"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -29,40 +30,6 @@ func hasConfig(kind string) bool {
return slices.Contains(serviceintegration.UserConfigTypes(), kind)
}
-// typesList integration type list
-func typesList() []string {
- return []string{
- "alertmanager",
- "cassandra_cross_service_cluster",
- "clickhouse_kafka",
- "clickhouse_postgresql",
- "dashboard",
- "datadog",
- "datasource",
- "external_aws_cloudwatch_logs",
- "external_aws_cloudwatch_metrics",
- "external_elasticsearch_logs",
- "external_google_cloud_logging",
- "external_opensearch_logs",
- "flink",
- "internal_connectivity",
- "jolokia",
- "kafka_connect",
- "kafka_logs",
- "kafka_mirrormaker",
- "logs",
- "m3aggregator",
- "m3coordinator",
- "metrics",
- "opensearch_cross_cluster_replication",
- "opensearch_cross_cluster_search",
- "prometheus",
- "read_replica",
- "rsyslog",
- "schema_registry_proxy",
- }
-}
-
func aivenServiceIntegrationSchema() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"integration_id": {
@@ -85,11 +52,11 @@ func aivenServiceIntegrationSchema() map[string]*schema.Schema {
Type: schema.TypeString,
},
"integration_type": {
- Description: "Type of the service integration. Possible values: " + schemautil.JoinQuoted(typesList(), ", ", "`"),
+ Description: "Type of the service integration. Possible values: " + schemautil.JoinQuoted(codegenintegrations.IntegrationTypeChoices(), ", ", "`"),
ForceNew: true,
Required: true,
Type: schema.TypeString,
- ValidateFunc: validation.StringInSlice(typesList(), false),
+ ValidateFunc: validation.StringInSlice(codegenintegrations.IntegrationTypeChoices(), false),
},
"project": {
Description: "Project the integration belongs to",
diff --git a/internal/sdkprovider/userconfig/serviceintegration/external_aws_cloudwatch_logs.go b/internal/sdkprovider/userconfig/serviceintegration/external_aws_cloudwatch_logs.go
new file mode 100644
index 000000000..42e3231bc
--- /dev/null
+++ b/internal/sdkprovider/userconfig/serviceintegration/external_aws_cloudwatch_logs.go
@@ -0,0 +1,31 @@
+// Code generated by user config generator. DO NOT EDIT.
+
+package serviceintegration
+
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
+ "github.com/aiven/terraform-provider-aiven/internal/sdkprovider/userconfig/diff"
+)
+
+func externalAwsCloudwatchLogsUserConfig() *schema.Schema {
+ return &schema.Schema{
+ Description: "ExternalAwsCloudwatchLogs user configurable settings",
+ DiffSuppressFunc: diff.SuppressUnchanged,
+ Elem: &schema.Resource{Schema: map[string]*schema.Schema{"selected_log_fields": {
+ Description: "The list of logging fields that will be sent to the integration logging service. The MESSAGE and timestamp fields are always sent.",
+ Elem: &schema.Schema{
+ Description: "Log field name.",
+ Type: schema.TypeString,
+ ValidateFunc: validation.StringInSlice([]string{"HOSTNAME", "PRIORITY", "REALTIME_TIMESTAMP", "service_name", "SYSTEMD_UNIT"}, false),
+ },
+ MaxItems: 5,
+ Optional: true,
+ Type: schema.TypeList,
+ }}},
+ MaxItems: 1,
+ Optional: true,
+ Type: schema.TypeList,
+ }
+}
diff --git a/internal/sdkprovider/userconfig/serviceintegration/external_elasticsearch_logs.go b/internal/sdkprovider/userconfig/serviceintegration/external_elasticsearch_logs.go
new file mode 100644
index 000000000..7a95fecf0
--- /dev/null
+++ b/internal/sdkprovider/userconfig/serviceintegration/external_elasticsearch_logs.go
@@ -0,0 +1,31 @@
+// Code generated by user config generator. DO NOT EDIT.
+
+package serviceintegration
+
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
+ "github.com/aiven/terraform-provider-aiven/internal/sdkprovider/userconfig/diff"
+)
+
+func externalElasticsearchLogsUserConfig() *schema.Schema {
+ return &schema.Schema{
+ Description: "ExternalElasticsearchLogs user configurable settings",
+ DiffSuppressFunc: diff.SuppressUnchanged,
+ Elem: &schema.Resource{Schema: map[string]*schema.Schema{"selected_log_fields": {
+ Description: "The list of logging fields that will be sent to the integration logging service. The MESSAGE and timestamp fields are always sent.",
+ Elem: &schema.Schema{
+ Description: "Log field name.",
+ Type: schema.TypeString,
+ ValidateFunc: validation.StringInSlice([]string{"HOSTNAME", "PRIORITY", "REALTIME_TIMESTAMP", "service_name", "SYSTEMD_UNIT"}, false),
+ },
+ MaxItems: 5,
+ Optional: true,
+ Type: schema.TypeList,
+ }}},
+ MaxItems: 1,
+ Optional: true,
+ Type: schema.TypeList,
+ }
+}
diff --git a/internal/sdkprovider/userconfig/serviceintegration/external_opensearch_logs.go b/internal/sdkprovider/userconfig/serviceintegration/external_opensearch_logs.go
new file mode 100644
index 000000000..fefef4d16
--- /dev/null
+++ b/internal/sdkprovider/userconfig/serviceintegration/external_opensearch_logs.go
@@ -0,0 +1,31 @@
+// Code generated by user config generator. DO NOT EDIT.
+
+package serviceintegration
+
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
+
+ "github.com/aiven/terraform-provider-aiven/internal/sdkprovider/userconfig/diff"
+)
+
+func externalOpensearchLogsUserConfig() *schema.Schema {
+ return &schema.Schema{
+ Description: "ExternalOpensearchLogs user configurable settings",
+ DiffSuppressFunc: diff.SuppressUnchanged,
+ Elem: &schema.Resource{Schema: map[string]*schema.Schema{"selected_log_fields": {
+ Description: "The list of logging fields that will be sent to the integration logging service. The MESSAGE and timestamp fields are always sent.",
+ Elem: &schema.Schema{
+ Description: "Log field name.",
+ Type: schema.TypeString,
+ ValidateFunc: validation.StringInSlice([]string{"HOSTNAME", "PRIORITY", "REALTIME_TIMESTAMP", "service_name", "SYSTEMD_UNIT"}, false),
+ },
+ MaxItems: 5,
+ Optional: true,
+ Type: schema.TypeList,
+ }}},
+ MaxItems: 1,
+ Optional: true,
+ Type: schema.TypeList,
+ }
+}
diff --git a/internal/sdkprovider/userconfig/serviceintegration/prometheus.go b/internal/sdkprovider/userconfig/serviceintegration/prometheus.go
new file mode 100644
index 000000000..ec56b7341
--- /dev/null
+++ b/internal/sdkprovider/userconfig/serviceintegration/prometheus.go
@@ -0,0 +1,103 @@
+// Code generated by user config generator. DO NOT EDIT.
+
+package serviceintegration
+
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+
+ "github.com/aiven/terraform-provider-aiven/internal/sdkprovider/userconfig/diff"
+)
+
+func prometheusUserConfig() *schema.Schema {
+ return &schema.Schema{
+ Description: "Prometheus user configurable settings",
+ DiffSuppressFunc: diff.SuppressUnchanged,
+ Elem: &schema.Resource{Schema: map[string]*schema.Schema{"source_mysql": {
+ Description: "Configuration options for metrics where source service is MySQL",
+ Elem: &schema.Resource{Schema: map[string]*schema.Schema{"telegraf": {
+ Description: "Configuration options for Telegraf MySQL input plugin",
+ Elem: &schema.Resource{Schema: map[string]*schema.Schema{
+ "gather_event_waits": {
+ Description: "Gather metrics from PERFORMANCE_SCHEMA.EVENT_WAITS.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_file_events_stats": {
+ Description: "gather metrics from PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_index_io_waits": {
+ Description: "Gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_info_schema_auto_inc": {
+ Description: "Gather auto_increment columns and max values from information schema.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_innodb_metrics": {
+ Description: "Gather metrics from INFORMATION_SCHEMA.INNODB_METRICS.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_perf_events_statements": {
+ Description: "Gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_process_list": {
+ Description: "Gather thread state counts from INFORMATION_SCHEMA.PROCESSLIST.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_slave_status": {
+ Description: "Gather metrics from SHOW SLAVE STATUS command output.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_table_io_waits": {
+ Description: "Gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_table_lock_waits": {
+ Description: "Gather metrics from PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "gather_table_schema": {
+ Description: "Gather metrics from INFORMATION_SCHEMA.TABLES.",
+ Optional: true,
+ Type: schema.TypeBool,
+ },
+ "perf_events_statements_digest_text_limit": {
+ Description: "Truncates digest text from perf_events_statements into this many characters.",
+ Optional: true,
+ Type: schema.TypeInt,
+ },
+ "perf_events_statements_limit": {
+ Description: "Limits metrics from perf_events_statements.",
+ Optional: true,
+ Type: schema.TypeInt,
+ },
+ "perf_events_statements_time_limit": {
+ Description: "Only include perf_events_statements whose last seen is less than this many seconds.",
+ Optional: true,
+ Type: schema.TypeInt,
+ },
+ }},
+ MaxItems: 1,
+ Optional: true,
+ Type: schema.TypeList,
+ }}},
+ MaxItems: 1,
+ Optional: true,
+ Type: schema.TypeList,
+ }}},
+ MaxItems: 1,
+ Optional: true,
+ Type: schema.TypeList,
+ }
+}
diff --git a/internal/sdkprovider/userconfig/serviceintegration/serviceintegration.go b/internal/sdkprovider/userconfig/serviceintegration/serviceintegration.go
index a831ab9b3..8710e5cb5 100644
--- a/internal/sdkprovider/userconfig/serviceintegration/serviceintegration.go
+++ b/internal/sdkprovider/userconfig/serviceintegration/serviceintegration.go
@@ -12,8 +12,14 @@ func GetUserConfig(kind string) *schema.Schema {
return clickhousePostgresqlUserConfig()
case "datadog":
return datadogUserConfig()
+ case "external_aws_cloudwatch_logs":
+ return externalAwsCloudwatchLogsUserConfig()
case "external_aws_cloudwatch_metrics":
return externalAwsCloudwatchMetricsUserConfig()
+ case "external_elasticsearch_logs":
+ return externalElasticsearchLogsUserConfig()
+ case "external_opensearch_logs":
+ return externalOpensearchLogsUserConfig()
case "kafka_connect":
return kafkaConnectUserConfig()
case "kafka_logs":
@@ -24,10 +30,12 @@ func GetUserConfig(kind string) *schema.Schema {
return logsUserConfig()
case "metrics":
return metricsUserConfig()
+ case "prometheus":
+ return prometheusUserConfig()
default:
panic("unknown user config type: " + kind)
}
}
func UserConfigTypes() []string {
- return []string{"clickhouse_kafka", "clickhouse_postgresql", "datadog", "external_aws_cloudwatch_metrics", "kafka_connect", "kafka_logs", "kafka_mirrormaker", "logs", "metrics"}
+ return []string{"clickhouse_kafka", "clickhouse_postgresql", "datadog", "external_aws_cloudwatch_logs", "external_aws_cloudwatch_metrics", "external_elasticsearch_logs", "external_opensearch_logs", "kafka_connect", "kafka_logs", "kafka_mirrormaker", "logs", "metrics", "prometheus"}
}
diff --git a/main.go b/main.go
index 118a84a4b..4d7c58dec 100644
--- a/main.go
+++ b/main.go
@@ -12,8 +12,7 @@ import (
)
//go:generate go test -tags userconfig ./internal/schemautil/userconfig
-//go:generate go run ./ucgenerator/... --services cassandra,clickhouse,flink,grafana,influxdb,kafka,kafka_connect,kafka_mirrormaker,m3aggregator,m3db,mysql,opensearch,pg,redis
-//go:generate go run ./ucgenerator/... --integrations logs,kafka_mirrormaker,kafka_connect,kafka_logs,metrics,datadog,clickhouse_kafka,clickhouse_postgresql,external_aws_cloudwatch_metrics
+//go:generate go run ./ucgenerator/... --excludeServices elasticsearch,dragonfly
// registryPrefix is the registry prefix for the provider.
const registryPrefix = "registry.terraform.io/"
diff --git a/ucgenerator/main.go b/ucgenerator/main.go
index 8361903e9..306106e58 100644
--- a/ucgenerator/main.go
+++ b/ucgenerator/main.go
@@ -11,6 +11,7 @@ import (
"github.com/aiven/go-api-schemas/pkg/dist"
"github.com/dave/jennifer/jen"
+ "golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/tools/imports"
"gopkg.in/yaml.v3"
@@ -27,35 +28,26 @@ const (
func main() {
var serviceList, integrationList string
- flag.StringVar(&serviceList, "services", "", "Comma separated service list of names")
- flag.StringVar(&integrationList, "integrations", "", "Comma separated integrations list of names")
+ flag.StringVar(&serviceList, "excludeServices", "", "Comma separated list of names to exclude from generation")
+ flag.StringVar(&integrationList, "excludeIntegrations", "", "Comma separated list of names to exclude from generation")
flag.Parse()
- if serviceList+integrationList == "" {
- log.Fatal("--services or --integrations must be provided")
- }
-
- if serviceList != "" {
- err := generate("service", dist.ServiceTypes, strings.Split(serviceList, ","))
- if err != nil {
- log.Fatal(err)
- }
+ err := generate("service", dist.ServiceTypes, strings.Split(serviceList, ","))
+ if err != nil {
+ log.Fatalf("generating services: %s", err)
}
- if integrationList != "" {
- err := generate("serviceintegration", dist.IntegrationTypes, strings.Split(integrationList, ","))
- if err != nil {
- log.Fatal(err)
- }
+ err = generate("serviceintegration", dist.IntegrationTypes, strings.Split(integrationList, ","))
+ if err != nil {
+ log.Fatalf("generating integrations: %s", err)
}
}
-func generate(kind string, data []byte, keys []string) error {
+func generate(kind string, data []byte, exclude []string) error {
// Fixes imports order
imports.LocalPrefix = localPrefix
var root map[string]*object
-
err := yaml.Unmarshal(data, &root)
if err != nil {
return err
@@ -67,16 +59,27 @@ func generate(kind string, data []byte, keys []string) error {
return err
}
+ keys := maps.Keys(root)
slices.Sort(keys)
doneKeys := make([]string, 0, len(keys))
doneNames := make([]string, 0, len(keys))
for _, key := range keys {
+ if slices.Contains(exclude, key) {
+ log.Printf("skipping %q: in exclude list", key)
+ continue
+ }
+
o, ok := root[key]
if !ok {
return fmt.Errorf("key %q not found in spec", key)
}
+ if len(o.Properties) == 0 {
+ log.Printf("skipping %q: empty root object", key)
+ continue
+ }
+
o.isRoot = true
o.init(key + "_user_config")
if o.Description == "" {
@@ -91,7 +94,10 @@ func generate(kind string, data []byte, keys []string) error {
f.ImportName(importSchema, "schema")
f.ImportName(importDiff, "diff")
f.ImportName(importValidation, "validation")
- genSchema(f, o)
+ err := genSchema(f, o)
+ if err != nil {
+ return fmt.Errorf("error generating %q: %w", key, err)
+ }
// Sorts imports
b, err := imports.Process("", []byte(f.GoString()), nil)
@@ -124,7 +130,7 @@ func generate(kind string, data []byte, keys []string) error {
)
configTypes := make([]jen.Code, 0)
- for _, v := range keys {
+ for _, v := range doneKeys {
configTypes = append(configTypes, jen.Lit(v))
}
f.Func().Id("UserConfigTypes").Params().Index().String().Block(
@@ -133,13 +139,19 @@ func generate(kind string, data []byte, keys []string) error {
return f.Save(filepath.Join(dirPath, kind+".go"))
}
-func genSchema(f *jen.File, o *object) {
+func genSchema(f *jen.File, o *object) error {
+ values, err := getSchemaValues(o)
+ if err != nil {
+ return err
+ }
+
f.Func().Id(o.camelName).Params().Op("*").Qual(importSchema, "Schema").Block(
- jen.Return(jen.Op("&").Qual(importSchema, "Schema").Values(getSchemaValues(o))),
+ jen.Return(jen.Op("&").Qual(importSchema, "Schema").Values(values)),
)
+ return nil
}
-func getSchemaValues(o *object) jen.Dict {
+func getSchemaValues(o *object) (jen.Dict, error) {
values := make(jen.Dict)
if d := getDescription(o); d != "" {
@@ -154,7 +166,7 @@ func getSchemaValues(o *object) jen.Dict {
case objectTypeObject, objectTypeArray:
if o.isSchemaless() {
// todo: handle schemaless if this happens
- log.Fatalf("schemaless is not implemented: %q", o.jsonName)
+ return nil, fmt.Errorf("schemaless is not implemented: %q", o.jsonName)
}
t = "List"
@@ -177,13 +189,13 @@ func getSchemaValues(o *object) jen.Dict {
case objectTypeNumber:
t = "Float"
default:
- log.Fatalf("unknown type %q for %q", o.Type, o.jsonName)
+ return nil, fmt.Errorf("unknown type %q for %q", o.Type, o.jsonName)
}
values[jen.Id("Type")] = jen.Qual(importSchema, "Type"+t)
if o.IsDeprecated {
if o.DeprecationNotice == "" {
- log.Fatalf("missing deprecation notice for %q", o.jsonName)
+ return nil, fmt.Errorf("missing deprecation notice for %q", o.jsonName)
}
values[jen.Id("Deprecated")] = jen.Lit(o.DeprecationNotice)
}
@@ -212,24 +224,33 @@ func getSchemaValues(o *object) jen.Dict {
args = append(args, scalarLit(o, v.Value))
}
+ call, err := scalarArrayLit(o, args)
+ if err != nil {
+ return nil, err
+ }
+
// There are no other types functions.
// Bool and number won't compile
switch o.Type {
case objectTypeString:
- values[jen.Id("ValidateFunc")] = jen.Qual(importValidation, "StringInSlice").Call(scalarArrayLit(o, args), jen.False())
+ values[jen.Id("ValidateFunc")] = jen.Qual(importValidation, "StringInSlice").Call(call, jen.False())
case objectTypeInteger:
- values[jen.Id("ValidateFunc")] = jen.Qual(importValidation, "IntInSlice").Call(scalarArrayLit(o, args))
+ values[jen.Id("ValidateFunc")] = jen.Qual(importValidation, "IntInSlice").Call(call)
}
}
- return values
+ return values, nil
}
if o.isArray() {
if o.ArrayItems.isScalar() {
- fields := getSchemaValues(o.ArrayItems)
+ fields, err := getSchemaValues(o.ArrayItems)
+ if err != nil {
+ return nil, err
+ }
+
values[jen.Id("Elem")] = jen.Op("&").Qual(importSchema, "Schema").Values(fields)
- return values
+ return values, nil
}
// Renders the array as an object
@@ -242,14 +263,19 @@ func getSchemaValues(o *object) jen.Dict {
fields := make(jen.Dict)
for _, p := range o.properties {
- fields[jen.Lit(p.tfName)] = jen.Values(getSchemaValues(p))
+ vals, err := getSchemaValues(p)
+ if err != nil {
+ return nil, err
+ }
+
+ fields[jen.Lit(p.tfName)] = jen.Values(vals)
}
values[jen.Id("Elem")] = jen.Op("&").Qual(importSchema, "Resource").Values(jen.Dict{
jen.Id("Schema"): jen.Map(jen.String()).Op("*").Qual(importSchema, "Schema").Values(fields),
})
- return values
+ return values, nil
}
func getDescription(o *object) string {
@@ -312,15 +338,14 @@ func scalarLit(o *object, value any) *jen.Statement {
return nil
}
-func scalarArrayLit(o *object, args []jen.Code) *jen.Statement {
+func scalarArrayLit(o *object, args []jen.Code) (*jen.Statement, error) {
switch o.Type {
case objectTypeString:
- return jen.Index().String().Values(args...)
+ return jen.Index().String().Values(args...), nil
case objectTypeInteger:
- return jen.Index().Int().Values(args...)
+ return jen.Index().Int().Values(args...), nil
}
- log.Fatalf("unexpected element type of array for default value: %q", o.Type)
- return nil
+ return nil, fmt.Errorf("unexpected element type of array for default value: %q", o.Type)
}
func isTypeSet(o *object) bool {