Skip to content

Commit

Permalink
chore: docs and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gene-redpanda committed Jul 30, 2024
1 parent a2a51d9 commit 8dcf2b8
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 15 deletions.
88 changes: 88 additions & 0 deletions docs/data-sources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,110 @@ Data source for a Redpanda Cloud cluster

- `id` (String) The ID of the cluster

### Optional

- `aws_private_link` (Attributes) (see [below for nested schema](#nestedatt--aws_private_link))
- `gcp_private_service_connect` (Attributes) (see [below for nested schema](#nestedatt--gcp_private_service_connect))

### Read-Only

- `allow_deletion` (Boolean) allows deletion of the cluster. defaults to true. Not recommended for production use
- `cloud_provider` (String) Must be one of aws or gcp
- `cluster_api_url` (String) The URL of the cluster API
- `cluster_type` (String) Type of the cluster
- `connection_type` (String) Connection type of the cluster
- `http_proxy` (Attributes) (see [below for nested schema](#nestedatt--http_proxy))
- `kafka_api` (Attributes) (see [below for nested schema](#nestedatt--kafka_api))
- `name` (String) Name of the cluster
- `network_id` (String) The ID of the network in which to create the cluster
- `read_replica_cluster_ids` (List of String)
- `redpanda_version` (String) Version of Redpanda to deploy
- `region` (String) Cloud provider specific region of the cluster
- `resource_group_id` (String) The ID of the resource group in which to create the cluster
- `schema_registry` (Attributes) (see [below for nested schema](#nestedatt--schema_registry))
- `tags` (Map of String) Tags to apply to the cluster
- `throughput_tier` (String) Throughput tier of the cluster
- `zones` (List of String) Cloud provider specific zones of the cluster

<a id="nestedatt--aws_private_link"></a>
### Nested Schema for `aws_private_link`

Required:

- `allowed_principals` (List of String)
- `enabled` (Boolean)


<a id="nestedatt--gcp_private_service_connect"></a>
### Nested Schema for `gcp_private_service_connect`

Required:

- `consumer_accept_list` (Attributes List) (see [below for nested schema](#nestedatt--gcp_private_service_connect--consumer_accept_list))
- `enabled` (Boolean)
- `global_access_enabled` (Boolean)

<a id="nestedatt--gcp_private_service_connect--consumer_accept_list"></a>
### Nested Schema for `gcp_private_service_connect.consumer_accept_list`

Required:

- `source` (String)



<a id="nestedatt--http_proxy"></a>
### Nested Schema for `http_proxy`

Read-Only:

- `mtls` (Attributes) (see [below for nested schema](#nestedatt--http_proxy--mtls))

<a id="nestedatt--http_proxy--mtls"></a>
### Nested Schema for `http_proxy.mtls`

Read-Only:

- `ca_certificates_pem` (List of String)
- `enabled` (Boolean)
- `principal_mapping_rules` (List of String)



<a id="nestedatt--kafka_api"></a>
### Nested Schema for `kafka_api`

Read-Only:

- `mtls` (Attributes) (see [below for nested schema](#nestedatt--kafka_api--mtls))

<a id="nestedatt--kafka_api--mtls"></a>
### Nested Schema for `kafka_api.mtls`

Read-Only:

- `ca_certificates_pem` (List of String)
- `enabled` (Boolean)
- `principal_mapping_rules` (List of String)



<a id="nestedatt--schema_registry"></a>
### Nested Schema for `schema_registry`

Read-Only:

- `mtls` (Attributes) (see [below for nested schema](#nestedatt--schema_registry--mtls))

<a id="nestedatt--schema_registry--mtls"></a>
### Nested Schema for `schema_registry.mtls`

Read-Only:

- `ca_certificates_pem` (List of String)
- `enabled` (Boolean)
- `principal_mapping_rules` (List of String)

## Usage

```hcl
Expand Down
72 changes: 65 additions & 7 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ Enables the provisioning and management of Redpanda clusters on AWS and GCP. A c
### Optional

- `allow_deletion` (Boolean) allows deletion of the cluster. defaults to true. should probably be set to false for production use
- `aws_private_link` (Attributes) (see [below for nested schema](#nestedatt--aws_private_link))
- `aws_private_link` (Attributes) The AWS Private Link configuration (see [below for nested schema](#nestedatt--aws_private_link))
- `cloud_provider` (String) Must be one of aws or gcp
- `gcp_private_service_connect` (Attributes) (see [below for nested schema](#nestedatt--gcp_private_service_connect))
- `gcp_private_service_connect` (Attributes) The GCP Private Service Connect configuration (see [below for nested schema](#nestedatt--gcp_private_service_connect))
- `http_proxy` (Attributes) (see [below for nested schema](#nestedatt--http_proxy))
- `kafka_api` (Attributes) The mutual TLS configuration for the Kafka API (see [below for nested schema](#nestedatt--kafka_api))
- `read_replica_cluster_ids` (List of String) The IDs of the read replica clusters
- `redpanda_version` (String) Version of Redpanda to deploy
- `region` (String) Cloud provider specific region of the cluster
- `schema_registry` (Attributes) (see [below for nested schema](#nestedatt--schema_registry))
- `tags` (Map of String) Tags to apply to the cluster
- `zones` (List of String) Cloud provider specific zones of the cluster

Expand All @@ -44,7 +48,7 @@ Enables the provisioning and management of Redpanda clusters on AWS and GCP. A c

Required:

- `allowed_principals` (List of String)
- `allowed_principals` (List of String) The ARNs of the allowed principals
- `enabled` (Boolean)


Expand All @@ -53,16 +57,70 @@ Required:

Required:

- `consumer_accept_list` (Attributes List) (see [below for nested schema](#nestedatt--gcp_private_service_connect--consumer_accept_list))
- `enabled` (Boolean)
- `global_access_enabled` (Boolean)
- `consumer_accept_list` (Attributes List) The list of consumers to accept (see [below for nested schema](#nestedatt--gcp_private_service_connect--consumer_accept_list))
- `enabled` (Boolean) Whether to enable GCP Private Service Connect
- `global_access_enabled` (Boolean) Whether to enable global access for GCP Private Service Connect

<a id="nestedatt--gcp_private_service_connect--consumer_accept_list"></a>
### Nested Schema for `gcp_private_service_connect.consumer_accept_list`

Required:

- `source` (String)
- `source` (String) The source of the consumer



<a id="nestedatt--http_proxy"></a>
### Nested Schema for `http_proxy`

Required:

- `mtls` (Attributes) The mutual TLS configuration for the HTTP Proxy (see [below for nested schema](#nestedatt--http_proxy--mtls))

<a id="nestedatt--http_proxy--mtls"></a>
### Nested Schema for `http_proxy.mtls`

Required:

- `ca_certificates_pem` (List of String) The CA certificates in PEM format
- `enabled` (Boolean) Whether to enable mutual TLS for the HTTP Proxy
- `principal_mapping_rules` (List of String) The principal mapping rules



<a id="nestedatt--kafka_api"></a>
### Nested Schema for `kafka_api`

Required:

- `mtls` (Attributes) The mutual TLS configuration for the Kafka API (see [below for nested schema](#nestedatt--kafka_api--mtls))

<a id="nestedatt--kafka_api--mtls"></a>
### Nested Schema for `kafka_api.mtls`

Required:

- `ca_certificates_pem` (List of String) The CA certificates in PEM format
- `enabled` (Boolean) Whether to enable mutual TLS for the Kafka API
- `principal_mapping_rules` (List of String) The principal mapping rules



<a id="nestedatt--schema_registry"></a>
### Nested Schema for `schema_registry`

Required:

- `mtls` (Attributes) The mutual TLS configuration for the Schema Registry (see [below for nested schema](#nestedatt--schema_registry--mtls))

<a id="nestedatt--schema_registry--mtls"></a>
### Nested Schema for `schema_registry.mtls`

Required:

- `ca_certificates_pem` (List of String) The CA certificates in PEM format
- `enabled` (Boolean) Whether to enable mutual TLS for the Schema Registry
- `principal_mapping_rules` (List of String) The principal mapping rules

## Usage

Expand Down
4 changes: 2 additions & 2 deletions redpanda/resources/cluster/data_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ func (d *DataSourceCluster) Read(ctx context.Context, req datasource.ReadRequest
}
}

kApi, dg := toMtlsModel(ctx, cluster.GetKafkaApi().GetMtls())
kAPI, dg := toMtlsModel(ctx, cluster.GetKafkaApi().GetMtls())
if dg != nil {
resp.Diagnostics.Append(dg...)
return
}
persist.KafkaAPI = &models.KafkaAPI{
Mtls: kApi,
Mtls: kAPI,
}
hp, dg := toMtlsModel(ctx, cluster.GetHttpProxy().GetMtls())
if dg != nil {
Expand Down
13 changes: 7 additions & 6 deletions redpanda/resources/cluster/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ func GenerateClusterRequest(model models.Cluster) (*controlplanev1beta2.ClusterC
return output, nil
}

// GenerateModel populates the Cluster model to be persisted to state for Create, Read and Update operations. It is also indirectly used by Import
func GenerateModel(ctx context.Context, cfg models.Cluster, cluster *controlplanev1beta2.Cluster) (*models.Cluster, error) {
output := &models.Cluster{
Name: types.StringValue(cluster.Name),
Expand Down Expand Up @@ -576,13 +577,13 @@ func GenerateModel(ctx context.Context, cfg models.Cluster, cluster *controlplan
ConsumerAcceptList: gcpConnectConsumerStructToModel(cluster.GcpPrivateServiceConnect.ConsumerAcceptList),
}
}
kApi, err := toMtlsModel(ctx, cluster.GetKafkaApi().GetMtls())
kAPI, err := toMtlsModel(ctx, cluster.GetKafkaApi().GetMtls())
if err != nil {
return nil, fmt.Errorf("failed to parse Kafka API MTLS: %v", err)
}
if kApi != nil {
if kAPI != nil {
output.KafkaAPI = &models.KafkaAPI{
Mtls: kApi,
Mtls: kAPI,
}
}
ht, err := toMtlsModel(ctx, cluster.GetHttpProxy().GetMtls())
Expand Down Expand Up @@ -688,7 +689,7 @@ func isMtlsStructNil(m *models.Mtls) bool {
}

func isMtlsSpecNil(m *controlplanev1beta2.MTLSSpec) bool {
return m == nil || (m.GetEnabled() == false && len(m.GetCaCertificatesPem()) == 0 && len(m.GetPrincipalMappingRules()) == 0)
return m == nil || (!m.GetEnabled() && len(m.GetCaCertificatesPem()) == 0 && len(m.GetPrincipalMappingRules()) == 0)
}

func emptyMtlsSpec() *controlplanev1beta2.MTLSSpec {
Expand All @@ -704,13 +705,13 @@ func isAwsPrivateLinkStructNil(m *models.AwsPrivateLink) bool {
}

func isAwsPrivateLinkSpecNil(m *controlplanev1beta2.AWSPrivateLinkStatus) bool {
return m == nil || (m.Enabled == false && len(m.AllowedPrincipals) == 0)
return m == nil || (!m.Enabled && len(m.AllowedPrincipals) == 0)
}

func isGcpPrivateServiceConnectStructNil(m *models.GcpPrivateServiceConnect) bool {
return m == nil || (m.Enabled.IsNull() && m.GlobalAccessEnabled.IsNull() && len(m.ConsumerAcceptList) == 0)
}

func isGcpPrivateServiceConnectSpecNil(m *controlplanev1beta2.GCPPrivateServiceConnectStatus) bool {
return m == nil || (m.Enabled == false && m.GlobalAccessEnabled == false && len(m.ConsumerAcceptList) == 0)
return m == nil || (!m.Enabled && !m.GlobalAccessEnabled && len(m.ConsumerAcceptList) == 0)
}

0 comments on commit 8dcf2b8

Please sign in to comment.