cloudapi/v2: Listen on /api/image-builder-composer/v2
This commit is contained in:
parent
01d920ac01
commit
6ce20a9ef6
7 changed files with 80 additions and 75 deletions
|
|
@ -231,7 +231,7 @@ func (c *Composer) Start() error {
|
|||
if c.apiListener != nil {
|
||||
go func() {
|
||||
const apiRoute = "/api/composer/v1"
|
||||
const apiRouteV2 = "/api/composer/v2"
|
||||
const apiRouteV2 = "/api/image-builder-composer/v2"
|
||||
const kojiRoute = "/api/composer-koji/v1"
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
ErrorCodePrefix = "COMPOSER-"
|
||||
ErrorHREF = "/api/composer/v2/errors"
|
||||
ErrorCodePrefix = "IMAGE-BUILDER-COMPOSER-"
|
||||
ErrorHREF = "/api/image-builder-composer/v2/errors"
|
||||
|
||||
// ocm-sdk sends ErrorUnauthenticated with id 401 & code COMPOSER-401
|
||||
ErrorUnauthenticated ServiceErrorCode = 401
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ func TestAPIError(t *testing.T) {
|
|||
ctx := e.NewContext(nil, nil)
|
||||
ctx.Set("operationID", "test-operation-id")
|
||||
apiError := APIError(se.code, nil, ctx)
|
||||
require.Equal(t, fmt.Sprintf("/api/composer/v2/errors/%d", se.code), apiError.Href)
|
||||
require.Equal(t, fmt.Sprintf("/api/image-builder-composer/v2/errors/%d", se.code), apiError.Href)
|
||||
require.Equal(t, fmt.Sprintf("%d", se.code), apiError.Id)
|
||||
require.Equal(t, "Error", apiError.Kind)
|
||||
require.Equal(t, fmt.Sprintf("COMPOSER-%d", se.code), apiError.Code)
|
||||
require.Equal(t, fmt.Sprintf("IMAGE-BUILDER-COMPOSER-%d", se.code), apiError.Code)
|
||||
require.Equal(t, "test-operation-id", apiError.OperationId)
|
||||
require.Equal(t, se.reason, apiError.Reason)
|
||||
}
|
||||
|
|
@ -39,15 +39,15 @@ func TestAPIErrorOperationID(t *testing.T) {
|
|||
ctx := echo.New().NewContext(nil, nil)
|
||||
|
||||
apiError := APIError(ErrorUnauthenticated, nil, ctx)
|
||||
require.Equal(t, "COMPOSER-10003", apiError.Code)
|
||||
require.Equal(t, "IMAGE-BUILDER-COMPOSER-10003", apiError.Code)
|
||||
|
||||
ctx.Set("operationID", 5)
|
||||
apiError = APIError(ErrorUnauthenticated, nil, ctx)
|
||||
require.Equal(t, "COMPOSER-10003", apiError.Code)
|
||||
require.Equal(t, "IMAGE-BUILDER-COMPOSER-10003", apiError.Code)
|
||||
|
||||
ctx.Set("operationID", "test-operation-id")
|
||||
apiError = APIError(ErrorUnauthenticated, nil, ctx)
|
||||
require.Equal(t, "COMPOSER-401", apiError.Code)
|
||||
require.Equal(t, "IMAGE-BUILDER-COMPOSER-401", apiError.Code)
|
||||
}
|
||||
|
||||
func TestAPIErrorList(t *testing.T) {
|
||||
|
|
@ -74,12 +74,12 @@ func TestAPIErrorList(t *testing.T) {
|
|||
require.Equal(t, 10, errs.Size)
|
||||
require.Equal(t, len(getServiceErrors()), errs.Total)
|
||||
require.Equal(t, 0, errs.Page)
|
||||
require.Equal(t, "COMPOSER-401", errs.Items[0].Code)
|
||||
require.Equal(t, "IMAGE-BUILDER-COMPOSER-401", errs.Items[0].Code)
|
||||
errs = APIErrorList(1, 10, ctx)
|
||||
require.Equal(t, 10, errs.Size)
|
||||
require.Equal(t, len(getServiceErrors()), errs.Total)
|
||||
require.Equal(t, 1, errs.Page)
|
||||
require.Equal(t, "COMPOSER-11", errs.Items[0].Code)
|
||||
require.Equal(t, "IMAGE-BUILDER-COMPOSER-11", errs.Items[0].Code)
|
||||
|
||||
// high page
|
||||
errs = APIErrorList(1000, 1, ctx)
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ info:
|
|||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
servers:
|
||||
- url: https://api.openshift.com/api/composer/v2
|
||||
- url: https://api.openshift.com/api/image-builder-composer/v2
|
||||
description: Main (production) server
|
||||
- url: https://api.stage.openshift.com/api/composer/v2
|
||||
- url: https://api.stage.openshift.com/api/image-builder-composer/v2
|
||||
description: Staging server
|
||||
- url: /api/composer/v2
|
||||
- url: /api/image-builder-composer/v2
|
||||
description: current domain
|
||||
|
||||
paths:
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
|
||||
return ctx.JSON(http.StatusCreated, &ComposeId{
|
||||
ObjectReference: ObjectReference{
|
||||
Href: "/api/composer/v2/compose",
|
||||
Href: "/api/image-builder-composer/v2/compose",
|
||||
Id: id.String(),
|
||||
Kind: "ComposeId",
|
||||
},
|
||||
|
|
@ -498,7 +498,7 @@ func (h *apiHandlers) GetComposeStatus(ctx echo.Context, id string) error {
|
|||
|
||||
return ctx.JSON(http.StatusOK, ComposeStatus{
|
||||
ObjectReference: ObjectReference{
|
||||
Href: fmt.Sprintf("/api/composer/v2/compose/%v", jobId),
|
||||
Href: fmt.Sprintf("/api/image-builder-composer/v2/compose/%v", jobId),
|
||||
Id: jobId.String(),
|
||||
Kind: "ComposeStatus",
|
||||
},
|
||||
|
|
@ -553,7 +553,7 @@ func (h *apiHandlers) GetComposeMetadata(ctx echo.Context, id string) error {
|
|||
// job still running: empty response
|
||||
return ctx.JSON(200, ComposeMetadata{
|
||||
ObjectReference: ObjectReference{
|
||||
Href: fmt.Sprintf("/api/composer/v2/%v/metadata", jobId),
|
||||
Href: fmt.Sprintf("/api/image-builder-composer/v2/%v/metadata", jobId),
|
||||
Id: jobId.String(),
|
||||
Kind: "ComposeMetadata",
|
||||
},
|
||||
|
|
@ -564,7 +564,7 @@ func (h *apiHandlers) GetComposeMetadata(ctx echo.Context, id string) error {
|
|||
// job canceled or failed, empty response
|
||||
return ctx.JSON(200, ComposeMetadata{
|
||||
ObjectReference: ObjectReference{
|
||||
Href: fmt.Sprintf("/api/composer/v2/%v/metadata", jobId),
|
||||
Href: fmt.Sprintf("/api/image-builder-composer/v2/%v/metadata", jobId),
|
||||
Id: jobId.String(),
|
||||
Kind: "ComposeMetadata",
|
||||
},
|
||||
|
|
@ -631,7 +631,7 @@ func (h *apiHandlers) GetComposeMetadata(ctx echo.Context, id string) error {
|
|||
|
||||
resp := &ComposeMetadata{
|
||||
ObjectReference: ObjectReference{
|
||||
Href: fmt.Sprintf("/api/composer/v2/compose/%v/metadata", jobId),
|
||||
Href: fmt.Sprintf("/api/image-builder-composer/v2/compose/%v/metadata", jobId),
|
||||
Id: jobId.String(),
|
||||
Kind: "ComposeMetadata",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ func TestUnknownRoute(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, _ := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", "/api/composer/v2/badroute", ``, http.StatusNotFound, `
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/badroute", ``, http.StatusNotFound, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/21",
|
||||
"href": "/api/image-builder-composer/v2/errors/21",
|
||||
"id": "21",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-21",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-21",
|
||||
"reason": "Requested resource doesn't exist"
|
||||
}`, "operation_id")
|
||||
}
|
||||
|
|
@ -56,21 +56,21 @@ func TestGetError(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, _ := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", "/api/composer/v2/errors/4", ``, http.StatusOK, `
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/errors/4", ``, http.StatusOK, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/4",
|
||||
"href": "/api/image-builder-composer/v2/errors/4",
|
||||
"id": "4",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-4",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-4",
|
||||
"reason": "Unsupported distribution"
|
||||
}`, "operation_id")
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", "/api/composer/v2/errors/3000", ``, http.StatusNotFound, `
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/errors/3000", ``, http.StatusNotFound, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/17",
|
||||
"href": "/api/image-builder-composer/v2/errors/17",
|
||||
"id": "17",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-17",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-17",
|
||||
"reason": "Error with given id not found"
|
||||
}`, "operation_id")
|
||||
}
|
||||
|
|
@ -81,16 +81,16 @@ func TestGetErrorList(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, _ := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", "/api/composer/v2/errors?page=3&size=1", ``, http.StatusOK, `
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/errors?page=3&size=1", ``, http.StatusOK, `
|
||||
{
|
||||
"kind": "ErrorList",
|
||||
"page": 3,
|
||||
"size": 1,
|
||||
"items": [{
|
||||
"href": "/api/composer/v2/errors/4",
|
||||
"href": "/api/image-builder-composer/v2/errors/4",
|
||||
"id": "4",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-4",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-4",
|
||||
"reason": "Unsupported distribution"
|
||||
}]
|
||||
}`, "operation_id", "total")
|
||||
|
|
@ -103,7 +103,7 @@ func TestCompose(t *testing.T) {
|
|||
srv, _ := newV2Server(t, dir)
|
||||
|
||||
// unsupported distribution
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "unsupported_distro",
|
||||
"image_requests":[{
|
||||
|
|
@ -120,15 +120,15 @@ func TestCompose(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestArch3Name), http.StatusBadRequest, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/4",
|
||||
"href": "/api/image-builder-composer/v2/errors/4",
|
||||
"id": "4",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-4",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-4",
|
||||
"reason": "Unsupported distribution"
|
||||
}`, "operation_id")
|
||||
|
||||
// unsupported architecture
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -144,15 +144,15 @@ func TestCompose(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName), http.StatusBadRequest, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/5",
|
||||
"href": "/api/image-builder-composer/v2/errors/5",
|
||||
"id": "5",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-5",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-5",
|
||||
"reason": "Unsupported architecture"
|
||||
}`, "operation_id")
|
||||
|
||||
// unsupported imagetype
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -168,15 +168,15 @@ func TestCompose(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusBadRequest, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/6",
|
||||
"href": "/api/image-builder-composer/v2/errors/6",
|
||||
"id": "6",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-6",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-6",
|
||||
"reason": "Unsupported image type"
|
||||
}`, "operation_id")
|
||||
|
||||
// Returns 404, but should be 405; see https://github.com/labstack/echo/issues/1981
|
||||
// test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
// test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
// {
|
||||
// "distribution": "%s",
|
||||
// "image_requests":[{
|
||||
|
|
@ -192,14 +192,14 @@ func TestCompose(t *testing.T) {
|
|||
// }]
|
||||
// }`, test_distro.TestDistroName, test_distro.TestArch3Name, test_distro.TestImageTypeName), http.StatusMethodNotAllowed, `
|
||||
// {
|
||||
// "href": "/api/composer/v2/errors/22",
|
||||
// "href": "/api/image-builder-composer/v2/errors/22",
|
||||
// "id": "22",
|
||||
// "kind": "Error",
|
||||
// "code": "COMPOSER-22",
|
||||
// "code": "IMAGE-BUILDER-COMPOSER-22",
|
||||
// "reason": "Requested method isn't supported for resource"
|
||||
// }`, "operation_id")
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -215,7 +215,7 @@ func TestCompose(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ func TestComposeStatusSuccess(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, wrksrv := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -242,7 +242,7 @@ func TestComposeStatusSuccess(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
|
||||
|
|
@ -250,9 +250,9 @@ func TestComposeStatusSuccess(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, "osbuild", jobType)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", fmt.Sprintf("/api/composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
{
|
||||
"href": "/api/composer/v2/compose/%v",
|
||||
"href": "/api/image-builder-composer/v2/compose/%v",
|
||||
"kind": "ComposeStatus",
|
||||
"id": "%v",
|
||||
"image_status": {"status": "building"}
|
||||
|
|
@ -266,20 +266,20 @@ func TestComposeStatusSuccess(t *testing.T) {
|
|||
|
||||
err = wrksrv.FinishJob(token, res)
|
||||
require.NoError(t, err)
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", fmt.Sprintf("/api/composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
{
|
||||
"href": "/api/composer/v2/compose/%v",
|
||||
"href": "/api/image-builder-composer/v2/compose/%v",
|
||||
"kind": "ComposeStatus",
|
||||
"id": "%v",
|
||||
"image_status": {"status": "success"}
|
||||
}`, jobId, jobId))
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", fmt.Sprintf("/api/composer/v2/compose/%v/metadata", jobId), ``, http.StatusInternalServerError, `
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/compose/%v/metadata", jobId), ``, http.StatusInternalServerError, `
|
||||
{
|
||||
"href": "/api/composer/v2/errors/1012",
|
||||
"href": "/api/image-builder-composer/v2/errors/1012",
|
||||
"id": "1012",
|
||||
"kind": "Error",
|
||||
"code": "COMPOSER-1012",
|
||||
"code": "IMAGE-BUILDER-COMPOSER-1012",
|
||||
"reason": "OSBuildJobResult does not have expected fields set"
|
||||
}`, "operation_id")
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ func TestComposeStatusFailure(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, wrksrv := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -307,7 +307,7 @@ func TestComposeStatusFailure(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
|
||||
|
|
@ -315,9 +315,9 @@ func TestComposeStatusFailure(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, "osbuild", jobType)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", fmt.Sprintf("/api/composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
{
|
||||
"href": "/api/composer/v2/compose/%v",
|
||||
"href": "/api/image-builder-composer/v2/compose/%v",
|
||||
"kind": "ComposeStatus",
|
||||
"id": "%v",
|
||||
"image_status": {"status": "building"}
|
||||
|
|
@ -325,9 +325,9 @@ func TestComposeStatusFailure(t *testing.T) {
|
|||
|
||||
err = wrksrv.FinishJob(token, nil)
|
||||
require.NoError(t, err)
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "GET", fmt.Sprintf("/api/composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/compose/%v", jobId), ``, http.StatusOK, fmt.Sprintf(`
|
||||
{
|
||||
"href": "/api/composer/v2/compose/%v",
|
||||
"href": "/api/image-builder-composer/v2/compose/%v",
|
||||
"kind": "ComposeStatus",
|
||||
"id": "%v",
|
||||
"image_status": {"status": "failure"}
|
||||
|
|
@ -340,7 +340,7 @@ func TestComposeCustomizations(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, _ := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"customizations": {
|
||||
|
|
@ -371,7 +371,7 @@ func TestComposeCustomizations(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ func TestImageTypes(t *testing.T) {
|
|||
defer os.RemoveAll(dir)
|
||||
srv, _ := newV2Server(t, dir)
|
||||
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -400,10 +400,10 @@ func TestImageTypes(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name, string(v2.ImageTypes_aws)), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -419,10 +419,10 @@ func TestImageTypes(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name, string(v2.ImageTypes_aws)), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -438,10 +438,10 @@ func TestImageTypes(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name, string(v2.ImageTypes_edge_commit)), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -457,10 +457,10 @@ func TestImageTypes(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name, string(v2.ImageTypes_edge_installer)), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -479,10 +479,10 @@ func TestImageTypes(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name, string(v2.ImageTypes_azure)), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
test.TestRoute(t, srv.Handler("/api/composer/v2"), false, "POST", "/api/composer/v2/compose", fmt.Sprintf(`
|
||||
test.TestRoute(t, srv.Handler("/api/image-builder-composer/v2"), false, "POST", "/api/image-builder-composer/v2/compose", fmt.Sprintf(`
|
||||
{
|
||||
"distribution": "%s",
|
||||
"image_requests":[{
|
||||
|
|
@ -500,7 +500,7 @@ func TestImageTypes(t *testing.T) {
|
|||
}]
|
||||
}`, test_distro.TestDistroName, test_distro.TestArch3Name, string(v2.ImageTypes_gcp)), http.StatusCreated, `
|
||||
{
|
||||
"href": "/api/composer/v2/compose",
|
||||
"href": "/api/image-builder-composer/v2/compose",
|
||||
"kind": "ComposeId"
|
||||
}`, "id")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -668,6 +668,11 @@ function sendCompose() {
|
|||
function waitForState() {
|
||||
local DESIRED_STATE="${1:-success}"
|
||||
local VERSION="${2:-v1}"
|
||||
local URL=https://localhost/api/composer/v1/compose/"$COMPOSE_ID"
|
||||
if [ "$VERSION" = "v2" ]; then
|
||||
URL=https://localhost/api/image-builder-composer/v2/compose/"$COMPOSE_ID"
|
||||
fi
|
||||
|
||||
while true
|
||||
do
|
||||
OUTPUT=$(curl \
|
||||
|
|
@ -676,7 +681,7 @@ function waitForState() {
|
|||
--cacert /etc/osbuild-composer/ca-crt.pem \
|
||||
--key /etc/osbuild-composer/client-key.pem \
|
||||
--cert /etc/osbuild-composer/client-crt.pem \
|
||||
https://localhost/api/composer/"$VERSION"/compose/"$COMPOSE_ID")
|
||||
"$URL")
|
||||
|
||||
COMPOSE_STATUS=$(echo "$OUTPUT" | jq -r '.image_status.status')
|
||||
UPLOAD_STATUS=$(echo "$OUTPUT" | jq -r '.image_status.upload_status.status')
|
||||
|
|
@ -969,7 +974,7 @@ function verifyInAWSS3() {
|
|||
--cacert /etc/osbuild-composer/ca-crt.pem \
|
||||
--key /etc/osbuild-composer/client-key.pem \
|
||||
--cert /etc/osbuild-composer/client-crt.pem \
|
||||
https://localhost/api/composer/v2/compose/"$COMPOSE_ID"/metadata | jq -r '.ostree_commit')
|
||||
https://localhost/api/image-builder-composer/v2/compose/"$COMPOSE_ID"/metadata | jq -r '.ostree_commit')
|
||||
|
||||
if [[ "${API_COMMIT_ID_V2}" != "${TAR_COMMIT_ID}" ]]; then
|
||||
echo "Commit ID returned from API v2 does not match Commit ID in archive 😠"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue