fabric8-platform icon indicating copy to clipboard operation
fabric8-platform copied to clipboard

create an Approval REST API

Open jstrachan opened this issue 7 years ago • 2 comments

we want to have a canonical service in Jenkinsfiles to do approvals and allow different environments to use different approval systems.

e.g. we want our Jenkinsfiles to do something like:

// lets wait for approval or timeout/fail if not
approve(namespace = "cheese", project = "beer", environment = "production", action = "promote")
 
// now promote to production
}

So we should create an Approval Service REST API and consumer contract. Then we can create a few implementations:

  • reuse the current chatops chat bot option
  • a noop (no approval)
  • plugin a Drools / jBPM solution: https://issues.jboss.org/browse/DROOLS-1355
  • a simple issue tracker implementation, e.g. using gitlab to raise an issue for approval and wait for the issue to be marked as fixed

jstrachan avatar Nov 04 '16 10:11 jstrachan

I guess we could even use a ThirdPartyResource for the Approval so apps could watch its status; though I worry about it being too easy for some bad app to update the TPR :) So a simple REST API to poll is maybe simpler ;)

jstrachan avatar Nov 04 '16 11:11 jstrachan

maybe the REST API should just be you POST some YAML/JSON key/value to the service URL and get back a Location header of the URL to GET to find the status of the approval (process instance ID / issue or whatever).

POST https://approver
Content-Type: text/yaml; charset=utf-8

namespace: "cheese"
project: "beer"
environment: "production"
action: "promote"

then the Location is returned to where to poll for the status:

HTTP/1.1 201 Created
Content-Length: 40
Content-Type: text/plain; charset=utf-8
Location: https://approver/approvals/1234

Then the client can GET the status at any time:

GET https://approver/approvals/1234

and the results could be something like

status: Pending
durationMillis: 23456
createdTime: ...

Where status is one of Pending, Approved, Rejected

At least that simple API would give us a head start until we need something more complex?

jstrachan avatar Nov 09 '16 12:11 jstrachan