From e70843d42dea7f8795b7a785bb0012186f6a6d96 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Fri, 19 Aug 2022 12:35:58 -0400 Subject: [PATCH] Registry index server endpoint testing added (#130) * devfile registry index server README added. * Squashed commit of the following: commit e3b636563b418e3f67f4a5ac47ab4599378a954a Author: Michael Valdron Date: Tue Aug 16 13:32:01 2022 -0400 oci server spec links added to godocs in ocitest.go Signed-off-by: Michael Valdron commit e09a61049d1635d1f1e5baee450fdd8b6695b22f Author: Michael Valdron Date: Tue Aug 16 13:13:31 2022 -0400 godocs added to endpoint_test.go and tag error detail changed to match ResponseError.Detail type signature Signed-off-by: Michael Valdron commit 737544b0f7895009303fbb25fba0b5d48f18ce4a Author: Michael Valdron Date: Tue Aug 16 12:58:37 2022 -0400 godocs added to ocitest.go and Detail field under ResponseError type signature changed Signed-off-by: Michael Valdron commit 36e9223520b6428634a6c711b27a495475e81134 Author: Michael Valdron Date: Fri Jul 29 19:01:15 2022 -0400 TestOCIServerProxy test function and test cases added. Signed-off-by: Michael Valdron commit 7163dfb69a0815a4c7d1cec576d8b755f01fb68d Author: Michael Valdron Date: Fri Jul 29 19:00:01 2022 -0400 ProxyRecorder struct with inheritance to httptest.ResponseRecorder, ProxyRecorder adds CloseNotify receiver function from http.CloseNotifier which is needed for testing the oci proxy route and missing from httptest.ResponseRecorder Signed-off-by: Michael Valdron commit 52d94f6c55c50db18c8952d39238cee17f8af519 Author: Michael Valdron Date: Thu Jul 28 17:20:55 2022 -0400 java-wildfly manifest test data and test cases under TestServeDevfileStarterProject added. Signed-off-by: Michael Valdron commit b3c489181753c6c83f04c386069a7e2601e64a58 Author: Michael Valdron Date: Thu Jul 28 16:54:41 2022 -0400 TestServeDevfileStarterProjectWithVersion test function and test cases added. Signed-off-by: Michael Valdron commit 9cf79f80bb2ec7107979b28c09ea9b5084d8fc99 Author: Michael Valdron Date: Thu Jul 28 16:43:09 2022 -0400 java-quarkus manifest test data and test case under TestServeDevfileStarterProject added. Signed-off-by: Michael Valdron commit aebbedca4c8528d900cd82f367d15290d601067c Author: Michael Valdron Date: Thu Jul 28 16:03:43 2022 -0400 TestServeDevfileStarterProject test function and test cases added. Signed-off-by: Michael Valdron commit a2f464f20761c6bfd54a4f75e8896b84517254aa Author: Michael Valdron Date: Thu Jul 28 14:56:27 2022 -0400 TestServeDevfileWithVersion test function and test cases added. Signed-off-by: Michael Valdron commit 4e4749af77df6eac545c3252efab2a69f8e6eabd Author: Michael Valdron Date: Thu Jul 28 13:43:53 2022 -0400 when fetching a blob, mock oci server handler now walks specified stack's directory rather than iterate through immediate children. Signed-off-by: Michael Valdron commit a415a06ed802e1d48202c9d81e3b1a9b5e609a5f Author: Michael Valdron Date: Wed Jul 27 17:13:27 2022 -0400 go-digest updated to direct dependency for digest handling in the mock OCI server. Signed-off-by: Michael Valdron commit 1742b0682064444be4fbfaa42c6b6b1d9beddf2e Author: Michael Valdron Date: Wed Jul 27 17:10:52 2022 -0400 go stack manifest testing data and TestServeDevfile test case added. Signed-off-by: Michael Valdron commit ab7505dbb663b586405ca060a6f5472d2317ff6c Author: Michael Valdron Date: Wed Jul 27 17:09:05 2022 -0400 first success mock testing with OCI server, TestServeDevfile testing updated including fail case. Signed-off-by: Michael Valdron commit c8196dbbf260d26cdd3592b38d767c147d45724f Author: Michael Valdron Date: Tue Jul 26 18:35:16 2022 -0400 test data for manifests added, handlers for mock OCI server progress. Signed-off-by: Michael Valdron commit 323393c7223d0472d7dc5c54db46e51357aec071 Author: Michael Valdron Date: Tue Jul 26 18:33:54 2022 -0400 Fixups: 'blob' corrected to 'blobs' in routes and the 'detail' field under ResponseError type changed from string to ResponseErrorDetails. Signed-off-by: Michael Valdron commit 6e0a4039856301e21dd7c3ce898ed7065c1a48e5 Author: Michael Valdron Date: Fri Jul 22 19:43:31 2022 -0400 added missing error logging after pullStackFromRegistry Signed-off-by: Michael Valdron commit 044de92c6401dbf0fca71a5f048728451cf4d257 Author: Michael Valdron Date: Fri Jul 22 19:14:40 2022 -0400 mock OCI server package created. Signed-off-by: Michael Valdron commit d4aed3ddd333767db9c1d4ecc6a8f2a02be87942 Author: Michael Valdron Date: Fri Jul 22 15:41:52 2022 -0400 remove unused arraylist source. Signed-off-by: Michael Valdron commit f3af8694ab978eb5b34e75478ab78d693e61bd27 Author: Michael Valdron Date: Fri Jul 22 15:36:17 2022 -0400 removed unused validateMethods function Signed-off-by: Michael Valdron commit 6868622e65704c9fada6db015beceefb31466d1e Author: Michael Valdron Date: Fri Jul 22 15:35:03 2022 -0400 writeErrors changed to use gin.H and json marshal Signed-off-by: Michael Valdron commit 5fe00bf4cb6d24464d0e27e38d98230d09500b01 Author: Michael Valdron Date: Fri Jul 22 15:31:31 2022 -0400 routing changed to use gin framework, ping test for mock OCI server. Signed-off-by: Michael Valdron commit e11d9fb3d7342f80976fc29cb2774e30543eda76 Author: Michael Valdron Date: Thu Jul 21 18:23:47 2022 -0400 mock OCI server routes corrected, e.g. '/v2/:name/manifests/:ref' corrected to '/v2/devfile-catalog/:name/manifests/:ref' Signed-off-by: Michael Valdron commit db8cb4e41aab667a2e1576358f9ad7e2d8da19cd Author: Michael Valdron Date: Thu Jul 21 18:21:34 2022 -0400 TestServeDevfile test function added with base source. Signed-off-by: Michael Valdron commit a5fc352ab7d426cdc5319d46ff838e9287ca5c42 Author: Michael Valdron Date: Tue Jul 19 18:38:12 2022 -0400 mock oci server setup code added. Signed-off-by: Michael Valdron commit 2978667042e6344ec9d7ab0e894de9506be1a879 Author: Michael Valdron Date: Tue Jul 19 18:31:55 2022 -0400 arraylist util functions and testing added. Signed-off-by: Michael Valdron commit eb51b6d457c602732d3c52e76bb700c4822d5ca8 Author: Michael Valdron Date: Wed Jul 13 23:02:48 2022 -0400 serve devfile index with type testing seperated from base serve devfile index testing. Signed-off-by: Michael Valdron commit a62e5ff0aedab6cac940cd4c63d9de90e881ea60 Author: Michael Valdron Date: Wed Jul 13 22:50:03 2022 -0400 endpoint function exporting reverted due to changing test source file package to the same as the endpoint functions. Signed-off-by: Michael Valdron commit 74366e72809805376bcd0f5294e73cea8d86a830 Author: Michael Valdron Date: Wed Jul 13 22:46:16 2022 -0400 setupVar fixture function added. testing for serve devfile index endpoints added. Signed-off-by: Michael Valdron commit a7e426cdc85857f2c9357f5ffc02f1f07f6cd5fc Author: Michael Valdron Date: Wed Jul 13 22:44:10 2022 -0400 test registry for index/server mock testing added. Signed-off-by: Michael Valdron commit 17b0c7d8a4754cd06b5073523a48e47911ee547d Author: Michael Valdron Date: Mon Jul 11 16:13:59 2022 -0400 fixed up TestServeHealthCheck Signed-off-by: Michael Valdron commit eb6d6f8805cbae5cd69eded8e369a8b7e9ea1918 Author: Michael Valdron Date: Fri May 6 17:03:38 2022 -0400 ServeDevfileIndexV1 testing added. Signed-off-by: Michael Valdron commit 38b468a27cc98f99cb8e8a722a9d67ce7a961f69 Author: Michael Valdron Date: Mon May 2 17:45:11 2022 -0400 endpoint_test.go added: - Mock testing for ServeHealthCheck created - Base source for ServeDevfileIndexV1 with TODOs created Signed-off-by: Michael Valdron commit 766511a3fa2e4b0a49bbe7e0067e2a8d365073a9 Author: Michael Valdron Date: Mon May 2 11:32:16 2022 -0400 endpoint handlers exported from package for use in mock testing Signed-off-by: Michael Valdron commit dfd1b91c4d4f21c59cbe7acaded7ce9fa0cfe091 Author: Michael Valdron Date: Fri Apr 29 16:52:31 2022 -0400 CreateIndexServer generator function added. Signed-off-by: Michael Valdron * bug which records status code 200 for HEAD request despite response returning 404 fixed. * environment variables section added to testing docs in index server README * additional oci proxy test cases for fetching blobs added. * starterProjectMediaType constant added. * revert to original router creation source for registry index server. Signed-off-by: Michael Valdron --- index/server/README.md | 26 + index/server/go.mod | 2 +- index/server/go.sum | 2 - index/server/pkg/ocitest/ocitest.go | 127 +++ index/server/pkg/server/constants.go | 25 +- index/server/pkg/server/endpoint.go | 3 +- index/server/pkg/server/endpoint_test.go | 1006 +++++++++++++++++ .../tests/registry/extraDevfileEntries.yaml | 39 + index/server/tests/registry/index_extra.json | 65 ++ index/server/tests/registry/index_main.json | 493 ++++++++ .../server/tests/registry/index_registry.json | 430 +++++++ .../code-with-quarkus/1.1.0/devfile.yaml | 71 ++ .../samples/nodejs-basic/1.0.0/devfile.yaml | 64 ++ .../samples/nodejs-basic/1.0.1/devfile.yaml | 43 + .../registry/stacks/go/1.1.0/devfile.yaml | 47 + .../registry/stacks/go/1.2.0/devfile.yaml | 47 + .../tests/registry/stacks/go/stack.yaml | 8 + .../registry/stacks/java-maven/devfile.yaml | 51 + .../stacks/java-openliberty/devfile.yaml | 92 ++ .../registry/stacks/java-quarkus/devfile.yaml | 60 + .../stacks/java-springboot/devfile.yaml | 53 + .../registry/stacks/java-vertx/devfile.yaml | 126 +++ .../java-wildfly-bootable-jar/devfile.yaml | 204 ++++ .../registry/stacks/java-wildfly/devfile.yaml | 225 ++++ .../tests/registry/stacks/nodejs/archive.tar | Bin 0 -> 848 bytes .../tests/registry/stacks/nodejs/devfile.yaml | 57 + .../stacks/python-django/devfile.yaml | 50 + .../tests/registry/stacks/python/devfile.yaml | 45 + tests/integration/pkg/tests/constants.go | 5 + .../pkg/tests/indexserver_tests.go | 10 +- 30 files changed, 3455 insertions(+), 21 deletions(-) create mode 100644 index/server/README.md create mode 100644 index/server/pkg/ocitest/ocitest.go create mode 100644 index/server/pkg/server/endpoint_test.go create mode 100644 index/server/tests/registry/extraDevfileEntries.yaml create mode 100644 index/server/tests/registry/index_extra.json create mode 100644 index/server/tests/registry/index_main.json create mode 100644 index/server/tests/registry/index_registry.json create mode 100644 index/server/tests/registry/samples/code-with-quarkus/1.1.0/devfile.yaml create mode 100644 index/server/tests/registry/samples/nodejs-basic/1.0.0/devfile.yaml create mode 100644 index/server/tests/registry/samples/nodejs-basic/1.0.1/devfile.yaml create mode 100644 index/server/tests/registry/stacks/go/1.1.0/devfile.yaml create mode 100644 index/server/tests/registry/stacks/go/1.2.0/devfile.yaml create mode 100644 index/server/tests/registry/stacks/go/stack.yaml create mode 100644 index/server/tests/registry/stacks/java-maven/devfile.yaml create mode 100644 index/server/tests/registry/stacks/java-openliberty/devfile.yaml create mode 100644 index/server/tests/registry/stacks/java-quarkus/devfile.yaml create mode 100644 index/server/tests/registry/stacks/java-springboot/devfile.yaml create mode 100644 index/server/tests/registry/stacks/java-vertx/devfile.yaml create mode 100644 index/server/tests/registry/stacks/java-wildfly-bootable-jar/devfile.yaml create mode 100644 index/server/tests/registry/stacks/java-wildfly/devfile.yaml create mode 100644 index/server/tests/registry/stacks/nodejs/archive.tar create mode 100644 index/server/tests/registry/stacks/nodejs/devfile.yaml create mode 100644 index/server/tests/registry/stacks/python-django/devfile.yaml create mode 100644 index/server/tests/registry/stacks/python/devfile.yaml create mode 100644 tests/integration/pkg/tests/constants.go diff --git a/index/server/README.md b/index/server/README.md new file mode 100644 index 00000000..50123cd4 --- /dev/null +++ b/index/server/README.md @@ -0,0 +1,26 @@ +# Devfile registry index server + +## Overview + +Provides REST API support for devfile registries and serves [devfile registry viewer](https://github.com/devfile/registry-viewer) client. + +For more information on REST API docs: [registry-REST-API.adoc](registry-REST-API.adoc) + +## Testing + +Endpoint unit testing is defined under `pkg/server/endpoint_test.go` and can be performed by running the following: + +```sh +go test pkg/server/endpoint_test.go +``` + +or by running all tests: + +```sh +go test ./... +``` + +**Environment Variables** + +- `DEVFILE_REGISTRY`: Optional environment variable for specifying testing registry path + - default: `../../tests/registry` diff --git a/index/server/go.mod b/index/server/go.mod index 8b463e5b..0096e4e3 100644 --- a/index/server/go.mod +++ b/index/server/go.mod @@ -11,6 +11,7 @@ require ( github.com/gin-gonic/gin v1.7.7 github.com/hashicorp/go-version v1.4.0 github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 + github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/image-spec v1.0.1 github.com/prometheus/client_golang v1.11.0 golang.org/x/text v0.3.6 @@ -64,7 +65,6 @@ require ( github.com/mitchellh/reflectwalk v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect - github.com/opencontainers/go-digest v1.0.0-rc1 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect diff --git a/index/server/go.sum b/index/server/go.sum index c68f78aa..0e44b1a6 100644 --- a/index/server/go.sum +++ b/index/server/go.sum @@ -140,8 +140,6 @@ github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c h1:sjghKUov/WT71dBr github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= github.com/devfile/library v1.2.1-0.20220308191614-f0f7e11b17de h1:jImHtiAxjyul1UkPmf6C3EMS5wqNz+k84LKkCXkeqws= github.com/devfile/library v1.2.1-0.20220308191614-f0f7e11b17de/go.mod h1:GSPfJaBg0+bBjBHbwBE5aerJLH6tWGQu2q2rHYd9czM= -github.com/devfile/registry-support/index/generator v0.0.0-20220316161530-f06d84c42b54 h1:k7F4Hc4svkA+qHerBTZzcU1iVrQAJHOh8KurPnL4uYk= -github.com/devfile/registry-support/index/generator v0.0.0-20220316161530-f06d84c42b54/go.mod h1:1fyDJL+fPHtcrYA6yjSVWeLmXmjCNth0d5Rq1rvtryc= github.com/devfile/registry-support/index/generator v0.0.0-20220624203950-e7282a4695b6 h1:bTbZxKSjF9xfiUuOKpoyX7P/ZcnIRy993+JBvkQ91hw= github.com/devfile/registry-support/index/generator v0.0.0-20220624203950-e7282a4695b6/go.mod h1:1fyDJL+fPHtcrYA6yjSVWeLmXmjCNth0d5Rq1rvtryc= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= diff --git a/index/server/pkg/ocitest/ocitest.go b/index/server/pkg/ocitest/ocitest.go new file mode 100644 index 00000000..81b1a40a --- /dev/null +++ b/index/server/pkg/ocitest/ocitest.go @@ -0,0 +1,127 @@ +package ocitest + +import ( + "encoding/json" + "fmt" + "log" + "net" + "net/http" + "net/http/httptest" + + "github.com/gin-gonic/gin" +) + +// ResponseError repersents an error returned in an errors response by an OCI server, +// see https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes +type ResponseError struct { + Code string `json:"code"` // Error code + Message string `json:"message"` // Error Message + Detail map[string]interface{} `json:"detail"` // Additional detail on the error (optional) +} + +// MockOCIServer is an entity for mocking an OCI server +// for testing. At the moment, this is only needed for +// the devfile registry index server endpoint testing, +// however, this entity could be used in a testing scenario +// where an OCI server is needed. +// +// More on the OCI server specification, see https://github.com/opencontainers/distribution-spec/blob/main/spec.md +type MockOCIServer struct { + httpserver *httptest.Server // Test server entity + router *gin.Engine // Router engine for route management + ServeManifest func(c *gin.Context) // Handler for serving a manifest for a blob + ServeBlob func(c *gin.Context) // Handler for serving a blob from the OCI server +} + +// servePing is a custom handler to test if +// MockOCIServer is listening for requests +func servePing(c *gin.Context) { + data, err := json.Marshal(gin.H{ + "message": "ok", + }) + if err != nil { + log.Fatal(err) + } + + c.JSON(http.StatusOK, data) +} + +// WriteErrors writes error response object for OCI server +// errors +func WriteErrors(errors []ResponseError) map[string]interface{} { + return gin.H{ + "errors": errors, + } +} + +// NewMockOCIServer creates a MockOCIServer entity +func NewMockOCIServer() *MockOCIServer { + gin.SetMode(gin.TestMode) + + mockOCIServer := &MockOCIServer{ + // Create router engine of mock OCI server + router: gin.Default(), + } + + // Create mock OCI server using the router engine + mockOCIServer.httpserver = httptest.NewUnstartedServer(mockOCIServer.router) + + return mockOCIServer +} + +// Start listening on listenAddr for requests to the MockOCIServer +func (server *MockOCIServer) Start(listenAddr string) error { + // Testing Route for checking mock OCI server + server.router.GET("/v2/ping", servePing) + + // Pull Routes, see https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull + // Fetch manifest routes + if server.ServeManifest != nil { + server.router.GET("/v2/devfile-catalog/:name/manifests/:ref", server.ServeManifest) + server.router.HEAD("/v2/devfile-catalog/:name/manifests/:ref", server.ServeManifest) + } + + // Fetch blob routes + if server.ServeBlob != nil { + server.router.GET("/v2/devfile-catalog/:name/blobs/:digest", server.ServeBlob) + server.router.HEAD("/v2/devfile-catalog/:name/blobs/:digest", server.ServeBlob) + } + + l, err := net.Listen("tcp", listenAddr) + if err != nil { + return fmt.Errorf("unexpected error while creating listener: %v", err) + } + + server.httpserver.Listener.Close() + server.httpserver.Listener = l + + server.httpserver.Start() + + return nil +} + +// Close the MockOCIServer connection +func (server *MockOCIServer) Close() { + server.httpserver.Close() +} + +// ProxyRecorder is an extension of the ResponseRecorder +// struct within httptest with an additional receiver CloseNotifier +// which is needed for testing the proxy route to the OCI server +type ProxyRecorder struct { + *httptest.ResponseRecorder + http.CloseNotifier +} + +// NewProxyRecorder creates a new ProxyRecorder entity +func NewProxyRecorder() *ProxyRecorder { + return &ProxyRecorder{ + ResponseRecorder: httptest.NewRecorder(), + } +} + +// CloseNotify creates a bool channel for notifying a +// closure of a request +func (rec *ProxyRecorder) CloseNotify() <-chan bool { + return make(<-chan bool) +} diff --git a/index/server/pkg/server/constants.go b/index/server/pkg/server/constants.go index e35878ba..0e1c1da0 100644 --- a/index/server/pkg/server/constants.go +++ b/index/server/pkg/server/constants.go @@ -8,18 +8,19 @@ import ( const ( // Constants for resource names and media types - archiveMediaType = "application/x-tar" - archiveName = "archive.tar" - devfileName = "devfile.yaml" - devfileNameHidden = ".devfile.yaml" - devfileConfigMediaType = "application/vnd.devfileio.devfile.config.v2+json" - devfileMediaType = "application/vnd.devfileio.devfile.layer.v1" - pngLogoMediaType = "image/png" - pngLogoName = "logo.png" - svgLogoMediaType = "image/svg+xml" - svgLogoName = "logo.svg" - vsxMediaType = "application/vnd.devfileio.vsx.layer.v1.tar" - vsxName = "vsx" + archiveMediaType = "application/x-tar" + archiveName = "archive.tar" + starterProjectMediaType = "application/zip" + devfileName = "devfile.yaml" + devfileNameHidden = ".devfile.yaml" + devfileConfigMediaType = "application/vnd.devfileio.devfile.config.v2+json" + devfileMediaType = "application/vnd.devfileio.devfile.layer.v1" + pngLogoMediaType = "image/png" + pngLogoName = "logo.png" + svgLogoMediaType = "image/svg+xml" + svgLogoName = "logo.svg" + vsxMediaType = "application/vnd.devfileio.vsx.layer.v1.tar" + vsxName = "vsx" scheme = "http" registryService = "localhost:5000" diff --git a/index/server/pkg/server/endpoint.go b/index/server/pkg/server/endpoint.go index 8f6f1155..20a614db 100644 --- a/index/server/pkg/server/endpoint.go +++ b/index/server/pkg/server/endpoint.go @@ -289,7 +289,7 @@ func serveDevfileStarterProjectWithVersion(c *gin.Context) { } c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s.zip\"", starterProjectName)) - c.Data(http.StatusAccepted, "application/zip", downloadBytes) + c.Data(http.StatusAccepted, starterProjectMediaType, downloadBytes) } } @@ -521,6 +521,7 @@ func fetchDevfile(c *gin.Context, name string, version string) ([]byte, indexSch if devfileIndex.Type == indexSchema.StackDevfileType { bytes, err = pullStackFromRegistry(foundVersion) if err != nil { + log.Print(err.Error()) c.JSON(http.StatusInternalServerError, gin.H{ "error": err.Error(), "status": fmt.Sprintf("Problem pulling version %s from OCI Registry", foundVersion.Version), diff --git a/index/server/pkg/server/endpoint_test.go b/index/server/pkg/server/endpoint_test.go new file mode 100644 index 00000000..c32e5d3f --- /dev/null +++ b/index/server/pkg/server/endpoint_test.go @@ -0,0 +1,1006 @@ +package server + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/fs" + "io/ioutil" + "log" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "reflect" + "strings" + "testing" + + "github.com/devfile/library/pkg/devfile/parser" + "github.com/devfile/registry-support/index/server/pkg/ocitest" + "github.com/gin-gonic/gin" + "github.com/opencontainers/go-digest" + "github.com/opencontainers/image-spec/specs-go" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" +) + +const ( + ociServerIP = "127.0.0.1:5000" // Mock OCI server listen address and port number, format: '
:' +) + +var ( + // mock manifest repository for OCI server + manifests = map[string]map[string]ocispec.Manifest{ + "java-maven": { + "1.1.0": { + Versioned: specs.Versioned{SchemaVersion: 2}, + Config: ocispec.Descriptor{ + MediaType: devfileConfigMediaType, + }, + Layers: []ocispec.Descriptor{ + { + MediaType: devfileMediaType, + Digest: "sha256:b81a4a857ebbd6b7093c38703e3b7c6d7a2652abfd55898f82fdea45634fd549", + Size: 1251, + Annotations: map[string]string{ + "org.opencontainers.image.title": devfileName, + }, + }, + }, + }, + }, + "go": { + "1.1.0": { + Versioned: specs.Versioned{SchemaVersion: 2}, + Config: ocispec.Descriptor{ + MediaType: devfileConfigMediaType, + }, + Layers: []ocispec.Descriptor{ + { + MediaType: devfileMediaType, + Digest: "sha256:4cad7c1629ba848245205a08107b296adba307f77ca3635b16920473589cb12e", + Size: 1086, + Annotations: map[string]string{ + "org.opencontainers.image.title": devfileName, + }, + }, + }, + }, + "1.2.0": { + Versioned: specs.Versioned{SchemaVersion: 2}, + Config: ocispec.Descriptor{ + MediaType: devfileConfigMediaType, + }, + Layers: []ocispec.Descriptor{ + { + MediaType: devfileMediaType, + Digest: "sha256:bb4c6b96292bbcd48f445436f7945399a4d314b111ee976d6235199e854bfb68", + Size: 1091, + Annotations: map[string]string{ + "org.opencontainers.image.title": devfileName, + }, + }, + }, + }, + }, + "java-quarkus": { + "1.1.0": { + Versioned: specs.Versioned{SchemaVersion: 2}, + Config: ocispec.Descriptor{ + MediaType: devfileConfigMediaType, + }, + Layers: []ocispec.Descriptor{ + { + MediaType: devfileMediaType, + Digest: "sha256:6143ffeab064d0b9a6991a6e1025a1b63d01be87e197fabb8a34d5a9fc3fcba0", + Size: 1935, + Annotations: map[string]string{ + "org.opencontainers.image.title": devfileName, + }, + }, + }, + }, + }, + "java-wildfly": { + "1.0.0": { + Versioned: specs.Versioned{SchemaVersion: 2}, + Config: ocispec.Descriptor{ + MediaType: devfileConfigMediaType, + }, + Layers: []ocispec.Descriptor{ + { + MediaType: devfileMediaType, + Digest: "sha256:a6363457f7603259b7c55c5d5752adcf1cfb146227e90890a3ca8aa6b71879dd", + Size: 7151, + Annotations: map[string]string{ + "org.opencontainers.image.title": devfileName, + }, + }, + }, + }, + }, + } +) + +// serveManifest custom handler for fetching a manifest from the +// mock OCI server +func serveManifest(c *gin.Context) { + name, ref := c.Param("name"), c.Param("ref") + var ( + stackManifest ocispec.Manifest + found bool + bytes []byte + err error + ) + + if strings.HasPrefix(ref, "sha256:") { + stackManifests, found := manifests[name] + if !found { + notFoundManifest(c, ref) + return + } + + found = false + for _, manifest := range stackManifests { + dgst, err := digestEntity(manifest) + if err != nil { + log.Fatal(err) + } else if reflect.DeepEqual(ref, dgst) { + stackManifest = manifest + found = true + break + } + } + + if !found { + notFoundManifest(c, ref) + return + } + } else { + stackManifest, found = manifests[name][ref] + + if !found { + notFoundManifest(c, ref) + return + } + } + + if c.Request.Method == http.MethodGet { + bytes, err = json.Marshal(stackManifest) + if err != nil { + log.Fatal(err) + } + } + + c.Data(http.StatusOK, ocispec.MediaTypeImageManifest, bytes) +} + +// notFoundManifest custom handler for manifest not found status of the mock OCI server +func notFoundManifest(c *gin.Context, tag string) { + var data gin.H = nil + + if c.Request.Method == http.MethodGet { + data = ocitest.WriteErrors([]ocitest.ResponseError{ + { + Code: "MANIFEST_UNKNOWN", + Message: "manifest unknown", + Detail: map[string]interface{}{ + "Tag": tag, + }, + }, + }) + } + + c.JSON(http.StatusNotFound, data) +} + +// digestEntity generates sha256 digest of any entity type +func digestEntity(e interface{}) (string, error) { + bytes, err := json.Marshal(e) + if err != nil { + return "", err + } + + return digest.FromBytes(bytes).String(), nil +} + +// digestFile generates sha256 digest from file contents +func digestFile(filepath string) (string, error) { + file, err := os.Open(filepath) + if err != nil { + return "", err + } + defer file.Close() + + dgst, err := digest.FromReader(file) + if err != nil { + return "", err + } + + return dgst.String(), nil +} + +// serveBlob custom handler for fetching a blob from the +// mock OCI server +func serveBlob(c *gin.Context) { + name, dgst := c.Param("name"), c.Param("digest") + stackRoot := filepath.Join(stacksPath, name) + var ( + blobPath string + found bool + err error + ) + + found = false + err = filepath.WalkDir(stackRoot, func(path string, d fs.DirEntry, err error) error { + var fdgst string + + if err != nil { + return err + } + + if found || d.IsDir() { + return nil + } + + fdgst, err = digestFile(path) + if err != nil { + return err + } else if reflect.DeepEqual(dgst, fdgst) { + blobPath = path + found = true + } + + return nil + }) + if err != nil { + log.Fatal(err) + } else if !found { + notFoundBlob(c) + return + } + + file, err := os.Open(blobPath) + if err != nil { + log.Fatal(err) + } + defer file.Close() + + bytes, err := io.ReadAll(file) + if err != nil { + log.Fatal(err) + } + + c.Data(http.StatusOK, http.DetectContentType(bytes), bytes) +} + +// notFoundBlob custom handler for blob not found status of the mock OCI server +func notFoundBlob(c *gin.Context) { + c.Data(http.StatusNotFound, "plain/text", []byte{}) +} + +// setupMockOCIServer sets up mock OCI server for endpoint testing environment +func setupMockOCIServer() (func(), error) { + mockOCIServer := ocitest.NewMockOCIServer() + + // Pull Routes + mockOCIServer.ServeManifest = serveManifest + mockOCIServer.ServeBlob = serveBlob + + if err := mockOCIServer.Start(ociServerIP); err != nil { + return nil, err + } + + return mockOCIServer.Close, nil +} + +// setupVars sets up registry index server global variables for endpoint testing environment +func setupVars() { + var registryPath string + + if _, found := os.LookupEnv("DEVFILE_REGISTRY"); found { + registryPath = os.Getenv("DEVFILE_REGISTRY") + } else { + registryPath = "../../tests/registry" + } + + if stacksPath == "" { + stacksPath = filepath.Join(registryPath, "stacks") + } + if samplesPath == "" { + samplesPath = filepath.Join(registryPath, "samples") + } + if indexPath == "" { + indexPath = filepath.Join(registryPath, "index_main.json") + } + if sampleIndexPath == "" { + sampleIndexPath = filepath.Join(registryPath, "index_extra.json") + } + if stackIndexPath == "" { + stackIndexPath = filepath.Join(registryPath, "index_registry.json") + } +} + +// TestMockOCIServer tests if MockOCIServer is listening for +// requests using the custom '/v2/ping' route +func TestMockOCIServer(t *testing.T) { + mockOCIServer := ocitest.NewMockOCIServer() + if err := mockOCIServer.Start(ociServerIP); err != nil { + t.Errorf("Failed to setup mock OCI server: %v", err) + return + } + defer mockOCIServer.Close() + setupVars() + + resp, err := http.Get(fmt.Sprintf("http://%s", filepath.Join(ociServerIP, "/v2/ping"))) + if err != nil { + t.Errorf("Error in request: %v", err) + return + } + + if !reflect.DeepEqual(resp.StatusCode, http.StatusOK) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", resp.StatusCode, http.StatusOK) + } +} + +// TestServeHealthCheck tests health check endpoint '/health' +func TestServeHealthCheck(t *testing.T) { + var got gin.H + + gin.SetMode(gin.TestMode) + + setupVars() + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + serveHealthCheck(c) + + wantStatusCode := http.StatusOK + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, wantStatusCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, wantStatusCode) + return + } + + wantContentType := "application/json" + header := w.Header() + if gotContentType := strings.Split(header.Get("Content-Type"), ";")[0]; !reflect.DeepEqual(gotContentType, wantContentType) { + t.Errorf("Did not get expected content type, Got: %v, Expected: %v", gotContentType, wantContentType) + return + } + + bytes, err := ioutil.ReadAll(w.Body) + if err != nil { + t.Fatalf("Did not expect error: %v", err) + return + } + + if err = json.Unmarshal(bytes, &got); err != nil { + t.Fatalf("Did not expect error: %v", err) + return + } + + wantMessage := "the server is up and running" + gotMessage, found := got["message"] + if !found { + t.Error("Did not get any body or message.") + return + } else if !reflect.DeepEqual(gotMessage, wantMessage) { + t.Errorf("Did not get expected body or message, Got: %v, Expected: %v", gotMessage, wantMessage) + return + } +} + +// TestServeDevfileIndexV1 tests '/index' endpoint +func TestServeDevfileIndexV1(t *testing.T) { + const wantStatusCode = http.StatusOK + + setupVars() + + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + serveDevfileIndexV1(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, wantStatusCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, wantStatusCode) + return + } +} + +// TestServeDevfileIndexV1WithType tests '/index/:type' endpoint +func TestServeDevfileIndexV1WithType(t *testing.T) { + setupVars() + tests := []struct { + name string + params gin.Params + wantCode int + }{ + { + name: "GET /index/stack - Successful Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "stack"}, + }, + wantCode: http.StatusOK, + }, + { + name: "GET /index/sample - Successful Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "sample"}, + }, + wantCode: http.StatusOK, + }, + { + name: "GET /index/all - Successful Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "all"}, + }, + wantCode: http.StatusOK, + }, + { + name: "GET /index/notatype - Type Not Found Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "notatype"}, + }, + wantCode: http.StatusNotFound, + }, + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + c.Params = append(c.Params, test.params...) + + serveDevfileIndexV1WithType(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + return + } + }) + } +} + +// TestServeDevfileIndexV2 tests '/v2index' endpoint +func TestServeDevfileIndexV2(t *testing.T) { + const wantStatusCode = http.StatusOK + + setupVars() + + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + serveDevfileIndexV2(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, wantStatusCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, wantStatusCode) + return + } +} + +// TestServeDevfileIndexV2 tests '/v2index/:type' endpoint +func TestServeDevfileIndexV2WithType(t *testing.T) { + setupVars() + tests := []struct { + name string + params gin.Params + wantCode int + }{ + { + name: "GET /v2index/stack - Successful Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "stack"}, + }, + wantCode: http.StatusOK, + }, + { + name: "GET /v2index/sample - Successful Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "sample"}, + }, + wantCode: http.StatusOK, + }, + { + name: "GET /v2index/all - Successful Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "all"}, + }, + wantCode: http.StatusOK, + }, + { + name: "GET /v2index/notatype - Type Not Found Response Test", + params: gin.Params{ + gin.Param{Key: "type", Value: "notatype"}, + }, + wantCode: http.StatusNotFound, + }, + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + c.Params = append(c.Params, test.params...) + + serveDevfileIndexV2WithType(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + return + } + }) + } +} + +// TestServeDevfile tests '/devfiles/:name' endpoint +func TestServeDevfile(t *testing.T) { + tests := []struct { + name string + params gin.Params + wantCode int + wantSchemaVersion string + wantError bool + }{ + { + name: "GET /devfiles/java-maven - Fetch Java Maven Devfile", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-maven"}, + }, + wantCode: http.StatusOK, + wantSchemaVersion: "2.2.0", + }, + { + name: "GET /devfiles/go - Fetch Go Devfile", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + }, + wantCode: http.StatusOK, + wantSchemaVersion: "2.0.0", + }, + { + name: "GET /devfiles/not-exist - Fetch Non-Existent Devfile", + params: gin.Params{ + gin.Param{Key: "name", Value: "not-exist"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + } + + closeServer, err := setupMockOCIServer() + if err != nil { + t.Errorf("Did not setup mock OCI server properly: %v", err) + return + } + defer closeServer() + setupVars() + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + c.Params = append(c.Params, test.params...) + + serveDevfile(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + } else if !test.wantError { + bytes := w.Body.Bytes() + content, err := parser.ParseFromData(bytes) + if err != nil { + t.Fatalf("Did not expect error: %v", err) + } + + if gotSchemaVersion := content.Data.GetSchemaVersion(); !reflect.DeepEqual(gotSchemaVersion, test.wantSchemaVersion) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotSchemaVersion, test.wantSchemaVersion) + } + } + }) + } +} + +// TestServeDevfileWithVersion tests '/devfiles/:name/:version' endpoint +func TestServeDevfileWithVersion(t *testing.T) { + tests := []struct { + name string + params gin.Params + wantCode int + wantSchemaVersion string + wantError bool + }{ + { + name: "GET /devfiles/go/default - Fetch Go Devfile With Default Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "version", Value: "default"}, + }, + wantCode: http.StatusOK, + wantSchemaVersion: "2.0.0", + }, + { + name: "GET /devfiles/go/latest - Fetch Go Devfile With Latest Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "version", Value: "latest"}, + }, + wantCode: http.StatusOK, + wantSchemaVersion: "2.1.0", + }, + { + name: "GET /devfiles/go/1.2.0 - Fetch Go Devfile With Specific Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "version", Value: "1.2.0"}, + }, + wantCode: http.StatusOK, + wantSchemaVersion: "2.1.0", + }, + { + name: "GET /devfiles/not-exist/latest - Fetch Non-Existent Devfile With Latest Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "not-exist"}, + gin.Param{Key: "version", Value: "latest"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + { + name: "GET /devfiles/java-maven/not-exist - Fetch Java Maven Devfile With Non-Existent Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-maven"}, + gin.Param{Key: "version", Value: "non-exist"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + } + + closeServer, err := setupMockOCIServer() + if err != nil { + t.Errorf("Did not setup mock OCI server properly: %v", err) + return + } + defer closeServer() + setupVars() + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + c.Params = append(c.Params, test.params...) + + serveDevfileWithVersion(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + } else if !test.wantError { + bytes := w.Body.Bytes() + content, err := parser.ParseFromData(bytes) + if err != nil { + t.Fatalf("Did not expect error: %v", err) + } + + if gotSchemaVersion := content.Data.GetSchemaVersion(); !reflect.DeepEqual(gotSchemaVersion, test.wantSchemaVersion) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotSchemaVersion, test.wantSchemaVersion) + } + } + }) + } +} + +// TestServeDevfileStarterProject tests '/devfiles/:name/starter-projects/:starterProjectName' endpoint +func TestServeDevfileStarterProject(t *testing.T) { + const wantContentType = starterProjectMediaType + tests := []struct { + name string + params gin.Params + wantCode int + wantError bool + }{ + { + name: "GET /devfiles/java-maven/starter-projects/springbootproject - Fetch Java Maven 'springbootproject' Starter Project", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-maven"}, + gin.Param{Key: "starterProjectName", Value: "springbootproject"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/go/starter-projects/go-starter - Fetch Go 'go-starter' Starter Project", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "starterProjectName", Value: "go-starter"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/java-quarkus/starter-projects/community - Fetch Java Quarkus 'community' Starter Project", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-quarkus"}, + gin.Param{Key: "starterProjectName", Value: "community"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/java-wildfly/starter-projects/microprofile-config - Fetch Java Wildfly 'microprofile-config' Starter Project", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-wildfly"}, + gin.Param{Key: "starterProjectName", Value: "microprofile-config"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/java-wildfly/starter-projects/microprofile-jwt - Fetch Java Wildfly 'microprofile-jwt' Starter Project", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-wildfly"}, + gin.Param{Key: "starterProjectName", Value: "microprofile-jwt"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/not-exist/starter-projects/some - Fetch 'some' starter project from Non-Existent stack", + params: gin.Params{ + gin.Param{Key: "name", Value: "not-exist"}, + gin.Param{Key: "starterProjectName", Value: "some"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + { + name: "GET /devfiles/java-maven/starter-projects/not-exist - Fetch Non-Existent starter project from Java Maven stack", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-maven"}, + gin.Param{Key: "starterProjectName", Value: "not-exist"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + } + + closeServer, err := setupMockOCIServer() + if err != nil { + t.Errorf("Did not setup mock OCI server properly: %v", err) + return + } + defer closeServer() + setupVars() + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + c.Params = append(c.Params, test.params...) + + serveDevfileStarterProject(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + } else if !test.wantError { + gotContentType := http.DetectContentType(w.Body.Bytes()) + if !reflect.DeepEqual(gotContentType, wantContentType) { + t.Errorf("Did not get expected content-type, Got: %v, Expected: %v", gotContentType, wantContentType) + } + } + }) + } +} + +// TestServeDevfileStarterProjectWithVersion tests '/devfiles/:name/:version/starter-projects/:starterProjectName' endpoint +func TestServeDevfileStarterProjectWithVersion(t *testing.T) { + const wantContentType = starterProjectMediaType + tests := []struct { + name string + params gin.Params + wantCode int + wantError bool + }{ + { + name: "GET /devfiles/go/default/starter-projects/go-starter - Fetch Go 'go-starter' Starter Project With Default Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "version", Value: "default"}, + gin.Param{Key: "starterProjectName", Value: "go-starter"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/go/latest/starter-projects/go-starter - Fetch Go 'go-starter' Starter Project With Latest Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "version", Value: "latest"}, + gin.Param{Key: "starterProjectName", Value: "go-starter"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/go/1.2.0/starter-projects/go-starter - Fetch Go 'go-starter' Starter Project With Specific Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "go"}, + gin.Param{Key: "version", Value: "1.2.0"}, + gin.Param{Key: "starterProjectName", Value: "go-starter"}, + }, + wantCode: http.StatusAccepted, + }, + { + name: "GET /devfiles/not-exist/latest/starter-projects/some - " + + "Fetch 'some' starter project from Non-Existent stack With Latest Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "not-exist"}, + gin.Param{Key: "version", Value: "latest"}, + gin.Param{Key: "starterProjectName", Value: "some"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + { + name: "GET /devfiles/java-maven/latest/starter-projects/not-exist - " + + "Fetch Non-Existent starter project from Java Maven stack With Latest Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-maven"}, + gin.Param{Key: "version", Value: "latest"}, + gin.Param{Key: "starterProjectName", Value: "not-exist"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + { + name: "GET /devfiles/java-maven/not-exist/starter-projects/springbootproject - " + + "Fetch Java Maven 'springbootproject' Starter Project With Non-Existent Version", + params: gin.Params{ + gin.Param{Key: "name", Value: "java-maven"}, + gin.Param{Key: "version", Value: "non-exist"}, + gin.Param{Key: "starterProjectName", Value: "springbootproject"}, + }, + wantCode: http.StatusNotFound, + wantError: true, + }, + } + + closeServer, err := setupMockOCIServer() + if err != nil { + t.Errorf("Did not setup mock OCI server properly: %v", err) + return + } + defer closeServer() + setupVars() + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + + c.Params = append(c.Params, test.params...) + + serveDevfileStarterProjectWithVersion(c) + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + } else if !test.wantError { + gotContentType := http.DetectContentType(w.Body.Bytes()) + if !reflect.DeepEqual(gotContentType, wantContentType) { + t.Errorf("Did not get expected content-type, Got: %v, Expected: %v", gotContentType, wantContentType) + } + } + }) + } +} + +// TestOCIServerProxy tests '/v2/*proxyPath' endpoint +func TestOCIServerProxy(t *testing.T) { + tests := []struct { + name string + method string + url string + wantCode int + wantError bool + }{ + { + name: "HEAD /v2/devfile-catalog/go/manifests/1.2.0", + method: http.MethodHead, + url: "/devfile-catalog/go/manifests/1.2.0", + wantCode: 200, + }, + { + name: "HEAD /v2/devfile-catalog/go/manifests/notfound", + method: http.MethodHead, + url: "/devfile-catalog/go/manifests/notfound", + wantCode: 404, + wantError: true, + }, + { + name: "GET /v2/devfile-catalog/go/manifests/1.2.0", + method: http.MethodGet, + url: "/devfile-catalog/go/manifests/1.2.0", + wantCode: 200, + }, + { + name: "GET /v2/devfile-catalog/go/manifests/notfound", + method: http.MethodGet, + url: "/devfile-catalog/go/manifests/notfound", + wantCode: 404, + wantError: true, + }, + { + name: "HEAD /v2/devfile-catalog/go/blobs/sha256:bb4c6b96292bbcd48f445436f7945399a4d314b111ee976d6235199e854bfb68", + method: http.MethodHead, + url: "/devfile-catalog/go/blobs/sha256:bb4c6b96292bbcd48f445436f7945399a4d314b111ee976d6235199e854bfb68", + wantCode: 200, + }, + { + name: "HEAD /v2/devfile-catalog/go/blobs/notfound", + method: http.MethodHead, + url: "/devfile-catalog/go/blobs/notfound", + wantCode: 404, + wantError: true, + }, + { + name: "GET /v2/devfile-catalog/go/blobs/sha256:bb4c6b96292bbcd48f445436f7945399a4d314b111ee976d6235199e854bfb68", + method: http.MethodGet, + url: "/devfile-catalog/go/blobs/sha256:bb4c6b96292bbcd48f445436f7945399a4d314b111ee976d6235199e854bfb68", + wantCode: 200, + }, + { + name: "GET /v2/devfile-catalog/go/blobs/notfound", + method: http.MethodGet, + url: "/devfile-catalog/go/blobs/notfound", + wantCode: 404, + wantError: true, + }, + } + + closeServer, err := setupMockOCIServer() + if err != nil { + t.Errorf("Did not setup mock OCI server properly: %v", err) + return + } + defer closeServer() + setupVars() + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + gin.SetMode(gin.TestMode) + + w := ocitest.NewProxyRecorder() + c, _ := gin.CreateTestContext(w) + url := fmt.Sprintf("%s://%s", scheme, filepath.Join(ociServerIP, "v2", test.url)) + + c.Request, err = http.NewRequest(test.method, url, bytes.NewBuffer([]byte{})) + if err != nil { + t.Fatalf("Did not expect error: %v", err) + } + c.Params = append(c.Params, gin.Param{Key: "proxyPath", Value: test.url}) + + ociServerProxy(c) + + // Force writes response headers to combat a response recording issue + c.Writer.WriteHeaderNow() + + if gotStatusCode := w.Code; !reflect.DeepEqual(gotStatusCode, test.wantCode) { + t.Errorf("Did not get expected status code, Got: %v, Expected: %v", gotStatusCode, test.wantCode) + } + }) + } +} diff --git a/index/server/tests/registry/extraDevfileEntries.yaml b/index/server/tests/registry/extraDevfileEntries.yaml new file mode 100644 index 00000000..a11a5cb8 --- /dev/null +++ b/index/server/tests/registry/extraDevfileEntries.yaml @@ -0,0 +1,39 @@ +schemaVersion: 1.0.0 +samples: + - name: nodejs-basic + displayName: Basic NodeJS + description: A simple Hello World application + icon: nodejsIcon.svg + tags: ["NodeJS", "Express"] + projectType: nodejs + language: nodejs + versions: + - version: 1.0.0 + schemaVersion: 2.0.0 + description: nodejs with devfile v2.0.0 + git: + remotes: + origin: https://github.com/redhat-developer/devfile-sample + - version: 1.0.1 + schemaVersion: 2.2.0 + default: true + description: nodejs with devfile v2.2.0 + git: + remotes: + origin: https://github.com/nodeshift-starters/devfile-sample + - name: code-with-quarkus + displayName: Basic Quarkus + description: A simple Hello World Java application using Quarkus + icon: https://raw.githubusercontent.com/elsony/devfile-sample-code-with-quarkus/main/.devfile/icon/quarkus.png + tags: ["Java", "Quarkus"] + projectType: quarkus + language: java + provider: Red Hat + versions: + - version: 1.1.0 + schemaVersion: 2.0.0 + default: true + description: java quarkus with devfile v2.0.0 + git: + remotes: + origin: https://github.com/elsony/devfile-sample-code-with-quarkus.git \ No newline at end of file diff --git a/index/server/tests/registry/index_extra.json b/index/server/tests/registry/index_extra.json new file mode 100644 index 00000000..a605f4c9 --- /dev/null +++ b/index/server/tests/registry/index_extra.json @@ -0,0 +1,65 @@ +[ + { + "name": "nodejs-basic", + "displayName": "Basic NodeJS", + "description": "A simple Hello World application", + "type": "sample", + "tags": [ + "NodeJS", + "Express" + ], + "icon": "nodejsIcon.svg", + "projectType": "nodejs", + "language": "nodejs", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.0.0", + "git": { + "remotes": { + "origin": "https://github.com/redhat-developer/devfile-sample" + } + }, + "description": "nodejs with devfile v2.0.0" + }, + { + "version": "1.0.1", + "schemaVersion": "2.2.0", + "default": true, + "git": { + "remotes": { + "origin": "https://github.com/nodeshift-starters/devfile-sample" + } + }, + "description": "nodejs with devfile v2.2.0" + } + ] + }, + { + "name": "code-with-quarkus", + "displayName": "Basic Quarkus", + "description": "A simple Hello World Java application using Quarkus", + "type": "sample", + "tags": [ + "Java", + "Quarkus" + ], + "icon": "https://raw.githubusercontent.com/elsony/devfile-sample-code-with-quarkus/main/.devfile/icon/quarkus.png", + "projectType": "quarkus", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.0.0", + "default": true, + "git": { + "remotes": { + "origin": "https://github.com/elsony/devfile-sample-code-with-quarkus.git" + } + }, + "description": "java quarkus with devfile v2.0.0" + } + ] + } +] \ No newline at end of file diff --git a/index/server/tests/registry/index_main.json b/index/server/tests/registry/index_main.json new file mode 100644 index 00000000..64363af2 --- /dev/null +++ b/index/server/tests/registry/index_main.json @@ -0,0 +1,493 @@ +[ + { + "name": "go", + "displayName": "Go Runtime", + "description": "Stack with the latest Go version", + "type": "stack", + "tags": [ + "Go", + "testtag" + ], + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", + "projectType": "go", + "language": "go", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.0.0", + "default": true, + "description": "Stack with the latest Go version with devfile v2.0.0 schema verison", + "tags": [ + "Go" + ], + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", + "links": { + "self": "devfile-catalog/go:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "go-starter" + ] + }, + { + "version": "1.2.0", + "schemaVersion": "2.1.0", + "description": "Stack with the latest Go version with devfile v2.1.0 schema verison", + "tags": [ + "testtag" + ], + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", + "links": { + "self": "devfile-catalog/go:1.2.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "go-starter" + ] + } + ] + }, + { + "name": "java-maven", + "displayName": "Maven Java", + "description": "Upstream Maven and OpenJDK 11", + "type": "stack", + "tags": [ + "Java", + "Maven" + ], + "projectType": "maven", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream Maven and OpenJDK 11", + "tags": [ + "Java", + "Maven" + ], + "links": { + "self": "devfile-catalog/java-maven:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "springbootproject" + ] + } + ] + }, + { + "name": "java-openliberty", + "displayName": "Open Liberty", + "description": "Java application stack using Open Liberty runtime", + "type": "stack", + "projectType": "docker", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "0.5.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Java application stack using Open Liberty runtime", + "links": { + "self": "devfile-catalog/java-openliberty:0.5.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "user-app" + ] + } + ] + }, + { + "name": "java-quarkus", + "displayName": "Quarkus Java", + "description": "Upstream Quarkus with Java+GraalVM", + "type": "stack", + "tags": [ + "Java", + "Quarkus" + ], + "projectType": "quarkus", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream Quarkus with Java+GraalVM", + "tags": [ + "Java", + "Quarkus" + ], + "links": { + "self": "devfile-catalog/java-quarkus:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "community", + "redhat-product" + ] + } + ] + }, + { + "name": "java-springboot", + "displayName": "Spring Boot®", + "description": "Spring Boot® using Java", + "type": "stack", + "tags": [ + "Java", + "Spring" + ], + "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "projectType": "spring", + "language": "java", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Spring Boot® using Java", + "tags": [ + "Java", + "Spring" + ], + "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "links": { + "self": "devfile-catalog/java-springboot:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "springbootproject" + ] + } + ] + }, + { + "name": "java-vertx", + "displayName": "Vert.x Java", + "description": "Upstream Vert.x using Java", + "type": "stack", + "tags": [ + "Java", + "Vert.x" + ], + "projectType": "vertx", + "language": "java", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream Vert.x using Java", + "tags": [ + "Java", + "Vert.x" + ], + "links": { + "self": "devfile-catalog/java-vertx:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "vertx-http-example", + "vertx-istio-circuit-breaker-booster", + "vertx-istio-routing-booster", + "vertx-secured-http-example-redhat", + "vertx-crud-example-redhat", + "vertx-istio-security-booster", + "vertx-crud-example", + "vertx-circuit-breaker-example", + "vertx-configmap-example", + "vertx-circuit-breaker-example-redhat", + "vertx-cache-example-redhat", + "vertx-cache-example", + "vertx-secured-http-example", + "vertx-health-checks-example-redhat", + "vertx-http-example-redhat", + "vertx-health-checks-example", + "vertx-configmap-example-redhat", + "vertx-messaging-work-queue-booster", + "vertx-istio-distributed-tracing-booster" + ] + } + ] + }, + { + "name": "java-wildfly", + "displayName": "WildFly Java", + "description": "Upstream WildFly", + "type": "stack", + "tags": [ + "Java", + "WildFly" + ], + "projectType": "wildfly", + "language": "java", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream WildFly", + "tags": [ + "Java", + "WildFly" + ], + "links": { + "self": "devfile-catalog/java-wildfly:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "microprofile-config", + "microprofile-fault-tolerance", + "microprofile-health", + "microprofile-jwt", + "microprofile-metrics", + "microprofile-openapi", + "microprofile-opentracing", + "microprofile-rest-client" + ] + } + ] + }, + { + "name": "java-wildfly-bootable-jar", + "displayName": "WildFly Bootable Jar", + "description": "Java stack with WildFly in bootable Jar mode, OpenJDK 11 and Maven 3.5", + "type": "stack", + "tags": [ + "RHEL8", + "Java", + "OpenJDK", + "Maven", + "WildFly", + "Microprofile", + "WildFly Bootable" + ], + "projectType": "WildFly", + "language": "java", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Java stack with WildFly in bootable Jar mode, OpenJDK 11 and Maven 3.5", + "tags": [ + "RHEL8", + "Java", + "OpenJDK", + "Maven", + "WildFly", + "Microprofile", + "WildFly Bootable" + ], + "links": { + "self": "devfile-catalog/java-wildfly-bootable-jar:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "microprofile-config", + "microprofile-fault-tolerance", + "microprofile-health", + "microprofile-jwt", + "microprofile-metrics", + "microprofile-openapi", + "microprofile-opentracing", + "microprofile-rest-client" + ] + } + ] + }, + { + "name": "nodejs", + "displayName": "NodeJS Runtime", + "description": "Stack with NodeJS 12", + "type": "stack", + "tags": [ + "NodeJS", + "Express", + "ubi8" + ], + "projectType": "nodejs", + "language": "nodejs", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Stack with NodeJS 12", + "tags": [ + "NodeJS", + "Express", + "ubi8" + ], + "links": { + "self": "devfile-catalog/nodejs:1.0.0" + }, + "resources": [ + "archive.tar", + "devfile.yaml" + ], + "starterProjects": [ + "nodejs-starter" + ] + } + ] + }, + { + "name": "python", + "displayName": "Python", + "description": "Python Stack with Python 3.7", + "type": "stack", + "tags": [ + "Python", + "pip" + ], + "projectType": "python", + "language": "python", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Python Stack with Python 3.7", + "tags": [ + "Python", + "pip" + ], + "links": { + "self": "devfile-catalog/python:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "python-example" + ] + } + ] + }, + { + "name": "python-django", + "displayName": "Django", + "description": "Python3.7 with Django", + "type": "stack", + "tags": [ + "Python", + "pip", + "Django" + ], + "projectType": "django", + "language": "python", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Python3.7 with Django", + "tags": [ + "Python", + "pip", + "Django" + ], + "links": { + "self": "devfile-catalog/python-django:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "django-example" + ] + } + ] + }, + { + "name": "nodejs-basic", + "displayName": "Basic NodeJS", + "description": "A simple Hello World application", + "type": "sample", + "tags": [ + "NodeJS", + "Express" + ], + "icon": "nodejsIcon.svg", + "projectType": "nodejs", + "language": "nodejs", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.0.0", + "git": { + "remotes": { + "origin": "https://github.com/redhat-developer/devfile-sample" + } + }, + "description": "nodejs with devfile v2.0.0" + }, + { + "version": "1.0.1", + "schemaVersion": "2.2.0", + "default": true, + "git": { + "remotes": { + "origin": "https://github.com/nodeshift-starters/devfile-sample" + } + }, + "description": "nodejs with devfile v2.2.0" + } + ] + }, + { + "name": "code-with-quarkus", + "displayName": "Basic Quarkus", + "description": "A simple Hello World Java application using Quarkus", + "type": "sample", + "tags": [ + "Java", + "Quarkus" + ], + "icon": "https://raw.githubusercontent.com/elsony/devfile-sample-code-with-quarkus/main/.devfile/icon/quarkus.png", + "projectType": "quarkus", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.0.0", + "default": true, + "git": { + "remotes": { + "origin": "https://github.com/elsony/devfile-sample-code-with-quarkus.git" + } + }, + "description": "java quarkus with devfile v2.0.0" + } + ] + } +] \ No newline at end of file diff --git a/index/server/tests/registry/index_registry.json b/index/server/tests/registry/index_registry.json new file mode 100644 index 00000000..f0050be0 --- /dev/null +++ b/index/server/tests/registry/index_registry.json @@ -0,0 +1,430 @@ +[ + { + "name": "go", + "displayName": "Go Runtime", + "description": "Stack with the latest Go version", + "type": "stack", + "tags": [ + "Go", + "testtag" + ], + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", + "projectType": "go", + "language": "go", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.0.0", + "default": true, + "description": "Stack with the latest Go version with devfile v2.0.0 schema verison", + "tags": [ + "Go" + ], + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", + "links": { + "self": "devfile-catalog/go:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "go-starter" + ] + }, + { + "version": "1.2.0", + "schemaVersion": "2.1.0", + "description": "Stack with the latest Go version with devfile v2.1.0 schema verison", + "tags": [ + "testtag" + ], + "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", + "links": { + "self": "devfile-catalog/go:1.2.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "go-starter" + ] + } + ] + }, + { + "name": "java-maven", + "displayName": "Maven Java", + "description": "Upstream Maven and OpenJDK 11", + "type": "stack", + "tags": [ + "Java", + "Maven" + ], + "projectType": "maven", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream Maven and OpenJDK 11", + "tags": [ + "Java", + "Maven" + ], + "links": { + "self": "devfile-catalog/java-maven:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "springbootproject" + ] + } + ] + }, + { + "name": "java-openliberty", + "displayName": "Open Liberty", + "description": "Java application stack using Open Liberty runtime", + "type": "stack", + "projectType": "docker", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "0.5.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Java application stack using Open Liberty runtime", + "links": { + "self": "devfile-catalog/java-openliberty:0.5.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "user-app" + ] + } + ] + }, + { + "name": "java-quarkus", + "displayName": "Quarkus Java", + "description": "Upstream Quarkus with Java+GraalVM", + "type": "stack", + "tags": [ + "Java", + "Quarkus" + ], + "projectType": "quarkus", + "language": "java", + "provider": "Red Hat", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream Quarkus with Java+GraalVM", + "tags": [ + "Java", + "Quarkus" + ], + "links": { + "self": "devfile-catalog/java-quarkus:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "community", + "redhat-product" + ] + } + ] + }, + { + "name": "java-springboot", + "displayName": "Spring Boot®", + "description": "Spring Boot® using Java", + "type": "stack", + "tags": [ + "Java", + "Spring" + ], + "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "projectType": "spring", + "language": "java", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Spring Boot® using Java", + "tags": [ + "Java", + "Spring" + ], + "icon": "https://www.eclipse.org/che/images/logo-eclipseche.svg", + "links": { + "self": "devfile-catalog/java-springboot:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "springbootproject" + ] + } + ] + }, + { + "name": "java-vertx", + "displayName": "Vert.x Java", + "description": "Upstream Vert.x using Java", + "type": "stack", + "tags": [ + "Java", + "Vert.x" + ], + "projectType": "vertx", + "language": "java", + "versions": [ + { + "version": "1.1.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream Vert.x using Java", + "tags": [ + "Java", + "Vert.x" + ], + "links": { + "self": "devfile-catalog/java-vertx:1.1.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "vertx-http-example", + "vertx-istio-circuit-breaker-booster", + "vertx-istio-routing-booster", + "vertx-secured-http-example-redhat", + "vertx-crud-example-redhat", + "vertx-istio-security-booster", + "vertx-crud-example", + "vertx-circuit-breaker-example", + "vertx-configmap-example", + "vertx-circuit-breaker-example-redhat", + "vertx-cache-example-redhat", + "vertx-cache-example", + "vertx-secured-http-example", + "vertx-health-checks-example-redhat", + "vertx-http-example-redhat", + "vertx-health-checks-example", + "vertx-configmap-example-redhat", + "vertx-messaging-work-queue-booster", + "vertx-istio-distributed-tracing-booster" + ] + } + ] + }, + { + "name": "java-wildfly", + "displayName": "WildFly Java", + "description": "Upstream WildFly", + "type": "stack", + "tags": [ + "Java", + "WildFly" + ], + "projectType": "wildfly", + "language": "java", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Upstream WildFly", + "tags": [ + "Java", + "WildFly" + ], + "links": { + "self": "devfile-catalog/java-wildfly:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "microprofile-config", + "microprofile-fault-tolerance", + "microprofile-health", + "microprofile-jwt", + "microprofile-metrics", + "microprofile-openapi", + "microprofile-opentracing", + "microprofile-rest-client" + ] + } + ] + }, + { + "name": "java-wildfly-bootable-jar", + "displayName": "WildFly Bootable Jar", + "description": "Java stack with WildFly in bootable Jar mode, OpenJDK 11 and Maven 3.5", + "type": "stack", + "tags": [ + "RHEL8", + "Java", + "OpenJDK", + "Maven", + "WildFly", + "Microprofile", + "WildFly Bootable" + ], + "projectType": "WildFly", + "language": "java", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Java stack with WildFly in bootable Jar mode, OpenJDK 11 and Maven 3.5", + "tags": [ + "RHEL8", + "Java", + "OpenJDK", + "Maven", + "WildFly", + "Microprofile", + "WildFly Bootable" + ], + "links": { + "self": "devfile-catalog/java-wildfly-bootable-jar:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "microprofile-config", + "microprofile-fault-tolerance", + "microprofile-health", + "microprofile-jwt", + "microprofile-metrics", + "microprofile-openapi", + "microprofile-opentracing", + "microprofile-rest-client" + ] + } + ] + }, + { + "name": "nodejs", + "displayName": "NodeJS Runtime", + "description": "Stack with NodeJS 12", + "type": "stack", + "tags": [ + "NodeJS", + "Express", + "ubi8" + ], + "projectType": "nodejs", + "language": "nodejs", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Stack with NodeJS 12", + "tags": [ + "NodeJS", + "Express", + "ubi8" + ], + "links": { + "self": "devfile-catalog/nodejs:1.0.0" + }, + "resources": [ + "archive.tar", + "devfile.yaml" + ], + "starterProjects": [ + "nodejs-starter" + ] + } + ] + }, + { + "name": "python", + "displayName": "Python", + "description": "Python Stack with Python 3.7", + "type": "stack", + "tags": [ + "Python", + "pip" + ], + "projectType": "python", + "language": "python", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Python Stack with Python 3.7", + "tags": [ + "Python", + "pip" + ], + "links": { + "self": "devfile-catalog/python:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "python-example" + ] + } + ] + }, + { + "name": "python-django", + "displayName": "Django", + "description": "Python3.7 with Django", + "type": "stack", + "tags": [ + "Python", + "pip", + "Django" + ], + "projectType": "django", + "language": "python", + "versions": [ + { + "version": "1.0.0", + "schemaVersion": "2.2.0", + "default": true, + "description": "Python3.7 with Django", + "tags": [ + "Python", + "pip", + "Django" + ], + "links": { + "self": "devfile-catalog/python-django:1.0.0" + }, + "resources": [ + "devfile.yaml" + ], + "starterProjects": [ + "django-example" + ] + } + ] + } +] \ No newline at end of file diff --git a/index/server/tests/registry/samples/code-with-quarkus/1.1.0/devfile.yaml b/index/server/tests/registry/samples/code-with-quarkus/1.1.0/devfile.yaml new file mode 100644 index 00000000..a7794205 --- /dev/null +++ b/index/server/tests/registry/samples/code-with-quarkus/1.1.0/devfile.yaml @@ -0,0 +1,71 @@ +schemaVersion: 2.0.0 +metadata: + name: java-quarkus + version: 1.1.0 + attributes: + alpha.build-context: . + alpha.build-dockerfile: src/main/docker/Dockerfile.jvm.staged + website: https://quarkus.io + displayName: Quarkus Java + description: Upstream Quarkus with Java+GraalVM + tags: ["Java", "Quarkus"] + projectType: "quarkus" + language: "java" +starterProjects: + - name: community + zip: + location: https://code.quarkus.io/d?e=io.quarkus%3Aquarkus-resteasy&e=io.quarkus%3Aquarkus-micrometer&e=io.quarkus%3Aquarkus-smallrye-health&e=io.quarkus%3Aquarkus-openshift&cn=devfile + - name: redhat-product + zip: + location: https://code.quarkus.redhat.com/d?e=io.quarkus%3Aquarkus-resteasy&e=io.quarkus%3Aquarkus-smallrye-health&e=io.quarkus%3Aquarkus-openshift +components: + - name: buildguidance + attributes: + tool: console-import + container: + image: buildguidanceimage-placeholder + memoryLimit: 1024Mi + endpoints: + - name: http-8081 + targetPort: 8081 + - name: tools + container: + image: quay.io/eclipse/che-quarkus:nightly + memoryLimit: 1512Mi + mountSources: true + volumeMounts: + - name: m2 + path: /home/user/.m2 + endpoints: + - name: '8080-http' + targetPort: 8080 + - name: m2 + volume: + size: 3Gi +commands: + - id: init-compile + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository compile" + workingDir: $PROJECTS_ROOT + - id: dev-run + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository quarkus:dev -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" + hotReloadCapable: true + group: + kind: run + isDefault: true + workingDir: $PROJECTS_ROOT + - id: dev-debug + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository quarkus:dev -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Ddebug=${DEBUG_PORT}" + hotReloadCapable: true + group: + kind: debug + isDefault: true + workingDir: $PROJECTS_ROOT +events: + postStart: + - init-compile diff --git a/index/server/tests/registry/samples/nodejs-basic/1.0.0/devfile.yaml b/index/server/tests/registry/samples/nodejs-basic/1.0.0/devfile.yaml new file mode 100644 index 00000000..5fa08e60 --- /dev/null +++ b/index/server/tests/registry/samples/nodejs-basic/1.0.0/devfile.yaml @@ -0,0 +1,64 @@ +schemaVersion: 2.0.0 +metadata: + name: nodejs + version: 1.0.1 + displayName: Node.js Runtime + description: Stack with Node.js 14 + tags: ["NodeJS", "Express", "ubi8"] + projectType: "nodejs" + language: "nodejs" + attributes: + alpha.build-context: . + alpha.build-dockerfile: Dockerfile +components: + - name: buildguidance + attributes: + tool: console-import + container: + image: buildguidanceimage-placeholder + memoryLimit: 1024Mi + endpoints: + - name: http-3001 + targetPort: 3001 + - name: runtime + container: + image: registry.access.redhat.com/ubi8/nodejs-14:latest + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project + endpoints: + - name: http-3000 + targetPort: 3000 +commands: + - id: install + exec: + component: runtime + commandLine: npm install + workingDir: /project + group: + kind: build + isDefault: true + - id: run + exec: + component: runtime + commandLine: npm start + workingDir: /project + group: + kind: run + isDefault: true + - id: debug + exec: + component: runtime + commandLine: npm run debug + workingDir: /project + group: + kind: debug + isDefault: true + - id: test + exec: + component: runtime + commandLine: npm test + workingDir: /project + group: + kind: test + isDefault: true diff --git a/index/server/tests/registry/samples/nodejs-basic/1.0.1/devfile.yaml b/index/server/tests/registry/samples/nodejs-basic/1.0.1/devfile.yaml new file mode 100644 index 00000000..77164e36 --- /dev/null +++ b/index/server/tests/registry/samples/nodejs-basic/1.0.1/devfile.yaml @@ -0,0 +1,43 @@ +schemaVersion: 2.2.0 +metadata: + name: nodejs + version: 1.0.1 + displayName: Node.js Runtime + description: Stack with Node.js 14 + tags: ["NodeJS", "Express", "ubi8"] + projectType: "nodejs" + language: "nodejs" + attributes: + alpha.dockerimage-port: 3001 + provider: Red Hat + supportUrl: https://github.com/devfile-samples/devfile-support#support-information +parent: + id: nodejs + registryUrl: "https://registry.devfile.io" +components: + - name: outerloop-build + image: + imageName: nodejs-image:latest + dockerfile: + uri: Dockerfile + buildContext: . + rootRequired: false + - name: outerloop-deploy + kubernetes: + uri: outerloop-deploy.yaml +commands: + - id: build-image + apply: + component: outerloop-build + - id: deployk8s + apply: + component: outerloop-deploy + - id: deploy + composite: + commands: + - build-image + - deployk8s + group: + kind: deploy + isDefault: true + diff --git a/index/server/tests/registry/stacks/go/1.1.0/devfile.yaml b/index/server/tests/registry/stacks/go/1.1.0/devfile.yaml new file mode 100644 index 00000000..001d4707 --- /dev/null +++ b/index/server/tests/registry/stacks/go/1.1.0/devfile.yaml @@ -0,0 +1,47 @@ +schemaVersion: 2.0.0 +metadata: + description: Stack with the latest Go version with devfile v2.0.0 schema verison + displayName: Go Runtime + icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg + language: go + name: go + provider: Red Hat + projectType: go + tags: + - Go + version: 1.1.0 +starterProjects: + - name: go-starter + git: + checkoutFrom: + revision: main + remotes: + origin: https://github.com/devfile-samples/devfile-stack-go.git +components: + - container: + endpoints: + - name: http + targetPort: 8080 + image: golang:latest + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project + name: runtime +commands: + - exec: + commandLine: GOCACHE=/project/.cache go build main.go + component: runtime + group: + isDefault: true + kind: build + workingDir: /project + id: build + - exec: + commandLine: ./main + component: runtime + group: + isDefault: true + kind: run + workingDir: /project + id: run + diff --git a/index/server/tests/registry/stacks/go/1.2.0/devfile.yaml b/index/server/tests/registry/stacks/go/1.2.0/devfile.yaml new file mode 100644 index 00000000..a879fa8f --- /dev/null +++ b/index/server/tests/registry/stacks/go/1.2.0/devfile.yaml @@ -0,0 +1,47 @@ +schemaVersion: 2.1.0 +metadata: + description: Stack with the latest Go version with devfile v2.1.0 schema verison + displayName: Go Runtime + icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg + language: go + name: go + provider: Red Hat + projectType: go + tags: + - testtag + version: 1.2.0 +starterProjects: + - name: go-starter + git: + checkoutFrom: + revision: main + remotes: + origin: https://github.com/devfile-samples/devfile-stack-go.git +components: + - container: + endpoints: + - name: http + targetPort: 8080 + image: golang:latest + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project + name: runtime +commands: + - exec: + commandLine: GOCACHE=/project/.cache go build main.go + component: runtime + group: + isDefault: true + kind: build + workingDir: /project + id: build + - exec: + commandLine: ./main + component: runtime + group: + isDefault: true + kind: run + workingDir: /project + id: run + diff --git a/index/server/tests/registry/stacks/go/stack.yaml b/index/server/tests/registry/stacks/go/stack.yaml new file mode 100644 index 00000000..4ac2bf82 --- /dev/null +++ b/index/server/tests/registry/stacks/go/stack.yaml @@ -0,0 +1,8 @@ +name: go +description: Stack with the latest Go version +displayName: Go Runtime +icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg +versions: + - version: 1.1.0 + default: true #should have one and only one default version + - version: 1.2.0 diff --git a/index/server/tests/registry/stacks/java-maven/devfile.yaml b/index/server/tests/registry/stacks/java-maven/devfile.yaml new file mode 100644 index 00000000..744702ff --- /dev/null +++ b/index/server/tests/registry/stacks/java-maven/devfile.yaml @@ -0,0 +1,51 @@ +schemaVersion: 2.2.0 +metadata: + name: java-maven + version: 1.1.0 + displayName: Maven Java + description: Upstream Maven and OpenJDK 11 + tags: ["Java", "Maven"] + projectType: "maven" + language: "java" + provider: "Red Hat" +starterProjects: + - name: springbootproject + git: + remotes: + origin: "https://github.com/odo-devfiles/springboot-ex.git" +components: + - name: tools + container: + image: quay.io/eclipse/che-java11-maven:nightly + memoryLimit: 512Mi + mountSources: true + endpoints: + - name: 'http-8080' + targetPort: 8080 + volumeMounts: + - name: m2 + path: /home/user/.m2 + - name: m2 + volume: {} +commands: + - id: mvn-package + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository package" + group: + kind: build + isDefault: true + - id: run + exec: + component: tools + commandLine: "java -jar target/*.jar" + group: + kind: run + isDefault: true + - id: debug + exec: + component: tools + commandLine: "java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar" + group: + kind: debug + isDefault: true \ No newline at end of file diff --git a/index/server/tests/registry/stacks/java-openliberty/devfile.yaml b/index/server/tests/registry/stacks/java-openliberty/devfile.yaml new file mode 100644 index 00000000..9b16a26e --- /dev/null +++ b/index/server/tests/registry/stacks/java-openliberty/devfile.yaml @@ -0,0 +1,92 @@ +# Copyright (c) 2021 IBM Corporation and others +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +schemaVersion: 2.2.0 +metadata: + name: java-openliberty + version: 0.5.0 + description: Java application stack using Open Liberty runtime + displayName: "Open Liberty" + language: "java" + projectType: "docker" + provider: "Red Hat" + alpha.build-dockerfile: "https://github.com/OpenLiberty/application-stack/releases/download/outer-loop-0.5.1/Dockerfile" + alpha.deployment-manifest: "https://github.com/OpenLiberty/application-stack/releases/download/outer-loop-0.5.1/app-deploy.yaml" +starterProjects: + - name: user-app + git: + remotes: + origin: 'https://github.com/OpenLiberty/application-stack-starters.git' +components: + - name: devruntime + container: + # In the original upstream of this devfile, the image used is openliberty/application-stack:, which is built from the repository: https://github.com/OpenLiberty/application-stack + image: openliberty/application-stack:0.5 + memoryLimit: 1512Mi + mountSources: true + endpoints: + - exposure: public + path: / + name: ep1 + targetPort: 9080 + protocol: http +commands: + - id: build + exec: + component: devruntime + commandLine: /stack/ol/scripts/devbuild-cmd.sh 21.0.0.3 + workingDir: /projects + hotReloadCapable: true + group: + kind: build + isDefault: true + - id: run + exec: + component: devruntime + commandLine: mvn -Dliberty.runtime.version=21.0.0.3 -Ddebug=false -DhotTests=true -DcompileWait=3 liberty:dev + workingDir: /projects + hotReloadCapable: true + group: + kind: run + isDefault: true + - id: run-test-off + exec: + component: devruntime + commandLine: mvn -Dliberty.runtime.version=21.0.0.3 -Ddebug=false liberty:dev + workingDir: /projects + hotReloadCapable: true + group: + kind: run + isDefault: false + - id: debug + exec: + component: devruntime + commandLine: mvn -Dliberty.runtime.version=21.0.0.3 -DdebugPort=${DEBUG_PORT} liberty:dev -Dliberty.env.WLP_DEBUG_REMOTE=y + workingDir: /projects + hotReloadCapable: true + group: + kind: debug + isDefault: true + - id: test + # The 'test' command requires an active container, so we don't need to specify the liberty runtime version + exec: + component: devruntime + commandLine: mvn failsafe:integration-test failsafe:verify + workingDir: /projects + hotReloadCapable: true + group: + kind: test + isDefault: true diff --git a/index/server/tests/registry/stacks/java-quarkus/devfile.yaml b/index/server/tests/registry/stacks/java-quarkus/devfile.yaml new file mode 100644 index 00000000..b7746e29 --- /dev/null +++ b/index/server/tests/registry/stacks/java-quarkus/devfile.yaml @@ -0,0 +1,60 @@ +schemaVersion: 2.2.0 +metadata: + name: java-quarkus + version: 1.1.0 + website: https://quarkus.io + displayName: Quarkus Java + description: Upstream Quarkus with Java+GraalVM + tags: ["Java", "Quarkus"] + projectType: "quarkus" + language: "java" + provider: "Red Hat" +starterProjects: + - name: community + zip: + location: https://code.quarkus.io/d?e=io.quarkus%3Aquarkus-resteasy&e=io.quarkus%3Aquarkus-micrometer&e=io.quarkus%3Aquarkus-smallrye-health&e=io.quarkus%3Aquarkus-openshift&cn=devfile + - name: redhat-product + zip: + location: https://code.quarkus.redhat.com/d?e=io.quarkus%3Aquarkus-resteasy&e=io.quarkus%3Aquarkus-smallrye-health&e=io.quarkus%3Aquarkus-openshift +components: + - name: tools + container: + image: quay.io/eclipse/che-quarkus:nightly + memoryLimit: 1512Mi + mountSources: true + volumeMounts: + - name: m2 + path: /home/user/.m2 + endpoints: + - name: '8080-http' + targetPort: 8080 + - name: m2 + volume: + size: 3Gi +commands: + - id: init-compile + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository compile" + workingDir: $PROJECTS_ROOT + - id: dev-run + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository quarkus:dev -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" + hotReloadCapable: true + group: + kind: run + isDefault: true + workingDir: $PROJECTS_ROOT + - id: dev-debug + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository quarkus:dev -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Ddebug=${DEBUG_PORT}" + hotReloadCapable: true + group: + kind: debug + isDefault: true + workingDir: $PROJECTS_ROOT +events: + postStart: + - init-compile diff --git a/index/server/tests/registry/stacks/java-springboot/devfile.yaml b/index/server/tests/registry/stacks/java-springboot/devfile.yaml new file mode 100644 index 00000000..abe0d074 --- /dev/null +++ b/index/server/tests/registry/stacks/java-springboot/devfile.yaml @@ -0,0 +1,53 @@ +schemaVersion: 2.2.0 +metadata: + name: java-springboot + version: 1.1.0 + displayName: Spring Boot® + description: Spring Boot® using Java + tags: ["Java", "Spring"] + globalMemoryLimit: 2674Mi + icon: https://www.eclipse.org/che/images/logo-eclipseche.svg + projectType: "spring" + language: "java" +starterProjects: + - name: springbootproject + git: + remotes: + origin: "https://github.com/odo-devfiles/springboot-ex.git" +components: + - name: tools + container: + image: quay.io/eclipse/che-java11-maven:nightly + memoryLimit: 768Mi + mountSources: true + endpoints: + - name: '8080-tcp' + targetPort: 8080 + volumeMounts: + - name: m2 + path: /home/user/.m2 + - name: m2 + volume: + size: 3Gi +commands: + - id: build + exec: + component: tools + commandLine: "mvn clean -Dmaven.repo.local=/home/user/.m2/repository package -Dmaven.test.skip=true" + group: + kind: build + isDefault: true + - id: run + exec: + component: tools + commandLine: "mvn -Dmaven.repo.local=/home/user/.m2/repository spring-boot:run" + group: + kind: run + isDefault: true + - id: debug + exec: + component: tools + commandLine: "java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n -jar target/*.jar" + group: + kind: debug + isDefault: true \ No newline at end of file diff --git a/index/server/tests/registry/stacks/java-vertx/devfile.yaml b/index/server/tests/registry/stacks/java-vertx/devfile.yaml new file mode 100644 index 00000000..a3bd188c --- /dev/null +++ b/index/server/tests/registry/stacks/java-vertx/devfile.yaml @@ -0,0 +1,126 @@ +schemaVersion: 2.2.0 +metadata: + name: java-vertx + version: 1.1.0 + displayName: Vert.x Java + description: Upstream Vert.x using Java + tags: ["Java", "Vert.x"] + projectType: "vertx" + language: "java" +starterProjects: + - name: vertx-http-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-http-example + - name: vertx-istio-circuit-breaker-booster + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-istio-circuit-breaker-booster + - name: vertx-istio-routing-booster + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-istio-routing-booster + - name: vertx-secured-http-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-secured-http-example-redhat + - name: vertx-crud-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-crud-example-redhat + - name: vertx-istio-security-booster + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-istio-security-booster + - name: vertx-crud-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-crud-example + - name: vertx-circuit-breaker-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-circuit-breaker-example + - name: vertx-configmap-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-configmap-example + - name: vertx-circuit-breaker-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-circuit-breaker-example-redhat + - name: vertx-cache-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-cache-example-redhat + - name: vertx-cache-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-cache-example + - name: vertx-secured-http-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-secured-http-example + - name: vertx-health-checks-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-health-checks-example-redhat + - name: vertx-http-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-http-example-redhat + - name: vertx-health-checks-example + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-health-checks-example + - name: vertx-configmap-example-redhat + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-configmap-example-redhat + - name: vertx-messaging-work-queue-booster + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-messaging-work-queue-booster + - name: vertx-istio-distributed-tracing-booster + git: + remotes: + origin: https://github.com/openshift-vertx-examples/vertx-istio-distributed-tracing-booster +components: + - name: runtime + container: + endpoints: + - exposure: public + path: / + name: '8080-tcp' + targetPort: 8080 + protocol: http + image: quay.io/eclipse/che-java11-maven:nightly + memoryLimit: 512Mi + mountSources: true + volumeMounts: + - name: m2 + path: /home/user/.m2 + - name: m2 + volume: + size: 3Gi +commands: + - id: mvn-package + exec: + commandLine: mvn package -Dmaven.test.skip=true + component: runtime + group: + isDefault: true + kind: build + - id: run + exec: + commandLine: mvn io.reactiverse:vertx-maven-plugin:run + component: runtime + group: + isDefault: true + kind: run + - id: debug + exec: + commandLine: mvn io.reactiverse:vertx-maven-plugin:debug -Ddebug.port=${DEBUG_PORT} + component: runtime + group: + isDefault: true + kind: debug diff --git a/index/server/tests/registry/stacks/java-wildfly-bootable-jar/devfile.yaml b/index/server/tests/registry/stacks/java-wildfly-bootable-jar/devfile.yaml new file mode 100644 index 00000000..4b6094da --- /dev/null +++ b/index/server/tests/registry/stacks/java-wildfly-bootable-jar/devfile.yaml @@ -0,0 +1,204 @@ +schemaVersion: 2.2.0 +metadata: + name: java-wildfly-bootable-jar + version: 1.0.0 + website: https://docs.wildfly.org/bootablejar/ + displayName: WildFly Bootable Jar + description: Java stack with WildFly in bootable Jar mode, OpenJDK 11 and Maven 3.5 + tags: ["RHEL8", "Java", "OpenJDK", "Maven", "WildFly", "Microprofile", "WildFly Bootable"] + projectType: "WildFly" + language: "java" +starterProjects: + - name: microprofile-config + description: WildFly Eclipse Microprofile Config Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-config + - name: microprofile-fault-tolerance + description: WildFly Eclipse Microprofile Fault Tolerance Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-fault-tolerance + - name: microprofile-health + description: WildFly Eclipse Microprofile Health Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-health + - name: microprofile-jwt + description: WildFly Eclipse Microprofile JWT Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-jwt + - name: microprofile-metrics + description: WildFly Eclipse Microprofile Metrics Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-metrics + - name: microprofile-openapi + description: WildFly Eclipse Microprofile OpenAPI Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-openapi + - name: microprofile-opentracing + description: WildFly Eclipse Microprofile OpenTracing Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-opentracing + - name: microprofile-rest-client + description: WildFly Eclipse Microprofile REST Client Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.0.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-rest-client +components: + - name: jaeger + container: + image: quay.io/jaegertracing/all-in-one:1.21.0 + memoryLimit: 128Mi + endpoints: + - name: 'tracing-ui' + targetPort: 16686 + - name: wildfly + container: + image: registry.access.redhat.com/ubi8/openjdk-11 + memoryLimit: 1512Mi + mountSources: true + volumeMounts: + - name: m2-repository + path: /home/jboss/.m2/repository + env: + # Enabling Jaeger tracing + - name: WILDFLY_TRACING_ENABLED + value: 'true' + # Define the Jaeger service name + - name: JAEGER_SERVICE_NAME + value: 'microprofile-opentracing' + # Configure Jaeger traces + - name: JAEGER_REPORTER_LOG_SPANS + value: 'true' + - name: JAEGER_SAMPLER_TYPE + value: 'const' + - name: JAEGER_SAMPLER_PARAM + value: '1' + - name: GC_METASPACE_SIZE + value: '96' + - name: GC_MAX_METASPACE_SIZE + value: '256' + - name: JAVA_OPTS + value: '-Djava.security.egd=file:/dev/urandom' + - name: MVN_ARGS_APPEND + value: '-Pbootable-jar -s /home/jboss/.m2/settings.xml -Dmaven.repo.local=/home/jboss/.m2/repository -Dcom.redhat.xpaas.repo.jbossorg -Dversion.wildfly-jar.maven.plugin=3.0.1.Final' + endpoints: + - name: 'http' + targetPort: 8080 + - name: m2-repository + volume: + size: 3Gi +commands: + - id: build + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} clean package + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: false + - id: run + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} org.wildfly.plugins:wildfly-jar-maven-plugin:run + workingDir: $PROJECTS_ROOT + group: + kind: run + isDefault: false + - id: debug + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} -Dwildfly.bootable.arguments="-b=0.0.0.0" -Dwildfly.bootable.jvmArguments="-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:${DEBUG_PORT},server=y,suspend=n" org.wildfly.plugins:wildfly-jar-maven-plugin:run + workingDir: $PROJECTS_ROOT + group: + kind: debug + isDefault: false + - id: dev-build + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} -Dmaven.test.skip=true -Ddev package + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: false + - id: dev-run + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} -Dwildfly.bootable.arguments="-b=0.0.0.0" org.wildfly.plugins:wildfly-jar-maven-plugin:dev + workingDir: $PROJECTS_ROOT + hotReloadCapable: true + group: + kind: run + isDefault: false + - id: dev-debug + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} -Dwildfly.bootable.arguments="-b=0.0.0.0" -Dwildfly.bootable.jvmArguments="-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:${DEBUG_PORT},server=y,suspend=n" org.wildfly.plugins:wildfly-jar-maven-plugin:dev + workingDir: $PROJECTS_ROOT + hotReloadCapable: true + group: + kind: debug + isDefault: false + - id: watch-build + exec: + component: wildfly + commandLine: echo 'It's watcher mode Baby !!!'' + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: true + - id: watch-run + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} -Dwildfly.bootable.arguments="-b=0.0.0.0" org.wildfly.plugins:wildfly-jar-maven-plugin:dev-watch -e -DskipTests + workingDir: $PROJECTS_ROOT + hotReloadCapable: true + group: + kind: run + isDefault: true + - id: watch-debug + exec: + component: wildfly + commandLine: mvn ${MVN_ARGS_APPEND} -Dwildfly.bootable.arguments="-b=0.0.0.0" -Dwildfly.bootable.jvmArguments="-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:${DEBUG_PORT},server=y,suspend=n" org.wildfly.plugins:wildfly-jar-maven-plugin:dev-watch -e + workingDir: $PROJECTS_ROOT + hotReloadCapable: true + group: + kind: debug + isDefault: true \ No newline at end of file diff --git a/index/server/tests/registry/stacks/java-wildfly/devfile.yaml b/index/server/tests/registry/stacks/java-wildfly/devfile.yaml new file mode 100644 index 00000000..9e95e503 --- /dev/null +++ b/index/server/tests/registry/stacks/java-wildfly/devfile.yaml @@ -0,0 +1,225 @@ +schemaVersion: 2.2.0 +metadata: + name: java-wildfly + version: 1.0.0 + website: https://wildfly.org + displayName: WildFly Java + description: Upstream WildFly + tags: ["Java", "WildFly"] + projectType: "wildfly" + language: "java" +starterProjects: + - name: microprofile-config + description: WildFly Eclipse Microprofile Config Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-config + - name: microprofile-fault-tolerance + description: WildFly Eclipse Microprofile Fault Tolerance Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-fault-tolerance + - name: microprofile-health + description: WildFly Eclipse Microprofile Health Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-health + - name: microprofile-jwt + description: WildFly Eclipse Microprofile JWT Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-jwt + - name: microprofile-metrics + description: WildFly Eclipse Microprofile Metrics Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-metrics + - name: microprofile-openapi + description: WildFly Eclipse Microprofile OpenAPI Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-openapi + - name: microprofile-opentracing + description: WildFly Eclipse Microprofile OpenTracing Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-opentracing + - name: microprofile-rest-client + description: WildFly Eclipse Microprofile REST Client Quickstart + git: + checkoutFrom: + remote: wildfly-quickstart + revision: 22.0.1.Final + remotes: + wildfly-quickstart: https://github.com/wildfly/quickstart.git + subDir: microprofile-rest-client +components: + - name: wildfly + container: + image: quay.io/wildfly/wildfly-centos7:22.0 + memoryLimit: 1512Mi + mountSources: true + volumeMounts: + - name: m2-repository + path: /home/jboss/.m2/repository + env: + - name: GC_METASPACE_SIZE + value: '96' + - name: GC_MAX_METASPACE_SIZE + value: '256' + - name: GALLEON_PROVISION_LAYERS + value: 'jaxrs-server,microprofile-platform' + - name: S2I_DESTINATION_DIR + value: '/projects' + - name: STANDALONE_RESTORE + value: /home/jboss/.m2/.lucky + - name: JBOSS_HOME + value: '/projects/wildfly' + - name: MVN_ARGS_APPEND + value: '-s /home/jboss/.m2/settings.xml -Dmaven.repo.local=/home/jboss/.m2/repository -Dcom.redhat.xpaas.repo.jbossorg' + endpoints: + - name: 'wildfly-http' + targetPort: 8080 + - name: m2-repository + volume: + size: 3Gi + - name: jaeger + container: + image: quay.io/jaegertracing/all-in-one:1.21.0 + memoryLimit: 128Mi + endpoints: + - name: 'tracing-ui' + targetPort: 16686 +commands: + - id: build + composite: + label: Build and deploy on WildFly Server + commands: + - compile + - copy-artifact + parallel: false + group: + kind: build + isDefault: true + - id: compile + exec: + label: Compile and package the application + component: wildfly + commandLine: source ${JBOSS_CONTAINER_MAVEN_DEFAULT_MODULE}/scl-enable-maven && mvn ${MVN_ARGS_APPEND} -Dmaven.test.skip=true clean package + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: false + - id: copy-artifact + exec: + label: Copy application artifact + component: wildfly + commandLine: cp target/*.war $JBOSS_HOME/standalone/deployments/ROOT.war + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: false + - id: run + exec: + label: Launch WildFly Server + component: wildfly + commandLine: cp -f $STANDALONE_RESTORE/standalone.xml $JBOSS_HOME/standalone/configuration/standalone.xml && $JBOSS_HOME/bin/openshift-launch.sh + workingDir: $PROJECTS_ROOT + hotReloadCapable: true + group: + kind: run + isDefault: true + - id: debug + exec: + label: Launch WildFly Server with debug enabled + component: wildfly + commandLine: cp -f $STANDALONE_RESTORE/standalone.xml $JBOSS_HOME/standalone/configuration/standalone.xml&& $JBOSS_HOME/bin/openshift-launch.sh + workingDir: $PROJECTS_ROOT + hotReloadCapable: true + env: + - name: JAVA_OPTS_APPEND + value: '-Xrunjdwp:transport=dt_socket,address=0.0.0.0:$DEBUG_PORT,server=y,suspend=n -Dsun.util.logging.disableCallerCheck=true' + group: + kind: debug + isDefault: true +#Hack to avoid the file permissions issue with the random openshift user + - id: copy-galleon + exec: + component: wildfly + commandLine: cp -Rf /opt/jboss/container/wildfly/s2i/galleon/galleon-m2-repository /tmp/. && cp -Rf /opt/wildfly /tmp/. + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: false + - id: copy-settings + exec: + component: wildfly + commandLine: cp ${JBOSS_CONTAINER_MAVEN_DEFAULT_MODULE}/jboss-settings.xml /tmp/settings.xml + workingDir: $PROJECTS_ROOT + group: + kind: build + isDefault: false + - id: provision-server + exec: + component: wildfly + commandLine: /usr/local/s2i/assemble && cp -Rf $JBOSS_HOME . + workingDir: $PROJECTS_ROOT + env: + - name: JBOSS_HOME + value: '/tmp/wildfly' + group: + kind: build + isDefault: false + - id: store-config + exec: + component: wildfly + commandLine: mkdir $STANDALONE_RESTORE && cp -f $JBOSS_HOME/standalone/configuration/standalone.xml $STANDALONE_RESTORE/standalone.xml + workingDir: $PROJECTS_ROOT + env: + - name: JBOSS_HOME + value: '/tmp/wildfly' + group: + kind: build + isDefault: false + - id: init-server + composite: + label: Provision WildFly Server + commands: + - copy-galleon + - provision-server + - store-config + parallel: false + group: + kind: build + isDefault: false +events: + postStart: + - "init-server" \ No newline at end of file diff --git a/index/server/tests/registry/stacks/nodejs/archive.tar b/index/server/tests/registry/stacks/nodejs/archive.tar new file mode 100644 index 0000000000000000000000000000000000000000..1655dace7f3a862b35de3b40ad82af5e7153c956 GIT binary patch literal 848 zcmV-W1F!raiwFQFGKgRR1MOGaZrer>^)tU>pa6L)DM}`lf@)~(w^?v zYtIfa@?3B1p1Tvz2X}Pt`TiOB$EDSx(uOIba?3@UR1Zv~&)=hKNpiqW7svMemtfu0 z|4K%8s1lyzF?>)yCZ6|l{r!per2f9=duQMtgUnO>&+GpRrh-Dtb1)eKD@%y6L=mHi zIBMVm7$g;m=Q2i!n?3^}rd%7faaa_g){eqBW5$VOF|5}7`=KDUTWycV z!N~S}%eq`Fe+LJKrINQ8nW1I9f_GI}N@aklH8+Z>4OF`J5^F2`We!o6suJuF+^rhC zehu#}AVgUq<64-$t+wLYXo!WprZRb;pn6z}W`{uq#a@Er{5Rx^VS-@4}epxAP`Iqm}Z2lId8 zk5BXeYoM!tdlV>)T`<8D)W+GcBL5;j{$l=*z4J-G{$tl4zd6nSuL0Y(tvfE_0Is$z zV6l?_ib~S}3+k1ihxa3^K*M5YSU_V}umS`4_|dss%$AG!^?Y?RznEQr`b4svtufa@ zGn`4+xvSQw1RB&1m&0aAis(h{=X4Hvd+vToL)Mnb^D4T;s3xZT+rAI`18-dmdr0?f!PhJ!WN(vHir;E~L-7(c@3ie9pVy5r@jZDT&!- zPICm+blIrtI);lR;ewk@KtG)X?u8r5%JhR(^*4^BUl}^%iK(0Tzw_cqK?rG@SJ1KS zMVd+4H7Qc}&?BPs42-I9u&t|+txmsH>TeFSd_bONRMe5{cHPn1d8yzJ^gk$KDqc#O a3y($n*3