Skip to content

Commit

Permalink
TEP-0118: Update Pipeline Conversion for Matrix Include Parameters
Browse files Browse the repository at this point in the history
This commit updates Pipeline Conversion to convert Matrix Include Parameters

Note: This feature is still in preview mode.
  • Loading branch information
EmmaMunley authored and tekton-robot committed Mar 11, 2023
1 parent bb8068f commit 808c7fe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
17 changes: 17 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ func (m *Matrix) convertTo(ctx context.Context, sink *v1.Matrix) {
param.convertTo(ctx, &new)
sink.Params = append(sink.Params, new)
}
for i, include := range m.Include {
sink.Include = append(sink.Include, v1.MatrixInclude{Name: include.Name})
for _, param := range include.Params {
newIncludeParam := v1.Param{}
param.convertTo(ctx, &newIncludeParam)
sink.Include[i].Params = append(sink.Include[i].Params, newIncludeParam)
}
}
}

func (m *Matrix) convertFrom(ctx context.Context, source v1.Matrix) {
Expand All @@ -267,6 +275,15 @@ func (m *Matrix) convertFrom(ctx context.Context, source v1.Matrix) {
new.convertFrom(ctx, param)
m.Params = append(m.Params, new)
}

for i, include := range source.Include {
m.Include = append(m.Include, MatrixInclude{Name: include.Name})
for _, p := range include.Params {
new := Param{}
new.convertFrom(ctx, p)
m.Include[i].Params = append(m.Include[i].Params, new)
}
}
}

func (pr PipelineResult) convertTo(ctx context.Context, sink *v1.PipelineResult) {
Expand Down
12 changes: 10 additions & 2 deletions pkg/apis/pipeline/v1beta1/pipeline_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,21 @@ func TestPipelineConversion(t *testing.T) {
},
}},
Matrix: &v1beta1.Matrix{
Params: []v1beta1.Param{{
Params: v1beta1.Params{{
Name: "a-param",
Value: v1beta1.ParamValue{
Type: v1beta1.ParamTypeArray,
ArrayVal: []string{"$(params.baz)", "and", "$(params.foo-is-baz)"},
},
}}},
}},
Include: []v1beta1.MatrixInclude{{
Name: "baz",
Params: v1beta1.Params{{
Name: "a-param", Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeString, StringVal: "$(params.baz)"},
}, {
Name: "flags", Value: v1beta1.ParamValue{Type: v1beta1.ParamTypeString, StringVal: "-cover -v"}}},
}},
},
Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{
Name: "my-task-workspace",
Workspace: "source",
Expand Down

0 comments on commit 808c7fe

Please sign in to comment.