Skip to content

Commit

Permalink
chore: remove ExternalClusterList type (cloudnative-pg#6426)
Browse files Browse the repository at this point in the history
Our documentation generator is not able to handle that type alias, so
let's get rid of it.

Closes: cloudnative-pg#6427

Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Co-authored-by: Marco Nenciarini <[email protected]>
  • Loading branch information
leonardoce and mnencia authored Dec 23, 2024
1 parent 4334d11 commit ed9105d
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 41 deletions.
1 change: 0 additions & 1 deletion .wordlist-en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ EphemeralVolumeSource
EphemeralVolumesSizeLimit
EphemeralVolumesSizeLimitConfiguration
ExternalCluster
ExternalClusterList
FQDN
Fei
Filesystem
Expand Down
8 changes: 4 additions & 4 deletions api/v1/cluster_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ func (pluginList PluginConfigurationList) GetEnabledPluginNames() (result []stri
return pluginNames
}

// GetEnabledPluginNames gets the name of the plugins that are
// GetExternalClustersEnabledPluginNames gets the name of the plugins that are
// involved in the reconciliation of this external cluster list. This
// list is usually composed by the plugins that need to be active to
// recover data from the external clusters.
func (externalClusterList ExternalClusterList) GetEnabledPluginNames() (result []string) {
pluginNames := make([]string, 0, len(externalClusterList))
for _, externalCluster := range externalClusterList {
func GetExternalClustersEnabledPluginNames(externalClusters []ExternalCluster) (result []string) {
pluginNames := make([]string, 0, len(externalClusters))
for _, externalCluster := range externalClusters {
if externalCluster.PluginConfiguration != nil {
pluginNames = append(pluginNames, externalCluster.PluginConfiguration.Name)
}
Expand Down
5 changes: 1 addition & 4 deletions api/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ type ClusterSpec struct {

// The list of external clusters which are used in the configuration
// +optional
ExternalClusters ExternalClusterList `json:"externalClusters,omitempty"`
ExternalClusters []ExternalCluster `json:"externalClusters,omitempty"`

// The instances' log level, one of the following values: error, warning, info (default), debug, trace
// +kubebuilder:default:=info
Expand Down Expand Up @@ -2060,9 +2060,6 @@ type ClusterMonitoringTLSConfiguration struct {
Enabled bool `json:"enabled,omitempty"`
}

// ExternalClusterList is a list of external clusters
type ExternalClusterList []ExternalCluster

// ExternalCluster represents the connection parameters to an
// external cluster which is used in the other sections of the configuration
type ExternalCluster struct {
Expand Down
23 changes: 1 addition & 22 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ externalPackages:

hideTypePatterns:
- "ParseError$"
# We cannot exclude all `List$` because we declare PluginConfigurationList and ExternalClusterList
# We cannot exclude all `List$` because we declare PluginConfigurationList
- "\\.BackupList$"
- "\\.ClusterList$"
- "\\.ClusterImageCatalogList$"
Expand Down
81 changes: 76 additions & 5 deletions docs/src/cloudnative-pg.v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ it can be with a switchover (<code>switchover</code>) or in-place (<code>restart
</td>
</tr>
<tr><td><code>externalClusters</code><br/>
<a href="#postgresql-cnpg-io-v1-ExternalClusterList"><i>ExternalClusterList</i></a>
<a href="#postgresql-cnpg-io-v1-ExternalCluster"><i>[]ExternalCluster</i></a>
</td>
<td>
<p>The list of external clusters which are used in the configuration</p>
Expand Down Expand Up @@ -2706,19 +2706,89 @@ storage</p>
</tbody>
</table>

## ExternalClusterList {#postgresql-cnpg-io-v1-ExternalClusterList}
## ExternalCluster {#postgresql-cnpg-io-v1-ExternalCluster}

(Alias of `[]github.com/cloudnative-pg/cloudnative-pg/api/v1.ExternalCluster`)

**Appears in:**

- [ClusterSpec](#postgresql-cnpg-io-v1-ClusterSpec)


<p>ExternalClusterList is a list of external clusters</p>

<p>ExternalCluster represents the connection parameters to an
external cluster which is used in the other sections of the configuration</p>


<table class="table">
<thead><tr><th width="30%">Field</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>name</code> <B>[Required]</B><br/>
<i>string</i>
</td>
<td>
<p>The server name, required</p>
</td>
</tr>
<tr><td><code>connectionParameters</code><br/>
<i>map[string]string</i>
</td>
<td>
<p>The list of connection parameters, such as dbname, host, username, etc</p>
</td>
</tr>
<tr><td><code>sslCert</code><br/>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#secretkeyselector-v1-core"><i>core/v1.SecretKeySelector</i></a>
</td>
<td>
<p>The reference to an SSL certificate to be used to connect to this
instance</p>
</td>
</tr>
<tr><td><code>sslKey</code><br/>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#secretkeyselector-v1-core"><i>core/v1.SecretKeySelector</i></a>
</td>
<td>
<p>The reference to an SSL private key to be used to connect to this
instance</p>
</td>
</tr>
<tr><td><code>sslRootCert</code><br/>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#secretkeyselector-v1-core"><i>core/v1.SecretKeySelector</i></a>
</td>
<td>
<p>The reference to an SSL CA public key to be used to connect to this
instance</p>
</td>
</tr>
<tr><td><code>password</code><br/>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#secretkeyselector-v1-core"><i>core/v1.SecretKeySelector</i></a>
</td>
<td>
<p>The reference to the password to be used to connect to the server.
If a password is provided, CloudNativePG creates a PostgreSQL
passfile at <code>/controller/external/NAME/pass</code> (where &quot;NAME&quot; is the
cluster's name). This passfile is automatically referenced in the
connection string when establishing a connection to the remote
PostgreSQL server from the current PostgreSQL <code>Cluster</code>. This ensures
secure and efficient password management for external clusters.</p>
</td>
</tr>
<tr><td><code>barmanObjectStore</code><br/>
<a href="https://pkg.go.dev/github.com/cloudnative-pg/barman-cloud/pkg/api/#BarmanObjectStoreConfiguration"><i>github.com/cloudnative-pg/barman-cloud/pkg/api.BarmanObjectStoreConfiguration</i></a>
</td>
<td>
<p>The configuration for the barman-cloud tool suite</p>
</td>
</tr>
<tr><td><code>plugin</code> <B>[Required]</B><br/>
<a href="#postgresql-cnpg-io-v1-PluginConfiguration"><i>PluginConfiguration</i></a>
</td>
<td>
<p>The configuration of the plugin that is taking care
of WAL archiving and backups for this external cluster</p>
</td>
</tr>
</tbody>
</table>

## ImageCatalogRef {#postgresql-cnpg-io-v1-ImageCatalogRef}

Expand Down Expand Up @@ -3616,6 +3686,7 @@ the operator calls PgBouncer's <code>PAUSE</code> and <code>RESUME</code> comman

**Appears in:**

- [ExternalCluster](#postgresql-cnpg-io-v1-ExternalCluster)


<p>PluginConfiguration specifies a plugin that need to be loaded for this
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/manager/walrestore/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ func restoreWALViaPlugins(
availablePluginNamesSet := stringset.From(availablePluginNames)

enabledPluginNames := cluster.Spec.Plugins.GetEnabledPluginNames()
enabledPluginNames = append(enabledPluginNames, cluster.Spec.ExternalClusters.GetEnabledPluginNames()...)
enabledPluginNames = append(
enabledPluginNames,
apiv1.GetExternalClustersEnabledPluginNames(cluster.Spec.ExternalClusters)...,
)
enabledPluginNamesSet := stringset.From(enabledPluginNames)

client, err := pluginClient.WithPlugins(
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

// Load the plugins required to bootstrap and reconcile this cluster
enabledPluginNames := cluster.Spec.Plugins.GetEnabledPluginNames()
enabledPluginNames = append(enabledPluginNames, cluster.Spec.ExternalClusters.GetEnabledPluginNames()...)
enabledPluginNames = append(
enabledPluginNames,
apiv1.GetExternalClustersEnabledPluginNames(cluster.Spec.ExternalClusters)...,
)

pluginLoadingContext, cancelPluginLoading := context.WithTimeout(ctx, 5*time.Second)
defer cancelPluginLoading()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ var _ = Describe("Managed subscription controller tests", func() {
TargetPrimary: "cluster-example-1",
},
Spec: apiv1.ClusterSpec{
ExternalClusters: apiv1.ExternalClusterList{
apiv1.ExternalCluster{
ExternalClusters: []apiv1.ExternalCluster{
{
Name: "cluster-other",
ConnectionParameters: map[string]string{
"host": "localhost",
Expand Down

0 comments on commit ed9105d

Please sign in to comment.