Skip to content

Commit d206193

Browse files
committed
chore: validate annotations
Signed-off-by: Niccolò Fei <[email protected]>
1 parent 3934c16 commit d206193

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

dagger/maintenance/main.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66
import (
77
"context"
88
"encoding/json"
9+
"fmt"
910
"maps"
1011
"path"
1112
"slices"
@@ -122,6 +123,20 @@ func (m *Maintenance) GenerateTestingValues(
122123
return nil, err
123124
}
124125

126+
pgImage, found := annotations["io.cloudnativepg.image.base.name"]
127+
if !found || pgImage == "" {
128+
return nil, fmt.Errorf(
129+
"extension image %s doesn't have an 'io.cloudnativepg.image.base.name' annotation",
130+
targetExtensionImage)
131+
}
132+
133+
version, found := annotations["org.opencontainers.image.version"]
134+
if !found || version == "" {
135+
return nil, fmt.Errorf(
136+
"extension image %s doesn't have an 'org.opencontainers.image.version' annotation",
137+
targetExtensionImage)
138+
}
139+
125140
// Build values.yaml content
126141
values := map[string]any{
127142
"name": metadata.Name,
@@ -132,8 +147,8 @@ func (m *Maintenance) GenerateTestingValues(
132147
"dynamic_library_path": metadata.DynamicLibraryPath,
133148
"ld_library_path": metadata.LdLibraryPath,
134149
"extension_image": targetExtensionImage,
135-
"pg_image": annotations["io.cloudnativepg.image.base.name"],
136-
"version": annotations["org.opencontainers.image.version"],
150+
"pg_image": pgImage,
151+
"version": version,
137152
}
138153
valuesYaml, err := yaml.Marshal(values)
139154
if err != nil {

0 commit comments

Comments
 (0)