Skip to content

Commit 0c5a5e8

Browse files
authored
feat: Allow users to specify image for code processor. Fixes #482 (#491)
Signed-off-by: Alex Collins <[email protected]>
1 parent 096e906 commit 0c5a5e8

File tree

13 files changed

+454
-354
lines changed

13 files changed

+454
-354
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Intermediate:
7474
* [Events interop](docs/EVENTS_INTEROP.md)
7575
* [Workflow interop](docs/WORKFLOW_INTEROP.md)
7676
* [Meta-data](docs/META.md)
77+
* [Idempotence](docs/IDEMPOTENCE.md)
7778

7879
Advanced
7980

api/v1alpha1/code.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ import (
77
)
88

99
type Code struct {
10-
Runtime Runtime `json:"runtime" protobuf:"bytes,4,opt,name=runtime,casttype=Runtime"`
11-
Source string `json:"source" protobuf:"bytes,3,opt,name=source"`
10+
Runtime Runtime `json:"runtime,omitempty" protobuf:"bytes,4,opt,name=runtime,casttype=Runtime"`
11+
// Image is used in preference to Runtime.
12+
Image string `json:"image,omitempty" protobuf:"bytes,5,opt,name=image"`
13+
Source string `json:"source" protobuf:"bytes,3,opt,name=source"`
1214
}
1315

1416
func (in Code) getContainer(req getContainerReq) corev1.Container {
17+
image := in.Image
18+
if image == "" {
19+
image = fmt.Sprintf(req.imageFormat, "dataflow-"+in.Runtime)
20+
}
1521
return containerBuilder{}.
1622
init(req).
17-
image(fmt.Sprintf(req.imageFormat, "dataflow-"+in.Runtime)).
23+
image(image).
1824
build()
1925
}

api/v1alpha1/code_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import (
77
)
88

99
func TestCode_getContainer(t *testing.T) {
10-
x := Code{
11-
Runtime: "my-runtime",
12-
}
13-
c := x.getContainer(getContainerReq{imageFormat: "fmt-%s"})
14-
assert.Equal(t, "fmt-dataflow-my-runtime", c.Image)
10+
t.Run("Runtime", func(t *testing.T) {
11+
x := Code{Runtime: "my-runtime"}
12+
c := x.getContainer(getContainerReq{imageFormat: "fmt-%s"})
13+
assert.Equal(t, "fmt-dataflow-my-runtime", c.Image)
14+
})
15+
t.Run("Runtime", func(t *testing.T) {
16+
x := Code{Image: "my-image"}
17+
c := x.getContainer(getContainerReq{})
18+
assert.Equal(t, "my-image", c.Image)
19+
})
1520
}

api/v1alpha1/generated.pb.go

Lines changed: 372 additions & 331 deletions
Large diffs are not rendered by default.

api/v1alpha1/generated.proto

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ spec:
720720
type: object
721721
code:
722722
properties:
723+
image:
724+
description: Image is used in preference to Runtime.
725+
type: string
723726
runtime:
724727
enum:
725728
- golang1-16
@@ -731,7 +734,6 @@ spec:
731734
source:
732735
type: string
733736
required:
734-
- runtime
735737
- source
736738
type: object
737739
container:
@@ -7907,6 +7909,9 @@ spec:
79077909
type: object
79087910
code:
79097911
properties:
7912+
image:
7913+
description: Image is used in preference to Runtime.
7914+
type: string
79107915
runtime:
79117916
enum:
79127917
- golang1-16
@@ -7918,7 +7923,6 @@ spec:
79187923
source:
79197924
type: string
79207925
required:
7921-
- runtime
79227926
- source
79237927
type: object
79247928
container:

config/crd/bases/dataflow.argoproj.io_pipelines.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ spec:
715715
type: object
716716
code:
717717
properties:
718+
image:
719+
description: Image is used in preference to Runtime.
720+
type: string
718721
runtime:
719722
enum:
720723
- golang1-16
@@ -726,7 +729,6 @@ spec:
726729
source:
727730
type: string
728731
required:
729-
- runtime
730732
- source
731733
type: object
732734
container:

config/crd/bases/dataflow.argoproj.io_steps.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ spec:
680680
type: object
681681
code:
682682
properties:
683+
image:
684+
description: Image is used in preference to Runtime.
685+
type: string
683686
runtime:
684687
enum:
685688
- golang1-16
@@ -691,7 +694,6 @@ spec:
691694
source:
692695
type: string
693696
required:
694-
- runtime
695697
- source
696698
type: object
697699
container:

config/default.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ spec:
720720
type: object
721721
code:
722722
properties:
723+
image:
724+
description: Image is used in preference to Runtime.
725+
type: string
723726
runtime:
724727
enum:
725728
- golang1-16
@@ -731,7 +734,6 @@ spec:
731734
source:
732735
type: string
733736
required:
734-
- runtime
735737
- source
736738
type: object
737739
container:
@@ -7907,6 +7909,9 @@ spec:
79077909
type: object
79087910
code:
79097911
properties:
7912+
image:
7913+
description: Image is used in preference to Runtime.
7914+
type: string
79107915
runtime:
79117916
enum:
79127917
- golang1-16
@@ -7918,7 +7923,6 @@ spec:
79187923
source:
79197924
type: string
79207925
required:
7921-
- runtime
79227926
- source
79237927
type: object
79247928
container:

config/dev.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ spec:
720720
type: object
721721
code:
722722
properties:
723+
image:
724+
description: Image is used in preference to Runtime.
725+
type: string
723726
runtime:
724727
enum:
725728
- golang1-16
@@ -731,7 +734,6 @@ spec:
731734
source:
732735
type: string
733736
required:
734-
- runtime
735737
- source
736738
type: object
737739
container:
@@ -7907,6 +7909,9 @@ spec:
79077909
type: object
79087910
code:
79097911
properties:
7912+
image:
7913+
description: Image is used in preference to Runtime.
7914+
type: string
79107915
runtime:
79117916
enum:
79127917
- golang1-16
@@ -7918,7 +7923,6 @@ spec:
79187923
source:
79197924
type: string
79207925
required:
7921-
- runtime
79227926
- source
79237927
type: object
79247928
container:

0 commit comments

Comments
 (0)