@@ -3204,7 +3204,33 @@ func TestApplyTaskResults_EmbeddedExpression(t *testing.T) {
3204
3204
DisplayName : "Result value --> aResultValue" ,
3205
3205
},
3206
3206
}},
3207
- }} {
3207
+ },
3208
+ {
3209
+ name : "Test result substitution on embedded variable substitution expression - workspace.subPath" ,
3210
+ resolvedResultRefs : resources.ResolvedResultRefs {{
3211
+ Value : * v1 .NewStructuredValues ("aResultValue" ),
3212
+ ResultReference : v1.ResultRef {
3213
+ PipelineTask : "aTask" ,
3214
+ Result : "aResult" ,
3215
+ },
3216
+ FromTaskRun : "aTaskRun" ,
3217
+ }},
3218
+ targets : resources.PipelineRunState {{
3219
+ PipelineTask : & v1.PipelineTask {
3220
+ Name : "bTask" ,
3221
+ TaskRef : & v1.TaskRef {Name : "bTask" },
3222
+ Workspaces : []v1.WorkspacePipelineTaskBinding {{Name : "ws-1" , Workspace : "ws-1" , SubPath : "$(tasks.aTask.results.aResult)" }},
3223
+ },
3224
+ }},
3225
+ want : resources.PipelineRunState {{
3226
+ PipelineTask : & v1.PipelineTask {
3227
+ Name : "bTask" ,
3228
+ TaskRef : & v1.TaskRef {Name : "bTask" },
3229
+ Workspaces : []v1.WorkspacePipelineTaskBinding {{Name : "ws-1" , Workspace : "ws-1" , SubPath : "aResultValue" }},
3230
+ },
3231
+ }},
3232
+ },
3233
+ } {
3208
3234
t .Run (tt .name , func (t * testing.T ) {
3209
3235
resources .ApplyTaskResults (tt .targets , tt .resolvedResultRefs )
3210
3236
if d := cmp .Diff (tt .want , tt .targets ); d != "" {
@@ -4967,6 +4993,48 @@ func TestApplyParametersToWorkspaceBindings(t *testing.T) {
4967
4993
},
4968
4994
},
4969
4995
},
4996
+ {
4997
+ name : "pvc object params" ,
4998
+ ps : & v1.PipelineSpec {
4999
+ Params : []v1.ParamSpec {
5000
+ {Name : "pvc-object" , Type : v1 .ParamTypeObject , Properties : map [string ]v1.PropertySpec {
5001
+ "name" : {Type : v1 .ParamTypeString },
5002
+ }},
5003
+ },
5004
+ },
5005
+ pr : & v1.PipelineRun {
5006
+ Spec : v1.PipelineRunSpec {
5007
+ Params : []v1.Param {
5008
+ {Name : "pvc-object" , Value : v1.ParamValue {Type : v1 .ParamTypeObject , ObjectVal : map [string ]string {
5009
+ "name" : "pvc-object-value" ,
5010
+ }}},
5011
+ },
5012
+ Workspaces : []v1.WorkspaceBinding {
5013
+ {
5014
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
5015
+ ClaimName : "$(params.pvc-object.name)" ,
5016
+ },
5017
+ },
5018
+ },
5019
+ },
5020
+ },
5021
+ expectedPr : & v1.PipelineRun {
5022
+ Spec : v1.PipelineRunSpec {
5023
+ Params : []v1.Param {
5024
+ {Name : "pvc-object" , Value : v1.ParamValue {Type : v1 .ParamTypeObject , ObjectVal : map [string ]string {
5025
+ "name" : "pvc-object-value" ,
5026
+ }}},
5027
+ },
5028
+ Workspaces : []v1.WorkspaceBinding {
5029
+ {
5030
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
5031
+ ClaimName : "pvc-object-value" ,
5032
+ },
5033
+ },
5034
+ },
5035
+ },
5036
+ },
5037
+ },
4970
5038
}
4971
5039
4972
5040
for _ , tt := range testCases {
@@ -5219,6 +5287,83 @@ func TestApplyResultsToWorkspaceBindings(t *testing.T) {
5219
5287
},
5220
5288
},
5221
5289
},
5290
+ {
5291
+ name : "pvc object-result" ,
5292
+ trResults : map [string ][]v1.TaskRunResult {
5293
+ "task1" : {
5294
+ {
5295
+ Name : "pvc-object" ,
5296
+ Type : v1 .ResultsTypeObject ,
5297
+ Value : v1.ResultValue {Type : v1 .ParamTypeObject , ObjectVal : map [string ]string {
5298
+ "name" : "pvc-object-value" ,
5299
+ }},
5300
+ },
5301
+ },
5302
+ },
5303
+ pr : & v1.PipelineRun {
5304
+ Spec : v1.PipelineRunSpec {
5305
+ Workspaces : []v1.WorkspaceBinding {
5306
+ {
5307
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
5308
+ ClaimName : "$(tasks.task1.results.pvc-object.name)" ,
5309
+ },
5310
+ },
5311
+ },
5312
+ },
5313
+ },
5314
+ expectedPr : & v1.PipelineRun {
5315
+ Spec : v1.PipelineRunSpec {
5316
+ Workspaces : []v1.WorkspaceBinding {
5317
+ {
5318
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
5319
+ ClaimName : "pvc-object-value" ,
5320
+ },
5321
+ },
5322
+ },
5323
+ },
5324
+ },
5325
+ },
5326
+ {
5327
+ name : "pvc object-result - along with array-result (no effect)" ,
5328
+ trResults : map [string ][]v1.TaskRunResult {
5329
+ "task1" : {
5330
+ {
5331
+ Name : "pvc-object" ,
5332
+ Type : v1 .ResultsTypeObject ,
5333
+ Value : v1.ResultValue {Type : v1 .ParamTypeObject , ObjectVal : map [string ]string {
5334
+ "name" : "pvc-object-value" ,
5335
+ }},
5336
+ },
5337
+ {
5338
+ Name : "pvc-array" ,
5339
+ Type : v1 .ResultsTypeArray ,
5340
+ Value : v1.ResultValue {Type : v1 .ParamTypeArray , ArrayVal : []string {"name-1" , "name-2" }},
5341
+ },
5342
+ },
5343
+ },
5344
+ pr : & v1.PipelineRun {
5345
+ Spec : v1.PipelineRunSpec {
5346
+ Workspaces : []v1.WorkspaceBinding {
5347
+ {
5348
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
5349
+ ClaimName : "$(tasks.task1.results.pvc-object.name)" ,
5350
+ },
5351
+ },
5352
+ },
5353
+ },
5354
+ },
5355
+ expectedPr : & v1.PipelineRun {
5356
+ Spec : v1.PipelineRunSpec {
5357
+ Workspaces : []v1.WorkspaceBinding {
5358
+ {
5359
+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
5360
+ ClaimName : "pvc-object-value" ,
5361
+ },
5362
+ },
5363
+ },
5364
+ },
5365
+ },
5366
+ },
5222
5367
}
5223
5368
5224
5369
for _ , tc := range testCases {
0 commit comments