MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / instanceYAML

Function instanceYAML

internal/patroni/config.go:444–587  ·  view source on GitHub ↗

instanceYAML returns Patroni settings that apply to instance.

(
	cluster *v1beta1.PostgresCluster, instance *v1beta1.PostgresInstanceSetSpec,
	pgbackrestReplicaCreateCommand []string,
)

Source from the content-addressed store, hash-verified

442
443// instanceYAML returns Patroni settings that apply to instance.
444func instanceYAML(
445 cluster *v1beta1.PostgresCluster, instance *v1beta1.PostgresInstanceSetSpec,
446 pgbackrestReplicaCreateCommand []string,
447) (string, error) {
448 root := map[string]any{
449 // Missing here is "name" which cannot be known until the instance Pod is
450 // created. That value should be injected using the downward API and the
451 // PATRONI_NAME environment variable.
452
453 "kubernetes": map[string]any{
454 // Missing here is "pod_ip" which cannot be known until the instance Pod is
455 // created. That value should be injected using the downward API and the
456 // PATRONI_KUBERNETES_POD_IP environment variable.
457
458 // Missing here is "ports" which is connascent with "postgresql.connect_address".
459 // See the PATRONI_KUBERNETES_PORTS env variable.
460 },
461
462 "restapi": map[string]any{
463 // Missing here is "connect_address" which cannot be known until the
464 // instance Pod is created. That value should be injected using the downward
465 // API and the PATRONI_RESTAPI_CONNECT_ADDRESS environment variable.
466
467 // Missing here is "listen" which is connascent with "connect_address".
468 // See the PATRONI_RESTAPI_LISTEN environment variable.
469 },
470
471 "tags": map[string]any{
472 // TODO(cbandy): "nofailover"
473 // TODO(cbandy): "nosync"
474 },
475 }
476
477 //nolint:gosec // G101: "pgpass" is a Patroni configuration key for a file path, not a credential.
478 postgresql := map[string]any{
479 // Missing here is "connect_address" which cannot be known until the
480 // instance Pod is created. That value should be injected using the downward
481 // API and the PATRONI_POSTGRESQL_CONNECT_ADDRESS environment variable.
482
483 // Missing here is "listen" which is connascent with "connect_address".
484 // See the PATRONI_POSTGRESQL_LISTEN environment variable.
485
486 // During startup, Patroni checks that this path is writable whether we use passwords or not.
487 // - https://github.com/zalando/patroni/issues/1888
488 "pgpass": "/tmp/.pgpass",
489
490 // Prefer to use UNIX domain sockets for local connections. If the PostgreSQL
491 // parameter "unix_socket_directories" is set, Patroni will connect using one
492 // of those directories. Otherwise, it will use the client (libpq) default.
493 "use_unix_socket": true,
494 }
495 root["postgresql"] = postgresql
496
497 // The "basebackup" replica method is configured differently from others.
498 // Patroni prepends "--" before it calls `pg_basebackup`.
499 // - https://github.com/zalando/patroni/blob/v2.0.2/patroni/postgresql/bootstrap.py#L45
500 postgresql["basebackup"] = []string{
501 // NOTE(cbandy): The "--waldir" option was introduced in PostgreSQL v10.

Callers 4

TestInstanceYAMLFunction · 0.85
InstanceConfigMapFunction · 0.85
TestInstanceConfigMapFunction · 0.85

Calls 4

WALDirectoryFunction · 0.92
QuoteWordsFunction · 0.92
DataDirectoryFunction · 0.92
ClusterBootstrappedFunction · 0.85

Tested by 3

TestInstanceYAMLFunction · 0.68
TestInstanceConfigMapFunction · 0.68