# Controller pipeline management The Ick2 controller manages information about named pipelines. Pipelines are sequences of steps to achieve part of a project build. They're described like resources like this: EXAMPLE pipeline resource { "pipeline": "build-website", "parameters": { "foo": "bar" }, "actions": [ { "shell": "git clone git://git.liw.fi/ick2-website src", "where": "host" }, { "shell": "cd src && ikiwiki --setup ikiwiki.setup", "where": "host" }, { "shell": "cd html && rsync -a --delete . server::/srv/http/ick2/.", "where": "host" } ] } In other words, there are several things that define a pipeline: * The `name`. This is used for referreing to the pipeline in the API. * A set of parameters, which are currently ignored. * A sequence of actions. At the moment, each action is a shell command to be run, but that will change later. ## Managing pipelines First we test the controller API for managing pipelines, without running them. We start by starting an instance of the controller. SCENARIO managing pipelines GIVEN an access token for user with scopes ... uapi_pipelines_get ... uapi_pipelines_post ... uapi_pipelines_id_get ... uapi_pipelines_id_put ... uapi_pipelines_id_delete AND a running ick controller WHEN user makes request GET /pipelines THEN result has status code 200 AND body matches { "pipelines": [] } WHEN user makes request POST /pipelines with a valid token and body ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "git clone git://repo src" }, ... { "where": "host", "shell": "mkdir html" }, ... { "where": "host", "shell": "ikiwiki src html" } ... ] ... } THEN result has status code 201 AND body matches ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "git clone git://repo src" }, ... { "where": "host", "shell": "mkdir html" }, ... { "where": "host", "shell": "ikiwiki src html" } ... ] ... } Creating a new pipeline with the same name is forbidden. WHEN user makes request POST /pipelines with a valid token and body ... { ... "pipeline": "foo/build_website" ... } THEN result has status code 409 WHEN user makes request GET /pipelines THEN result has status code 200 AND body matches ... { ... "pipelines": [ ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "git clone git://repo src" }, ... { "where": "host", "shell": "mkdir html" }, ... { "where": "host", "shell": "ikiwiki src html" } ... ] ... } ... ] ... } WHEN user stops ick controller GIVEN a running ick controller WHEN user makes request GET /pipelines/foo/build_website THEN result has status code 200 AND body matches ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "git clone git://repo src" }, ... { "where": "host", "shell": "mkdir html" }, ... { "where": "host", "shell": "ikiwiki src html" } ... ] ... } WHEN user makes request PUT /pipelines/build_websitte with a valid token ... and body ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "build-it" } ... ] ... } THEN result has status code 200 AND body matches ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "build-it" } ... ] ... } WHEN user makes request GET /pipelines/foo/build_website THEN result has status code 200 AND body matches ... { ... "pipeline": "foo/build_website", ... "actions": [ ... { "where": "host", "shell": "build-it" } ... ] ... } WHEN user makes request DELETE /pipelines/foo/build_website THEN result has status code 200 WHEN user makes request GET /pipelines/foo/build_website THEN result has status code 404 WHEN user makes request PUT /pipelines/doesnotexist with a valid token and body ... { ... "pipeline": "doesnotexist" ... } THEN result has status code 404 FINALLY stop ick controller