# Controller project management The Ick2 controller manages information about projects. Projects are things the controller builds. A project is described by a resource like this: EXAMPLE project resource { "project": "ick2-website", "pipelines": [ "setup-workspace", "build-website", "publish-website" ] } In other words, there are several things that define a project: * The `name`. This is used for referreing to the project in the API. * A list of pipelines. Each pipeline has a name, and sequence of actions that need to be taken. At the moment, each action is a shell command to be run. ## Managing projects First we test the controller API for managing projects, without building them. We start by starting an instance of the controller. SCENARIO managing projects GIVEN an access token for user with scopes ... uapi_pipelines_post ... uapi_projects_get ... uapi_projects_post ... uapi_projects_id_get ... uapi_projects_id_put ... uapi_projects_id_delete AND a running ick controller WHEN user makes request GET /projects THEN result has status code 200 AND body matches { "projects": [] } WHEN user makes request POST /pipelines with a valid token and body ... { ... "pipeline": "build", ... "actions": [ ... { "shell": "git clone git://repo src" }, ... { "shell": "mkdir html" }, ... { "shell": "ikiwiki src html" } ... ] ... } WHEN user makes request POST /projects with a valid token and body ... { ... "project": "foo/website", ... "pipelines": ["build"] ... } THEN result has status code 201 AND body matches ... { ... "project": "foo/website", ... "pipelines": ["build"], ... "next_build_id": null ... } AND controller state directory contains project foo/website Creating a new project with the same name is forbidden. WHEN user makes request POST /projects with a valid token and body ... { ... "project": "foo/website", ... "pipelines": [] ... } THEN result has status code 409 WHEN user makes request GET /projects THEN result has status code 200 AND body matches ... { ... "projects": [ ... { ... "project": "foo/website", ... "pipelines": ["build"], ... "next_build_id": null ... } ... ] ... } WHEN user stops ick controller GIVEN a running ick controller WHEN user makes request GET /projects/foo/website THEN result has status code 200 AND body matches ... { ... "project": "foo/website", ... "pipelines": ["build"], ... "next_build_id": null ... } WHEN user makes request PUT /projects/foo/website with a valid token ... and body ... { ... "project": "foo/website", ... "parameters": {"foo": "bar"}, ... "pipelines": ["build"] ... } THEN result has status code 200 AND body matches ... { ... "project": "foo/website", ... "parameters": {"foo": "bar"}, ... "pipelines": ["build"], ... "next_build_id": null ... } AND controller state directory contains project foo/website WHEN user makes request GET /projects/foo/website THEN result has status code 200 AND body matches ... { ... "project": "foo/website", ... "parameters": {"foo": "bar"}, ... "pipelines": ["build"], ... "next_build_id": null ... } WHEN user makes request DELETE /projects/foo/website THEN result has status code 200 WHEN user makes request GET /projects/foo/website THEN result has status code 404 WHEN user makes request PUT /projects/nosuchproject with a valid token and body ... { ... "project": "nosuchproject", ... "pipelines": [] ... } THEN result has status code 404 FINALLY stop ick controller