Skip to content

Commit 98bc2f1

Browse files
committed
Merge branch 'main' into move-jspecify-annotations-closest-to-the-target
# Conflicts: # docs/cluster-connection.md # docs/database.md # docs/default-privilege.md # docs/grant.md # docs/role.md # docs/schema.md # operator/src/main/java/it/aboutbits/postgresql/core/ResourceRef.java # operator/src/main/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionSpec.java # operator/src/main/java/it/aboutbits/postgresql/crd/role/RoleSpec.java # operator/src/test/java/it/aboutbits/postgresql/_support/testdata/persisted/creator/ClusterConnectionCreate.java # operator/src/test/java/it/aboutbits/postgresql/_support/testdata/persisted/creator/RoleCreate.java # operator/src/test/java/it/aboutbits/postgresql/_support/testdata/persisted/creator/SecretRefCreate.java
2 parents a9deaa1 + 35ddaeb commit 98bc2f1

8 files changed

Lines changed: 56 additions & 47 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
AboutBits PostgreSQL Operator is a Kubernetes operator that helps you manage PostgreSQL databases, schemas, roles (users), and privileges in a declarative way using Custom Resource Definitions (CRDs).
44

5+
## Compatibility
6+
7+
| Component | Supported Versions |
8+
|----------------|--------------------|
9+
| **PostgreSQL** | 15, 16, 17, 18 |
10+
| **Kubernetes** | 1.29+ |
11+
12+
> **Note:** Kubernetes 1.29+ is required due to the use of CRD CEL validations (GA in 1.29, Beta in 1.25).
13+
514
## Architecture
615

716
```

docs/cluster-connection.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Other Custom Resources (like `Database`, `Role`, `Schema`, `Grant`, `DefaultPriv
77

88
## Spec
99

10-
| Field | Type | Description | Required |
11-
|------------------|---------------------|-----------------------------------------------------------------------|----------|
12-
| `host` | `string` | The hostname of the PostgreSQL instance. | Yes |
13-
| `port` | `integer` | The port of the PostgreSQL instance (1-65535). | Yes |
14-
| `database` | `string` | The database to connect to (usually `postgres` for admin operations). | Yes |
15-
| `adminSecretRef` | `ResourceRef` | Reference to the Kubernetes Secret containing the admin credentials. | Yes |
16-
| `parameters` | `map[string]string` | Additional connection parameters. | No |
10+
| Field | Type | Description | Required | Mutable |
11+
|------------------|---------------------|-----------------------------------------------------------------------|----------|---------|
12+
| `host` | `string` | The hostname of the PostgreSQL instance. | Yes | Yes |
13+
| `port` | `integer` | The port of the PostgreSQL instance (1-65535). | Yes | Yes |
14+
| `database` | `string` | The database to connect to (usually `postgres` for admin operations). | Yes | Yes |
15+
| `adminSecretRef` | `ResourceRef` | Reference to the Kubernetes Secret containing the admin credentials. | Yes | Yes |
16+
| `parameters` | `map[string]string` | Additional connection parameters. | No | Yes |
1717

1818
### ResourceRef (`adminSecretRef`)
1919

docs/database.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ The `Database` Custom Resource Definition (CRD) is responsible for managing Post
44

55
## Spec
66

7-
| Field | Type | Description | Required | Immutable |
8-
|-----------------|---------------|------------------------------------------------------------------------------------------------------|----------|-----------|
9-
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | No |
10-
| `name` | `string` | The name of the database to create. | Yes | Yes |
11-
| `owner` | `string` | The owner of the database. | No | No |
12-
| `reclaimPolicy` | `string` | The policy for reclaiming the database when the CR is deleted. Values: `Retain` (Default), `Delete`. | No | No |
7+
| Field | Type | Description | Required | Mutable |
8+
|-----------------|---------------|------------------------------------------------------------------------------------------------------|----------|---------|
9+
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | Yes |
10+
| `name` | `string` | The name of the database to create. | Yes | No |
11+
| `owner` | `string` | The owner of the database. | No | Yes |
12+
| `reclaimPolicy` | `string` | The policy for reclaiming the database when the CR is deleted. Values: `Retain` (Default), `Delete`. | No | Yes |
1313

1414
### ResourceRef (`clusterRef`)
1515

docs/default-privilege.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ The `DefaultPrivilege` Custom Resource Definition (CRD) manages default privileg
44

55
## Spec
66

7-
| Field | Type | Description | Required | Immutable |
8-
|--------------|-----------------|---------------------------------------------------------------------------------------------------------|-------------|-----------|
9-
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | No |
10-
| `database` | `string` | The database where default privileges apply. | Yes | Yes |
11-
| `role` | `string` | The role to which default privileges are granted. | Yes | Yes |
12-
| `owner` | `string` | The role that owns the objects (the creator). Default privileges apply to objects created by this role. | Yes | Yes |
13-
| `schema` | `string` | The schema where default privileges apply. Required, unless `objectType` is `schema`. | Conditional | Yes |
14-
| `objectType` | `string` | The type of object. | Yes | Yes |
15-
| `privileges` | `array[string]` | List of privileges to grant. | Yes | No |
7+
| Field | Type | Description | Required | Mutable |
8+
|--------------|-----------------|---------------------------------------------------------------------------------------------------------|-------------|---------|
9+
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | Yes |
10+
| `database` | `string` | The database where default privileges apply. | Yes | No |
11+
| `role` | `string` | The role to which default privileges are granted. | Yes | No |
12+
| `owner` | `string` | The role that owns the objects (the creator). Default privileges apply to objects created by this role. | Yes | No |
13+
| `schema` | `string` | The schema where default privileges apply. Required, unless `objectType` is `schema`. | Conditional | No |
14+
| `objectType` | `string` | The type of object. | Yes | No |
15+
| `privileges` | `array[string]` | List of privileges to grant. | Yes | Yes |
1616

