@@ -1096,6 +1096,63 @@ request:
1096
1096
Expect (buildRun ).To (BeComparableTo (desiredBuildRun ))
1097
1097
})
1098
1098
1099
+ It ("converts for spec a generated serviceAccount" , func () {
1100
+ // Create the yaml in v1alpha1
1101
+ buildRunTemplate := `kind: ConversionReview
1102
+ apiVersion: %s
1103
+ request:
1104
+ uid: 0000-0000-0000-0000
1105
+ desiredAPIVersion: %s
1106
+ objects:
1107
+ - apiVersion: shipwright.io/v1alpha1
1108
+ kind: BuildRun
1109
+ metadata:
1110
+ name: buildkit-run
1111
+ spec:
1112
+ buildRef:
1113
+ name: a_build
1114
+ serviceAccount:
1115
+ generate: true
1116
+ output:
1117
+ image: foobar
1118
+ `
1119
+ o := fmt .Sprintf (buildRunTemplate , apiVersion , desiredAPIVersion )
1120
+
1121
+ // Invoke the /convert webhook endpoint
1122
+ conversionReview , err := getConversionReview (o )
1123
+ Expect (err ).To (BeNil ())
1124
+ Expect (conversionReview .Response .Result .Status ).To (Equal (v1 .StatusSuccess ))
1125
+
1126
+ convertedObj , err := ToUnstructured (conversionReview )
1127
+ Expect (err ).To (BeNil ())
1128
+
1129
+ buildRun , err := toV1Beta1BuildRunObject (convertedObj )
1130
+ Expect (err ).To (BeNil ())
1131
+
1132
+ // Prepare our desired v1beta1 BuildRun
1133
+ desiredBuildRun := v1beta1.BuildRun {
1134
+ ObjectMeta : v1.ObjectMeta {
1135
+ Name : "buildkit-run" ,
1136
+ },
1137
+ TypeMeta : v1.TypeMeta {
1138
+ APIVersion : "shipwright.io/v1beta1" ,
1139
+ Kind : "BuildRun" ,
1140
+ },
1141
+ Spec : v1beta1.BuildRunSpec {
1142
+ Build : v1beta1.ReferencedBuild {
1143
+ Name : pointer .String ("a_build" ),
1144
+ },
1145
+ ServiceAccount : pointer .String (".generate" ),
1146
+ Output : & v1beta1.Image {
1147
+ Image : "foobar" ,
1148
+ },
1149
+ },
1150
+ }
1151
+
1152
+ // Use ComparableTo and assert the whole object
1153
+ Expect (buildRun ).To (BeComparableTo (desiredBuildRun ))
1154
+ })
1155
+
1099
1156
It ("converts for spec Build buildref" , func () {
1100
1157
// Create the yaml in v1alpha1
1101
1158
buildTemplate := `kind: ConversionReview
@@ -1215,6 +1272,7 @@ request:
1215
1272
Expect (buildRun ).To (BeComparableTo (desiredBuildRun ))
1216
1273
})
1217
1274
})
1275
+
1218
1276
Context ("for a BuildStrategy spec from v1beta1 to v1alpha1" , func () {
1219
1277
var desiredAPIVersion = "shipwright.io/v1alpha1"
1220
1278
It ("converts the strategy" , func () {
0 commit comments