-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
data_types.go
40 lines (32 loc) · 1.3 KB
/
data_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package v1alpha1
// Data is a data template
type Data struct {
// Source sources external data into a data template
Source DataSource `json:"source" protobuf:"bytes,1,opt,name=source"`
// Transformation applies a set of transformations
Transformation Transformation `json:"transformation" protobuf:"bytes,2,rep,name=transformation"`
}
func (ds *DataSource) GetArtifactIfNeeded() (*Artifact, bool) {
if ds.ArtifactPaths != nil {
return &ds.ArtifactPaths.Artifact, true
}
return nil, false
}
type Transformation []TransformationStep
type TransformationStep struct {
// Expression defines an expr expression to apply
Expression string `json:"expression" protobuf:"bytes,1,opt,name=expression"`
}
// DataSource sources external data into a data template
type DataSource struct {
// ArtifactPaths is a data transformation that collects a list of artifact paths
ArtifactPaths *ArtifactPaths `json:"artifactPaths,omitempty" protobuf:"bytes,1,opt,name=artifactPaths"`
}
// ArtifactPaths expands a step from a collection of artifacts
type ArtifactPaths struct {
// Artifact is the artifact location from which to source the artifacts, it can be a directory
Artifact `json:",inline" protobuf:"bytes,1,opt,name=artifact"`
}
type DataSourceProcessor interface {
ProcessArtifactPaths(*ArtifactPaths) (interface{}, error)
}