1717
### Object Types
1818

docs/grant.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ The `Grant` Custom Resource Definition (CRD) is responsible for managing privile
44

55
## Spec
66

7-
| Field | Type | Description | Required | Immutable |
8-
|--------------|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------|-------------|-----------|
9-
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | No |
10-
| `database` | `string` | The database containing the objects. | Yes | Yes |
11-
| `role` | `string` | The role to which privileges are granted. | Yes | Yes |
12-
| `schema` | `string` | The schema containing the objects. Required, unless `objectType` is `database`. | Conditional | Yes |
13-
| `objectType` | `string` | The type of object. | Yes | Yes |
14-
| `objects` | `array[string]` | List of object names. If empty, all objects of this `objectType` will be granted. Required, unless `objectType` is `database` or `schema`. | Conditional | No |
15-
| `privileges` | `array[string]` | List of privileges to grant. | Yes | No |
7+
| Field | Type | Description | Required | Mutable |
8+
|--------------|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------|-------------|---------|
9+
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | Yes |
10+
| `database` | `string` | The database containing the objects. | Yes | No |
11+
| `role` | `string` | The role to which privileges are granted. | Yes | No |
12+
| `schema` | `string` | The schema containing the objects. Required, unless `objectType` is `database`. | Conditional | No |
13+
| `objectType` | `string` | The type of object. | Yes | No |
14+
| `objects` | `array[string]` | List of object names. If empty, all objects of this `objectType` will be granted. Required, unless `objectType` is `database` or `schema`. | Conditional | Yes |
15+
| `privileges` | `array[string]` | List of privileges to grant. | Yes | Yes |
1616

1717
### Object Types
1818

docs/role.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ The `Role` Custom Resource Definition (CRD) manages PostgreSQL roles (users).
44

55
## Spec
66

7-
| Field | Type | Description | Required | Immutable |
8-
|---------------------|---------------|-------------------------------------------------------------------------------------|----------|-----------|
9-
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | No |
10-
| `name` | `string` | The name of the role to create in the database. | Yes | Yes |
11-
| `comment` | `string` | A comment to add to the role. | No | No |
12-
| `passwordSecretRef` | `ResourceRef` | Reference to a secret containing the password for the role to make it a LOGIN role. | No | No |
13-
| `flags` | `RoleFlags` | Flags and attributes for the role. | No | No |
7+
| Field | Type | Description | Required | Mutable |
8+
|---------------------|---------------|-------------------------------------------------------------------------------------|----------|---------|
9+
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | Yes |
10+
| `name` | `string` | The name of the role to create in the database. | Yes | No |
11+
| `comment` | `string` | A comment to add to the role. | No | Yes |
12+
| `passwordSecretRef` | `ResourceRef` | Reference to a secret containing the password for the role to make it a LOGIN role. | No | Yes |
13+
| `flags` | `RoleFlags` | Flags and attributes for the role. | No | Yes |
1414

1515
### ResourceRef (`clusterRef` and `passwordSecretRef`)
1616

docs/schema.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ The `Schema` Custom Resource Definition (CRD) is responsible for managing Postgr
44

55
## Spec
66

7-
| Field | Type | Description | Required | Immutable |
8-
|-----------------|---------------|----------------------------------------------------------------------------------------------------|----------|-----------|
9-
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | No |
10-
| `database` | `string` | The name of the database in which the schema is created. | Yes | Yes |
11-
| `name` | `string` | The name of the schema to create. | Yes | Yes |
12-
| `owner` | `string` | The owner of the schema. | No | No |
13-
| `reclaimPolicy` | `string` | The policy for reclaiming the schema when the CR is deleted. Values: `Retain` (Default), `Delete`. | No | No |
7+
| Field | Type | Description | Required | Mutable |
8+
|-----------------|---------------|----------------------------------------------------------------------------------------------------|----------|---------|
9+
| `clusterRef` | `ResourceRef` | Reference to the `ClusterConnection` to use. | Yes | Yes |
10+
| `database` | `string` | The name of the database in which the schema is created. | Yes | No |
11+
| `name` | `string` | The name of the schema to create. | Yes | No |
12+
| `owner` | `string` | The owner of the schema. | No | Yes |
13+
| `reclaimPolicy` | `string` | The policy for reclaiming the schema when the CR is deleted. Values: `Retain` (Default), `Delete`. | No | Yes |
1414

1515
### ResourceRef (`clusterRef`)
1616

operator/src/main/java/it/aboutbits/postgresql/crd/grant/GrantService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public Map<String, Set<Privilege>> determineCurrentObjectPrivileges(
312312
OID_DATA_TYPE,
313313
val(schema)
314314
)),
315-
objects.isEmpty() ? noCondition() : PG_CLASS.RELNAME.in(objects),
315+
isAllMode ? noCondition() : PG_CLASS.RELNAME.in(objects),
316316
// See https://www.postgresql.org/docs/current/catalog-pg-class.html#CATALOG-PG-CLASS
317317
PG_CLASS.RELKIND.in(
318318
"r", // Ordinary Table
@@ -324,7 +324,7 @@ public Map<String, Set<Privilege>> determineCurrentObjectPrivileges(
324324
)
325325
.fetchMap(PG_CLASS.RELNAME, isOwnerCondition);
326326

327-
if (objects.isEmpty()) {
327+
if (isAllMode) {
328328
objectExistenceAndOwnershipMap.putAll(existingObjectsOwner);
329329
} else {
330330
for (var object : objects) {

0 commit comments

Comments
 (0)