forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements in the TaskRun controller the logic to provide the cloud event pipeline resource. This commits puts together the API, cloud event helper and resource definition from four pull requests: - tektoncd#1090 - tektoncd#1091 - tektoncd#1092 TBD: Test for interaction with the image digest export It adds unit tests for the new code and one E2E YAML test. The YAML test runs a simple http server that can receive the cloudevent for test purposes. The list of cloud events to be sent is added to the TaskRun status and processed by the TaskRun controller once the pod associated to the TaskRun completes its execution. The `isDone` definition of the TaskRun is not altered, the reconciler checks for events to be sent once the TaskRun.isDone is true. Retries are not implemented yet in the sense that every scheduled event will be attempted exactly once, but it may be that those attempts happen across different invocations of Reconcile. Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
- Loading branch information
Showing
6 changed files
with
485 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: sink | ||
namespace: default | ||
spec: | ||
selector: | ||
app: cloudevent | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
app: cloudevent | ||
name: message-sink | ||
namespace: default | ||
spec: | ||
containers: | ||
- env: | ||
- name: PORT | ||
value: "8080" | ||
name: cloudeventlistener | ||
image: python:3-alpine | ||
imagePullPolicy: IfNotPresent | ||
command: ["/bin/sh"] | ||
args: | ||
- -ce | ||
- | | ||
cat <<EOF | python | ||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
class PostHandler(BaseHTTPRequestHandler): | ||
def do_POST(self): | ||
self.send_response(200) | ||
self.send_header('Content-type', 'text/html') | ||
self.end_headers() | ||
self.wfile.write("<html><body><h1>POST!</h1></body></html>") | ||
if __name__ == "__main__": | ||
httpd = HTTPServer(('', $PORT), PostHandler) | ||
print('Starting httpd...') | ||
httpd.serve_forever() | ||
EOF | ||
ports: | ||
- containerPort: 8080 | ||
name: user-port | ||
protocol: TCP | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: to-message-sink | ||
spec: | ||
type: cloudEvent | ||
params: | ||
- name: targetURI | ||
value: http://sink.default:8080 | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: rules-branch | ||
spec: | ||
type: git | ||
params: | ||
- name: revision | ||
value: master | ||
- name: url | ||
value: https://github.com/bazelbuild/rules_docker | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: send-cloud-event-task | ||
spec: | ||
inputs: | ||
resources: | ||
- name: workspace | ||
type: git | ||
outputs: | ||
resources: | ||
- name: notification | ||
type: cloudEvent | ||
steps: | ||
- name: list | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: ['-c', 'ls -al /workspace'] | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: TaskRun | ||
metadata: | ||
name: send-cloud-event | ||
spec: | ||
inputs: | ||
resources: | ||
- name: workspace | ||
resourceRef: | ||
name: rules-branch | ||
outputs: | ||
resources: | ||
- name: notification | ||
resourceRef: | ||
name: to-message-sink | ||
taskRef: | ||
name: send-cloud-event-task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.