Skip to content

Commit

Permalink
feat: add command to GitStep in Python DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Jul 21, 2021
1 parent 003d94e commit 18815b5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 3 additions & 4 deletions docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,10 @@ For a pipeline to terminate one of two things must happen:
kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/argo-dataflow/main/examples/107-completion-pipeline.yaml
```

### [terminator](https://raw.githubusercontent.com/argoproj-labs/argo-dataflow/main/examples/107-terminator-pipeline.yaml)

This example demostrates having a terminator step, and then terminating other steps
using different terminations strategies.
### [107-terminator](https://raw.githubusercontent.com/argoproj-labs/argo-dataflow/main/examples/107-terminator-pipeline.yaml)

This example demonstrates having a terminator step, and then terminating other steps
using different terminations strategies.

```
kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/argo-dataflow/main/examples/107-terminator-pipeline.yaml
Expand Down
14 changes: 9 additions & 5 deletions dsls/python/argo_dataflow/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,28 @@ def dump(self):


class GitStep(Step):
def __init__(self, name, url, branch, path, image, sources=[], env=None, terminator=False):
def __init__(self, name, url, branch, path, image, sources=[], env=None, terminator=False, command=None):
super().__init__(name, sources=sources, terminator=terminator)
self._url = url
self._branch = branch
self._path = path
self._image = image
self._env = env
self._command = command

def dump(self):
x = super().dump()
x['git'] = {
y = {
'url': self._url,
'branch': self._branch,
'path': self._path,
'image': self._image
}
if self._command:
y['command'] = self._command
if self._env:
x['git']['env'] = self._env
y['env'] = self._env
x['git'] = y
return x


Expand Down Expand Up @@ -414,8 +418,8 @@ def expand(self, name):
def filter(self, name, filter):
return FilterStep(name, filter, sources=[self])

def git(self, name, url, branch, path, image, env=None):
return GitStep(name, url, branch, path, image, sources=[self], env=env)
def git(self, name, url, branch, path, image, env=None, command=None):
return GitStep(name, url, branch, path, image, sources=[self], env=env, command=command)

def group(self, name, key, format, endOfGroup, storage):
return GroupStep(name, key, format, endOfGroup, storage, sources=[self])
Expand Down
2 changes: 1 addition & 1 deletion examples/106-git-pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.step(
(kafka('input-topic')
.git('main', 'https://github.com/argoproj-labs/argo-dataflow', 'main', 'examples/git', 'golang:1.16',
env=[{'name': "GOCACHE", 'value': "/tmp/.gocache"}])
env=[{'name': "GOCACHE", 'value': "/tmp/.gocache"}], command=["go", "run", "."])
.kafka('output-topic')
))
.save())
4 changes: 4 additions & 0 deletions examples/106-git-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ spec:
steps:
- git:
branch: main
command:
- go
- run
- .
env:
- name: GOCACHE
value: /tmp/.gocache
Expand Down

0 comments on commit 18815b5

Please sign in to comment.