From a36c0b46d8a8f5f946471872ac8ce8dd56bfb678 Mon Sep 17 00:00:00 2001 From: Guangning E Date: Thu, 11 Jan 2024 15:51:47 +0800 Subject: [PATCH] Support docs for terraform cloud provider (#14) * Generate docs for cloud provider * Update pool, poolnamespace and location desc --- cloud/data_source_pulsar_cluster.go | 13 +---- cloud/data_source_service_account.go | 2 - cloud/provider.go | 21 ++++---- cloud/resource_service_account.go | 1 - docs/data-sources/pulsar_cluster.md | 70 ++++++++++++++++++++++++++ docs/data-sources/pulsar_instance.md | 31 ++++++++++++ docs/data-sources/service_account.md | 32 ++++++++++++ docs/index.md | 34 +++---------- docs/resources/pulsar_cluster.md | 73 ++++++++++++++++++++++++++++ docs/resources/pulsar_instance.md | 31 ++++++++++++ docs/resources/service_account.md | 32 ++++++++++++ examples/service-accounts/README.md | 2 - 12 files changed, 289 insertions(+), 53 deletions(-) create mode 100644 docs/data-sources/pulsar_cluster.md create mode 100644 docs/data-sources/pulsar_instance.md create mode 100644 docs/data-sources/service_account.md create mode 100644 docs/resources/pulsar_cluster.md create mode 100644 docs/resources/pulsar_instance.md create mode 100644 docs/resources/service_account.md delete mode 100644 examples/service-accounts/README.md diff --git a/cloud/data_source_pulsar_cluster.go b/cloud/data_source_pulsar_cluster.go index 539a654..bd1a933 100644 --- a/cloud/data_source_pulsar_cluster.go +++ b/cloud/data_source_pulsar_cluster.go @@ -84,43 +84,36 @@ func dataSourcePulsarCluster() *schema.Resource { }, "config": { Type: schema.TypeList, - Optional: true, Computed: true, - MinItems: 0, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "websocket_enabled": { Type: schema.TypeBool, - Optional: true, Computed: true, }, "function_enabled": { Type: schema.TypeBool, - Optional: true, Computed: true, Description: descriptions["function_enabled"], }, "transaction_enabled": { Type: schema.TypeBool, - Optional: true, Computed: true, Description: descriptions["transaction_enabled"], }, "protocols": { Type: schema.TypeList, - Optional: true, + Computed: true, Description: descriptions["protocols"], Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "kafka": { Type: schema.TypeMap, - Optional: true, Computed: true, Description: descriptions["kafka"], }, "mqtt": { Type: schema.TypeMap, - Optional: true, Computed: true, Description: descriptions["mqtt"], }, @@ -129,16 +122,13 @@ func dataSourcePulsarCluster() *schema.Resource { }, "audit_log": { Type: schema.TypeList, - Optional: true, Computed: true, Description: descriptions["audit_log"], Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "categories": { Type: schema.TypeList, - Optional: true, Computed: true, - MinItems: 1, Description: descriptions["categories"], Elem: &schema.Schema{ Type: schema.TypeString, @@ -150,7 +140,6 @@ func dataSourcePulsarCluster() *schema.Resource { }, "custom": { Type: schema.TypeMap, - Optional: true, Computed: true, Description: descriptions["custom"], }, diff --git a/cloud/data_source_service_account.go b/cloud/data_source_service_account.go index 333ce1d..2f84334 100644 --- a/cloud/data_source_service_account.go +++ b/cloud/data_source_service_account.go @@ -55,13 +55,11 @@ func dataSourceServiceAccount() *schema.Resource { }, "admin": { Type: schema.TypeBool, - Optional: true, Description: descriptions["admin"], Computed: true, }, "private_key_data": { Type: schema.TypeString, - Optional: true, Description: descriptions["private_key_data"], Computed: true, }, diff --git a/cloud/provider.go b/cloud/provider.go index 6fac3af..a982aca 100644 --- a/cloud/provider.go +++ b/cloud/provider.go @@ -46,16 +46,17 @@ var descriptions map[string]string func init() { descriptions = map[string]string{ - "key_file_path": "The path of the private key file", - "organization": "The organization name", - "name": "The service account name", - "admin": "Whether the service account is admin", - "private_key_data": "The private key data", - "availability-mode": "The availability mode, supporting 'zonal' and 'regional'", - "pool_name": "The infrastructure pool name to use.", - "pool_namespace": "The infrastructure pool namespace to use", - "instance_name": "The pulsar instance name", - "location": "The location of the pulsar cluster", + "key_file_path": "The path of the private key file", + "organization": "The organization name", + "name": "The service account name", + "admin": "Whether the service account is admin", + "private_key_data": "The private key data", + "availability-mode": "The availability mode, supporting 'zonal' and 'regional'", + "pool_name": "The infrastructure pool name to use, supported pool 'shared-aws', 'shared-gcp'", + "pool_namespace": "The infrastructure pool namespace to use, supported 'streamnative'", + "instance_name": "The pulsar instance name", + "location": "The location of the pulsar cluster, " + + "supported location https://docs.streamnative.io/docs/cluster#cluster-location", "bookie_replicas": "The number of bookie replicas", "broker_replicas": "The number of broker replicas", "compute_unit": "compute unit, 1 compute unit is 2 cpu and 8gb memory", diff --git a/cloud/resource_service_account.go b/cloud/resource_service_account.go index dfa86f8..1e792e4 100644 --- a/cloud/resource_service_account.go +++ b/cloud/resource_service_account.go @@ -80,7 +80,6 @@ func resourceServiceAccount() *schema.Resource { }, "private_key_data": { Type: schema.TypeString, - Optional: true, Description: descriptions["private_key_data"], Computed: true, }, diff --git a/docs/data-sources/pulsar_cluster.md b/docs/data-sources/pulsar_cluster.md new file mode 100644 index 0000000..d9803db --- /dev/null +++ b/docs/data-sources/pulsar_cluster.md @@ -0,0 +1,70 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative_pulsar_cluster Data Source - terraform-provider-streamnative" +subcategory: "" +description: |- + +--- + +# streamnative_pulsar_cluster (Data Source) + + + + + + +## Schema + +### Required + +- `name` (String) The service account name +- `organization` (String) The organization name + +### Read-Only + +- `bookie_replicas` (Number) The number of bookie replicas +- `bookkeeper_version` (String) The version of the bookkeeper cluster +- `broker_replicas` (Number) The number of broker replicas +- `compute_unit` (Number) compute unit, 1 compute unit is 2 cpu and 8gb memory +- `config` (List of Object) (see [below for nested schema](#nestedatt--config)) +- `http_tls_service_url` (String) The service url of the pulsar cluster, use it to management the pulsar cluster +- `id` (String) The ID of this resource. +- `instance_name` (String) The pulsar instance name +- `kafka_service_url` (String) If you want to connect to the pulsar cluster using the kafka protocol, use this kafka service url +- `location` (String) The location of the pulsar cluster, supported location https://docs.streamnative.io/docs/cluster#cluster-location +- `mqtt_service_url` (String) If you want to connect to the pulsar cluster using the mqtt protocol, use this mqtt service url +- `pulsar_tls_service_url` (String) The service url of the pulsar cluster, use it to produce and consume message +- `pulsar_version` (String) The version of the pulsar cluster +- `ready` (String) Pulsar cluster is ready, it will be set to 'True' after the cluster is ready +- `storage_unit` (Number) storage unit, 1 storage unit is 2 cpu and 8gb memory +- `websocket_service_url` (String) If you want to connect to the pulsar cluster using the websocket protocol, use this websocket service url + + +### Nested Schema for `config` + +Read-Only: + +- `audit_log` (List of Object) (see [below for nested schema](#nestedobjatt--config--audit_log)) +- `custom` (Map of String) +- `function_enabled` (Boolean) +- `protocols` (List of Object) (see [below for nested schema](#nestedobjatt--config--protocols)) +- `transaction_enabled` (Boolean) +- `websocket_enabled` (Boolean) + + +### Nested Schema for `config.audit_log` + +Read-Only: + +- `categories` (List of String) + + + +### Nested Schema for `config.protocols` + +Read-Only: + +- `kafka` (Map of String) +- `mqtt` (Map of String) + + diff --git a/docs/data-sources/pulsar_instance.md b/docs/data-sources/pulsar_instance.md new file mode 100644 index 0000000..881b670 --- /dev/null +++ b/docs/data-sources/pulsar_instance.md @@ -0,0 +1,31 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative_pulsar_instance Data Source - terraform-provider-streamnative" +subcategory: "" +description: |- + +--- + +# streamnative_pulsar_instance (Data Source) + + + + + + +## Schema + +### Required + +- `name` (String) The service account name +- `organization` (String) The organization name + +### Read-Only + +- `availability_mode` (String) The availability mode, supporting 'zonal' and 'regional' +- `id` (String) The ID of this resource. +- `pool_name` (String) The infrastructure pool name to use, supported pool 'shared-aws', 'shared-gcp' +- `pool_namespace` (String) The infrastructure pool namespace to use, supported 'streamnative' +- `ready` (String) Pulsar instance is ready, it will be set to 'True' after the instance is ready + + diff --git a/docs/data-sources/service_account.md b/docs/data-sources/service_account.md new file mode 100644 index 0000000..94eff59 --- /dev/null +++ b/docs/data-sources/service_account.md @@ -0,0 +1,32 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative_service_account Data Source - terraform-provider-streamnative" +subcategory: "" +description: |- + +--- + +# streamnative_service_account (Data Source) + + + + + + +## Schema + +### Required + +- `organization` (String) The organization name + +### Optional + +- `name` (String) The service account name + +### Read-Only + +- `admin` (Boolean) Whether the service account is admin +- `id` (String) The ID of this resource. +- `private_key_data` (String) The private key data + + diff --git a/docs/index.md b/docs/index.md index 09dd974..33fb5d1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,38 +1,20 @@ --- -page_title: "Provider: StreamNative" +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative Provider" subcategory: "" description: |- + --- -# StreamNative Provider +# streamnative Provider -Simplify Apache Pulsar Terraform deployment with the StreamNative Terraform Provider. Manage Pulsar Instances, Pulsar Clusters, Service Accounts, and more in StreamNative. -Use the StreamNative provider to deploy and manage [StreamNative Cloud](https://console.streamnative.cloud) infrastructure. You must provide appropriate credentials to use the provider. The navigation menu provides details about the resources that you can interact with (_Resources_), and a guide (_Guides_) for how you can get started. -## Example Usage - ```hcl - terraform { - required_providers { - pulsar = { - version = "0.1.0" - source = "registry.terraform.io/streamnative/streamnative" - } - } - } - ``` -[Add example] + +## Schema -## Enable StreamNative Cloud Access +### Required -[Document how to enable StreamNative Cloud Access] - -## Provider Authentication - -StreamNative Terraform provider allows authentication by using ... - -## Helpful Links/Information - -* [Report Bugs](https://github.com/streamnative/terraform-provider-streamnative/issues) \ No newline at end of file +- `key_file_path` (String) The path of the private key file diff --git a/docs/resources/pulsar_cluster.md b/docs/resources/pulsar_cluster.md new file mode 100644 index 0000000..2eb6092 --- /dev/null +++ b/docs/resources/pulsar_cluster.md @@ -0,0 +1,73 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative_pulsar_cluster Resource - terraform-provider-streamnative" +subcategory: "" +description: |- + +--- + +# streamnative_pulsar_cluster (Resource) + + + + + + +## Schema + +### Required + +- `instance_name` (String) The pulsar instance name +- `location` (String) The location of the pulsar cluster, supported location https://docs.streamnative.io/docs/cluster#cluster-location +- `name` (String) The service account name +- `organization` (String) The organization name + +### Optional + +- `bookie_replicas` (Number) The number of bookie replicas +- `broker_replicas` (Number) The number of broker replicas +- `compute_unit` (Number) compute unit, 1 compute unit is 2 cpu and 8gb memory +- `config` (Block List) (see [below for nested schema](#nestedblock--config)) +- `storage_unit` (Number) storage unit, 1 storage unit is 2 cpu and 8gb memory + +### Read-Only + +- `bookkeeper_version` (String) The version of the bookkeeper cluster +- `http_tls_service_url` (String) The service url of the pulsar cluster, use it to management the pulsar cluster +- `id` (String) The ID of this resource. +- `kafka_service_url` (String) If you want to connect to the pulsar cluster using the kafka protocol, use this kafka service url +- `mqtt_service_url` (String) If you want to connect to the pulsar cluster using the mqtt protocol, use this mqtt service url +- `pulsar_tls_service_url` (String) The service url of the pulsar cluster, use it to produce and consume message +- `pulsar_version` (String) The version of the pulsar cluster +- `ready` (String) Pulsar cluster is ready, it will be set to 'True' after the cluster is ready +- `websocket_service_url` (String) If you want to connect to the pulsar cluster using the websocket protocol, use this websocket service url + + +### Nested Schema for `config` + +Optional: + +- `audit_log` (Block List) (see [below for nested schema](#nestedblock--config--audit_log)) +- `custom` (Map of String) Controls the custom config of pulsar cluster +- `function_enabled` (Boolean) Whether the function is enabled +- `protocols` (Block List) (see [below for nested schema](#nestedblock--config--protocols)) +- `transaction_enabled` (Boolean) Whether the transaction is enabled +- `websocket_enabled` (Boolean) + + +### Nested Schema for `config.audit_log` + +Optional: + +- `categories` (List of String) Controls the audit log categories config of pulsar cluster, supported categories: "Management", "Describe", "Produce", "Consume" + + + +### Nested Schema for `config.protocols` + +Optional: + +- `kafka` (Map of String) Controls the kafka protocol config of pulsar cluster +- `mqtt` (Map of String) Controls the mqtt protocol config of pulsar cluster + + diff --git a/docs/resources/pulsar_instance.md b/docs/resources/pulsar_instance.md new file mode 100644 index 0000000..1adc5e1 --- /dev/null +++ b/docs/resources/pulsar_instance.md @@ -0,0 +1,31 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative_pulsar_instance Resource - terraform-provider-streamnative" +subcategory: "" +description: |- + +--- + +# streamnative_pulsar_instance (Resource) + + + + + + +## Schema + +### Required + +- `availability_mode` (String) The availability mode, supporting 'zonal' and 'regional' +- `name` (String) The service account name +- `organization` (String) The organization name +- `pool_name` (String) The infrastructure pool name to use, supported pool 'shared-aws', 'shared-gcp' +- `pool_namespace` (String) The infrastructure pool namespace to use, supported 'streamnative' + +### Read-Only + +- `id` (String) The ID of this resource. +- `ready` (String) Pulsar instance is ready, it will be set to 'True' after the instance is ready + + diff --git a/docs/resources/service_account.md b/docs/resources/service_account.md new file mode 100644 index 0000000..82af60c --- /dev/null +++ b/docs/resources/service_account.md @@ -0,0 +1,32 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "streamnative_service_account Resource - terraform-provider-streamnative" +subcategory: "" +description: |- + +--- + +# streamnative_service_account (Resource) + + + + + + +## Schema + +### Required + +- `organization` (String) The organization name + +### Optional + +- `admin` (Boolean) Whether the service account is admin +- `name` (String) The service account name + +### Read-Only + +- `id` (String) The ID of this resource. +- `private_key_data` (String) The private key data + + diff --git a/examples/service-accounts/README.md b/examples/service-accounts/README.md deleted file mode 100644 index 07afa15..0000000 --- a/examples/service-accounts/README.md +++ /dev/null @@ -1,2 +0,0 @@ -## Notes -