Skip to content

Commit 8eef786

Browse files
committed
feat: Make CREATE EXTENSION tests optional
1 parent 5578bb5 commit 8eef786

File tree

9 files changed

+26
-7
lines changed

9 files changed

+26
-7
lines changed

dagger/maintenance/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ func (m *Maintenance) GenerateTestingValues(
174174
targetExtensionImage)
175175
}
176176

177+
var extensions []map[string]string
178+
var expectedExtensions []map[string]any
179+
if metadata.CreateExtension {
180+
extensions = []map[string]string{
181+
{"name": metadata.SQLName, "version": version},
182+
}
183+
expectedExtensions = []map[string]any{
184+
{"applied": true, "name": metadata.SQLName},
185+
}
186+
}
187+
177188
// Build values.yaml content
178189
values := map[string]any{
179190
"name": metadata.Name,
@@ -186,6 +197,9 @@ func (m *Maintenance) GenerateTestingValues(
186197
"extension_image": targetExtensionImage,
187198
"pg_image": pgImage,
188199
"version": version,
200+
"create_extension": metadata.CreateExtension,
201+
"extensions": extensions,
202+
"expected_extensions": expectedExtensions,
189203
}
190204
valuesYaml, err := yaml.Marshal(values)
191205
if err != nil {

dagger/maintenance/parse.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type extensionMetadata struct {
2828
DynamicLibraryPath []string `hcl:"dynamic_library_path" cty:"dynamic_library_path"`
2929
LdLibraryPath []string `hcl:"ld_library_path" cty:"ld_library_path"`
3030
AutoUpdateOsLibs bool `hcl:"auto_update_os_libs" cty:"auto_update_os_libs"`
31+
CreateExtension bool `hcl:"create_extension" cty:"create_extension"`
3132
Versions versionMap `hcl:"versions" cty:"versions"`
3233
Remain hcl.Body `hcl:",remain"`
3334
}

pgaudit/metadata.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata = {
77
dynamic_library_path = []
88
ld_library_path = []
99
auto_update_os_libs = false
10+
create_extension = true
1011

1112
versions = {
1213
bookworm = {

pgvector/metadata.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata = {
77
dynamic_library_path = []
88
ld_library_path = []
99
auto_update_os_libs = false
10+
create_extension = true
1011

1112
versions = {
1213
bookworm = {

postgis/metadata.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ metadata = {
77
dynamic_library_path = []
88
ld_library_path = ["/system"]
99
auto_update_os_libs = true
10+
create_extension = true
1011

1112
versions = {
1213
bookworm = {

templates/metadata.hcl.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ metadata = {
99
dynamic_library_path = []
1010
ld_library_path = []
1111
auto_update_os_libs = false
12+
create_extension = true
1213

1314
versions = {
1415
{{- range $distro := .Distros}}

test/check-extension.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ spec:
1313
value: ($values.sql_name)
1414
- name: EXT_VERSION
1515
value: ($values.version)
16+
- name: CREATE_EXTENSION
17+
value: (to_string($values.create_extension))
1618
- name: DB_URI
1719
valueFrom:
1820
secretKeyRef:
@@ -23,6 +25,10 @@ spec:
2325
args:
2426
- |
2527
set -e
28+
if [ "$CREATE_EXTENSION" != "true" ]; then
29+
echo "Skipping extension check (create_extension=false)"
30+
exit 0
31+
fi
2632
DB_URI=$(echo $DB_URI | sed "s|/\*|/|")
2733
test "$(psql "$DB_URI" -tAc "SELECT EXISTS (SELECT FROM pg_catalog.pg_extension WHERE extname = '${EXT_SQL_NAME}' AND extversion = '${EXT_VERSION}')" -q)" = "t"
2834
echo "Extension '${EXT_SQL_NAME} v${EXT_VERSION}' is installed!"

test/database-assert.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ metadata:
44
name: (join('-', [$values.name, 'app']))
55
status:
66
applied: true
7-
extensions:
8-
- applied: true
9-
name: ($values.sql_name)
10-
observedGeneration: 1

test/database.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ spec:
77
owner: app
88
cluster:
99
name: ($values.name)
10-
extensions:
11-
- name: ($values.sql_name)
12-
version: ($values.version)
10+
extensions: ($values.extensions)

0 commit comments

Comments
 (0)