Skip to content

Commit

Permalink
Merge pull request #7 from wangkuiyi/doc
Browse files Browse the repository at this point in the history
Side by side
  • Loading branch information
wangkuiyi authored Dec 25, 2019
2 parents 2b59170 + 738e446 commit 8e84e9c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 14 deletions.
71 changes: 59 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,75 @@
# Fluid

Fluid is a Python package allowing users to write [Tekton Pipeline](https://github.com/tektoncd/pipeline) workflows in Python other than YAML.
Fluid is a Python package allowing users to write [Tekton](https://github.com/tektoncd/pipeline) workflows in Python other than YAML.

You can consider Fluid a programming langauge with a small subset of Python syntax.

- Only function definitions and function invocations.
- Only positional arguments, but no keyword (named) arguments.
- Functions have no return values. (Tekton doesn't support Task output parameters.)

When you run a Fluid program, which is indeed a Python program, it prints the YAML to standard output. You can then to submit the YAML to Tekton.
Here is an example. To the left is a Python program defining a Task and related TaskRun. To the right is the equivalent YAML file.

Here is an example Fluid program.
<table><tr><td valign=top>

```python
import fluid

@fluid.task
def echo_hello_world(hello, world="El mundo"):
'''Defines an example Tekton Task'''
fluid.step(image="ubuntu", cmd=["echo"], args=[hello])
fluid.step(image="ubuntu", cmd=["echo"], args=[world])

if __name__ == "__main__":
echo_hello_world("Aloha")
echo_hello_world("Aloha")
```

</td><td valign=top>

```yaml
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: echo-hello-world
spec:
inputs:
params:
- description: ''
name: hello
type: string
- default: El mundo
description: ''
name: world
type: string
steps:
- args:
- $(inputs.params.hello)
command:
- echo
image: ubuntu
name: example-py-12
- args:
- $(inputs.params.world)
command:
- echo
image: ubuntu
name: example-py-13
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: echo-hello-world-run
spec:
inputs:
params:
- name: hello
value: Aloha
taskRef:
name: echo_hello_world
```
</tr></td></table>
## Fluid as a Langauge
You can consider Fluid a programming langauge with a small subset of Python syntax.
- Only function definitions and function invocations.
- Only positional arguments, but no keyword (named) arguments.
- Functions have no return values. (Tekton doesn't support Task output parameters.)
When you run a Fluid program, which is indeed a Python program, it prints the YAML file, which, you can then to submit the YAML to Tekton.
3 changes: 1 addition & 2 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ def echo_hello_world(hello, world="El mundo"):
fluid.step(image="ubuntu", cmd=["echo"], args=[world])


if __name__ == "__main__":
echo_hello_world("Aloha")
echo_hello_world("Aloha")

0 comments on commit 8e84e9c

Please sign in to comment.