Skip to content

Commit be6fe69

Browse files
feat: allow per-extension license metadata (#111)
Introduce a `licenses` field in the metadata schema as a list of SPDX identifiers, allowing each extension to declare its own licensing. These are joined with " AND " at build time to populate the OCI `org.opencontainers.image.licenses` label and annotation, replacing the previously hardcoded "Apache-2.0". The existing extensions have been updated: pgaudit and pgvector use the PostgreSQL license, while PostGIS includes the full set of licenses from its dependency tree, as reported by trivy. Closes #110 Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 2716417 commit be6fe69

6 files changed

Lines changed: 23 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ annotations as defined by the [OCI Image Format Specification](https://github.co
147147
| `org.opencontainers.image.title` | Human-readable image title |
148148
| `org.opencontainers.image.description` | Image description |
149149
| `org.opencontainers.image.source` | Source repository URL |
150-
| `org.opencontainers.image.licenses` | License identifier (Apache-2.0) |
150+
| `org.opencontainers.image.licenses` | License identifier |
151151

152152
You can inspect these labels using container tools:
153153

docker-bake.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ target "default" {
7474
"index,manifest:org.opencontainers.image.description=A ${metadata.name} ${getExtensionVersion(distro, pgVersion)} container image for PostgreSQL ${pgVersion} on ${distro}",
7575
"index,manifest:org.opencontainers.image.documentation=${url}",
7676
"index,manifest:org.opencontainers.image.authors=${authors}",
77-
"index,manifest:org.opencontainers.image.licenses=Apache-2.0",
77+
"index,manifest:org.opencontainers.image.licenses=${join(" AND ", metadata.licenses)}",
7878
"index,manifest:org.opencontainers.image.base.name=scratch",
7979
"index,manifest:io.cloudnativepg.image.base.name=${getBaseImage(distro, pgVersion)}",
8080
"index,manifest:io.cloudnativepg.image.base.pgmajor=${pgVersion}",
@@ -91,7 +91,7 @@ target "default" {
9191
"org.opencontainers.image.description" = "A ${metadata.name} ${getExtensionVersion(distro, pgVersion)} container image for PostgreSQL ${pgVersion} on ${distro}",
9292
"org.opencontainers.image.documentation" = "${url}",
9393
"org.opencontainers.image.authors" = "${authors}",
94-
"org.opencontainers.image.licenses" = "Apache-2.0",
94+
"org.opencontainers.image.licenses" = "${join(" AND ", metadata.licenses)}",
9595
"org.opencontainers.image.base.name" = "scratch",
9696
"io.cloudnativepg.image.base.name" = "${getBaseImage(distro, pgVersion)}",
9797
"io.cloudnativepg.image.base.pgmajor" = "${pgVersion}",

pgaudit/metadata.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ metadata = {
22
name = "pgaudit"
33
sql_name = "pgaudit"
44
image_name = "pgaudit"
5+
licenses = ["PostgreSQL"]
56
shared_preload_libraries = ["pgaudit"]
67
extension_control_path = []
78
dynamic_library_path = []

pgvector/metadata.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ metadata = {
22
name = "pgvector"
33
sql_name = "vector"
44
image_name = "pgvector"
5+
licenses = ["PostgreSQL"]
56
shared_preload_libraries = []
67
extension_control_path = []
78
dynamic_library_path = []

postgis/metadata.hcl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ metadata = {
22
name = "postgis"
33
sql_name = "postgis"
44
image_name = "postgis-extension"
5+
licenses = [ "Apache-2.0", "blessing", "BSD-2-Clause", "BSD-3-Clause",
6+
"BSD-3-Clause-Clear", "BSD-3-Clause-LBNL", "BSD-4-Clause-UC",
7+
"BSL-1.0", "CC-BY-3.0", "CC-BY-4.0", "CC-BY-SA-3.0", "curl",
8+
"FTL", "GPL-2.0-or-later", "GPL-3.0-or-later", "HDF5", "HPND-sell-variant",
9+
"IJG", "Info-ZIP", "ISC", "LGPL-2.1-or-later", "Libpng", "libtiff",
10+
"MIT", "MIT-Modern-Variant", "MPL-1.1", "OLDAP-2.8",
11+
"PostgreSQL", "Spencer-86", "SPL-1.0", "Unicode-DFS-2015",
12+
"Unlicense", "X11", "Zlib" ]
513
shared_preload_libraries = []
614
extension_control_path = []
715
dynamic_library_path = []

templates/metadata.hcl.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ metadata = {
99
# it identifies the image (e.g. ghcr.io/cloudnative-pg/<image_name>)
1010
image_name = "{{ .Name }}"
1111

12+
# TODO: Remove this comment block after customizing the file.
13+
# `licenses`: A list of SPDX identifiers representing the software's licenses.
14+
# Formatting Rules:
15+
# - Must be a list of strings: ["MIT", "Apache-2.0"]
16+
# - Use SPDX IDs exactly as they appear at https://spdx.org/licenses/
17+
# - These are automatically joined with " AND " to populate the OCI label
18+
# org.opencontainers.image.licenses
19+
# Examples: "Apache-2.0", "PostgreSQL", "MIT".
20+
licenses = ["Apache-2.0"]
21+
1222
# TODO: Remove this comment block after customizing the file.
1323
# `shared_preload_libraries`: list libraries to be added to
1424
# `shared_preload_libraries` in Postgres. Usually empty.

0 commit comments

Comments
 (0)