generated from cloudnative-pg/cnpg-template
-
Notifications
You must be signed in to change notification settings - Fork 13
feat: new extension scaffolding #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GabriFedi97
wants to merge
5
commits into
cloudnative-pg:main
Choose a base branch
from
GabriFedi97:dev/17
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9d3f652
feat: new extension scaffolding dagger command
GabriFedi97 34c4a09
feat: add task entry
GabriFedi97 9b0bfa8
feat: add task entry
GabriFedi97 b58773f
docs: create new extension
GabriFedi97 3349043
chore: check if extension already exists
GabriFedi97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| {{ $packageName := replaceAll .Package "%version%" "${PG_MAJOR}" }} | ||
| ARG BASE=ghcr.io/cloudnative-pg/postgresql:{{ .DefaultVersion }}-minimal-{{ .DefaultDistro }} | ||
| FROM $BASE AS builder | ||
|
|
||
| ARG PG_MAJOR | ||
| ARG EXT_VERSION | ||
|
|
||
| USER 0 | ||
|
|
||
| # Install extension | ||
|
|
||
| # RUN apt-get update && \ | ||
| # apt-get install -y --no-install-recommends "{{ $packageName }}=${EXT_VERSION}" | ||
|
|
||
| FROM scratch | ||
| ARG PG_MAJOR | ||
|
|
||
| # Licenses | ||
| # Including license files is essential for legal compliance and transparency. | ||
| # It ensures proper attribution to original authors, fulfills open source license | ||
| # requirements, and enables automated compliance scanning tools to verify licensing. | ||
|
|
||
| # COPY --from=builder /usr/share/doc/{{ $packageName }}/copyright /licenses/{{ $packageName }}/ | ||
|
|
||
| # Libraries | ||
| # Include the extension's shared objects and related dependencies under the /lib directory. | ||
| # CNPG will load these libraries at runtime by configuring the dynamic linker path (LD_LIBRARY_PATH) and | ||
| # the PostgreSQL GUC "dynamic_library_path" based on defaults and Cluster configuration. | ||
| # For more details, see: https://cloudnative-pg.io/docs/1.28/imagevolume_extensions#how-it-works | ||
|
|
||
| # COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/{{ .Name }}* /lib/ | ||
| # COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/ /lib/bitcode/ | ||
|
|
||
| # Share | ||
| # Include the extension's SQL scripts and control files under the /share/extension directory. | ||
| # CNPG will configure PostgreSQL to include this path via the "extension_control_path" GUC to | ||
| # seamlessly find and manage the current extension. | ||
| # For more details, see: https://cloudnative-pg.io/docs/1.28/imagevolume_extensions#how-it-works | ||
|
|
||
| # COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/{{ .Name }}* /share/extension/ | ||
|
|
||
| USER 65532:65532 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # {{ toTitle .Name }} | ||
|
|
||
| <!-- | ||
| Introduction: give a brief introduction of the extension and what it is useful for. | ||
| Add a reference to the official documentation if available. | ||
| --> | ||
|
|
||
| The {{ .Name }} PostgreSQL extension provides support for | ||
| vector data types and operations, enabling efficient storage and retrieval of | ||
| high-dimensional vectors. It is particularly useful for applications involving | ||
| machine learning, recommendation systems, and similarity search. | ||
|
|
||
| ## Usage | ||
|
|
||
| <!-- | ||
| Usage: add instructions on how to use the extension with CloudNativePG. | ||
| Include code snippets for Cluster and Database resources as needed. | ||
| --> | ||
|
|
||
| ### 1. Add the {{ .Name }} extension image to your Cluster | ||
|
|
||
| Define the `{{ .Name }}` extension under the `postgresql.extensions` section of | ||
| your `Cluster` resource. For example: | ||
|
|
||
| ```yaml | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Cluster | ||
| metadata: | ||
| name: cluster-{{ .Name }} | ||
| spec: | ||
| imageName: ghcr.io/cloudnative-pg/postgresql:{{ .DefaultVersion }}-minimal-{{ .DefaultDistro }} | ||
| instances: 1 | ||
|
|
||
| storage: | ||
| size: 1Gi | ||
|
|
||
| postgresql: | ||
| extensions: | ||
| - name: {{ .Name }} | ||
| image: | ||
| reference: ghcr.io/cloudnative-pg/{{ .Name }}:1.0-{{ .DefaultVersion }}-{{ .DefaultDistro }} | ||
| ``` | ||
|
|
||
| ### 2. Enable the extension in a database | ||
|
|
||
| You can install `{{ .Name }}` in a specific database by creating or updating a | ||
| `Database` resource. For example, to enable it in the `app` database: | ||
|
|
||
| ```yaml | ||
| apiVersion: postgresql.cnpg.io/v1 | ||
| kind: Database | ||
| metadata: | ||
| name: cluster-{{ .Name }}-app | ||
| spec: | ||
| name: app | ||
| owner: app | ||
| cluster: | ||
| name: cluster-{{ .Name }} | ||
| extensions: | ||
| - name: {{ .Name }} | ||
| version: '1.0' | ||
| ``` | ||
|
|
||
| ### 3. Verify installation | ||
|
|
||
| Once the database is ready, connect to it with `psql` and run: | ||
|
|
||
| ```sql | ||
| \dx | ||
| ``` | ||
|
|
||
| You should see `{{ .Name }}` listed among the installed extensions. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| metadata = { | ||
| name = "{{ .Name }}" | ||
| sql_name = "{{ .Name }}" | ||
| image_name = "{{ .Name }}" | ||
| shared_preload_libraries = [] | ||
| extension_control_path = [] | ||
| dynamic_library_path = [] | ||
| ld_library_path = [] | ||
| auto_update_os_libs = false | ||
|
|
||
| versions = { | ||
| {{- range $distro := .Distros}} | ||
| {{ $distro }} = { | ||
| {{- range $version := $.Versions}} | ||
| // renovate: suite={{ $distro }}-pgdg depName={{ replaceAll $.Package "%version%" $version }} | ||
| "{{ $version }}" = "<package-version-here>" | ||
| {{- end}} | ||
| } | ||
| {{- end}} | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to add a placeholder for the renovate line here?