@@ -13,8 +13,6 @@ import (
1313 "os/exec"
1414 "path/filepath"
1515 "runtime"
16- "strconv"
17- "strings"
1816 "testing"
1917
2018 "github.com/stretchr/testify/require"
@@ -77,7 +75,15 @@ func TestCreateGoWithDockerSupport(t *testing.T) {
7775 require .NoError (t , err , "Makefile build_image target should be valid" )
7876
7977 manifest := & extensions.Manifest {Name : "test-docker" , Version : version , Type : extensions .TypeGo , CShared : true }
80- pushOCIImageForDownload (t , extensionDir , "./Dockerfile" , manifest )
78+ // Build and push the single-platform image via the Makefile's push_image target, which
79+ // emits the manifest-level OCI annotations required by boe download.
80+ // #nosec G204
81+ pushCmd := exec .CommandContext (ctx , "make" , "push_image" , "PLATFORMS=linux/" + runtime .GOARCH )
82+ pushCmd .Dir = extensionDir
83+ pushOutput , err := pushCmd .CombinedOutput ()
84+ t .Logf ("make push_image output: %s" , string (pushOutput ))
85+ require .NoError (t , err , "Makefile push_image target should be valid" )
86+
8187 requireDownloadHasFiles (t , manifest , "manifest.yaml" , "config.schema.json" )
8288 })
8389 })
@@ -117,7 +123,15 @@ func TestCreateGoWithDockerSupport(t *testing.T) {
117123 require .NoError (t , err , "Makefile build_image_plugin target should be valid" )
118124
119125 manifest := & extensions.Manifest {Name : "test-docker" , Version : version , Type : extensions .TypeGo , CShared : false }
120- pushOCIImageForDownload (t , extensionDir , "./Dockerfile.plugin" , manifest )
126+ // Build and push the single-platform plugin image via the Makefile's push_image_plugin
127+ // target, which emits the manifest-level OCI annotations required by boe download.
128+ // #nosec G204
129+ pushCmd := exec .CommandContext (ctx , "make" , "push_image_plugin" , "PLATFORMS=linux/" + runtime .GOARCH )
130+ pushCmd .Dir = extensionDir
131+ pushOutput , err := pushCmd .CombinedOutput ()
132+ t .Logf ("make push_image_plugin output: %s" , string (pushOutput ))
133+ require .NoError (t , err , "Makefile push_image_plugin target should be valid" )
134+
121135 requireDownloadHasFiles (t , manifest , "manifest.yaml" , "config.schema.json" )
122136 })
123137 })
@@ -178,63 +192,20 @@ func TestCreateRustNetworkAndListenerFilters(t *testing.T) {
178192 t .Logf ("make build_image output: %s" , string (output ))
179193 require .NoError (t , err , "Makefile build_image target should be valid" )
180194
181- // Push local image to registry and check its annotations
182- pushOCIImageForDownload (t , extensionDir , "./Dockerfile" , manifest )
195+ // Build and push the single-platform image to the registry via the Makefile's push_image
196+ // target, then check its annotations are usable by boe download.
197+ // #nosec G204
198+ pushCmd := exec .CommandContext (ctx , "make" , "push_image" , "PLATFORMS=linux/" + runtime .GOARCH )
199+ pushCmd .Dir = extensionDir
200+ pushOutput , err := pushCmd .CombinedOutput ()
201+ t .Logf ("make push_image output: %s" , string (pushOutput ))
202+ require .NoError (t , err , "Makefile push_image target should be valid" )
203+
183204 requireDownloadHasFiles (t , manifest , "manifest.yaml" )
184205 })
185206 }
186207}
187208
188- // pushOCIImageForDownload pushes the extension image to the test registry in OCI format,
189- // preserving the manifest annotations required by boe download.
190- // It does not use the `make push_image` target because it is meant for multi-platform builds
191- // and here we want to build for a single platform. We call directly buildx build with the
192- // minimum set of annotations and config.
193- func pushOCIImageForDownload (t * testing.T , extensionDir , dockerfile string , manifest * extensions.Manifest ) {
194- t .Helper ()
195- ctx := t .Context ()
196-
197- // Ensure boe-builder exists; the Makefile's create_builder target is idempotent.
198- // #nosec G204
199- createBuilderCmd := exec .CommandContext (ctx , "make" , "create_builder" )
200- createBuilderCmd .Dir = extensionDir
201- out , err := createBuilderCmd .CombinedOutput ()
202- t .Logf ("make create_builder output: %s" , string (out ))
203- require .NoError (t , err , "Should be able to ensure boe-builder exists" )
204-
205- args := []string {
206- "buildx" , "build" ,
207- "--builder" , "boe-builder" ,
208- "--platform" , fmt .Sprintf ("linux/%s" , runtime .GOARCH ),
209- "--output" , "type=registry,oci-mediatypes=true,registry.insecure=true" ,
210- "--provenance=false" ,
211- "--tag" , fmt .Sprintf ("%s/extension-%s:%s" , registryAddr , manifest .Name , manifest .Version ),
212- "-f" , dockerfile ,
213- "--annotation" , fmt .Sprintf ("manifest:org.opencontainers.image.title=%s" , manifest .Name ),
214- "--annotation" , fmt .Sprintf ("manifest:org.opencontainers.image.version=%s" , manifest .Version ),
215- "--annotation" , fmt .Sprintf ("manifest:%s=%s" , extensions .OCIAnnotationExtensionType , string (manifest .Type )),
216- "--annotation" , fmt .Sprintf ("manifest:%s=%s" , extensions .OCIAnnotationCShared , strconv .FormatBool (manifest .CShared )),
217- }
218- if manifest .Type == extensions .TypeGo {
219- args = append (args , "--build-arg" , fmt .Sprintf ("NAME=%s" , manifest .Name ))
220- }
221- if len (manifest .FilterTypes ) > 0 {
222- filterTypes := make ([]string , len (manifest .FilterTypes ))
223- for i , ft := range manifest .FilterTypes {
224- filterTypes [i ] = string (ft )
225- }
226- args = append (args , "--annotation" , fmt .Sprintf ("manifest:%s=%s" , extensions .OCIAnnotationFilterType , strings .Join (filterTypes , "," )))
227- }
228- args = append (args , "." )
229-
230- // #nosec G204
231- pushCmd := exec .CommandContext (ctx , "docker" , args ... )
232- pushCmd .Dir = extensionDir
233- output , err := pushCmd .CombinedOutput ()
234- t .Logf ("pushOCIImageForDownload output: %s" , string (output ))
235- require .NoError (t , err , "Should be able to push OCI image to local registry" )
236- }
237-
238209func fetchManifest (t * testing.T , registry , repository , reference string ) {
239210 url := fmt .Sprintf ("http://%s/v2/%s/manifests/%s" , registry , repository , reference )
240211 // Set Accept header to request OCI media types to ensure the manifest is in OCI format
0 commit comments