-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: and 1st-class support for expand and flatten
- Loading branch information
Showing
19 changed files
with
779 additions
and
190 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
type Expand struct{} | ||
|
||
func (m *Expand) getContainer(req getContainerReq) corev1.Container { | ||
return corev1.Container{ | ||
Name: CtrMain, | ||
Image: req.runnerImage, | ||
ImagePullPolicy: req.imagePullPolicy, | ||
Args: []string{"expand"}, | ||
VolumeMounts: []corev1.VolumeMount{req.volumeMount}, | ||
Resources: SmallResourceRequirements, | ||
} | ||
} |
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,18 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
type Flatten struct{} | ||
|
||
func (m *Flatten) getContainer(req getContainerReq) corev1.Container { | ||
return corev1.Container{ | ||
Name: CtrMain, | ||
Image: req.runnerImage, | ||
ImagePullPolicy: req.imagePullPolicy, | ||
Args: []string{"flatten"}, | ||
VolumeMounts: []corev1.VolumeMount{req.volumeMount}, | ||
Resources: SmallResourceRequirements, | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,36 @@ | ||
apiVersion: dataflow.argoproj.io/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
annotations: | ||
dataflow.argoproj.io/description: | | ||
This is an example of built-in flattening and expanding. | ||
dataflow.argoproj.io/name: Flatten and expand | ||
creationTimestamp: null | ||
name: flatten-expand | ||
spec: | ||
steps: | ||
- map: | | ||
bytes('{"foo": {"bar": "' + string(msg) + '"}}') | ||
name: generate | ||
sinks: | ||
- stan: | ||
subject: data | ||
sources: | ||
- cron: | ||
layout: "15:04:05" | ||
schedule: '*/3 * * * * *' | ||
- flatten: {} | ||
name: flatten | ||
sinks: | ||
- stan: | ||
subject: flattened | ||
sources: | ||
- stan: | ||
subject: data | ||
- expand: {} | ||
name: expand | ||
sinks: | ||
- log: {} | ||
sources: | ||
- stan: | ||
subject: flattened |
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
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,24 @@ | ||
package expand | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/doublerebel/bellows" | ||
|
||
"github.com/argoproj-labs/argo-dataflow/runner/util" | ||
) | ||
|
||
func Exec(ctx context.Context) error { | ||
return util.Do(ctx, func(msg []byte) ([][]byte, error) { | ||
v := make(map[string]interface{}) | ||
if err := json.Unmarshal(msg, &v); err != nil { | ||
return nil, err | ||
} | ||
if data, err := json.Marshal(bellows.Expand(v)); err != nil { | ||
return nil, err | ||
} else { | ||
return [][]byte{data}, nil | ||
} | ||
}) | ||
} |
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,24 @@ | ||
package flatten | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/doublerebel/bellows" | ||
|
||
"github.com/argoproj-labs/argo-dataflow/runner/util" | ||
) | ||
|
||
func Exec(ctx context.Context) error { | ||
return util.Do(ctx, func(msg []byte) ([][]byte, error) { | ||
v := make(map[string]interface{}) | ||
if err := json.Unmarshal(msg, &v); err != nil { | ||
return nil, err | ||
} | ||
if data, err := json.Marshal(bellows.Flatten(v)); err != nil { | ||
return nil, err | ||
} else { | ||
return [][]byte{data}, nil | ||
} | ||
}) | ||
} |
Oops, something went wrong.