@@ -82,6 +82,10 @@ request:
82
82
strategy:
83
83
name: %s
84
84
kind: %s
85
+ status:
86
+ message: "all validations succeeded"
87
+ reason: Succeeded
88
+ registered: "True"
85
89
`
86
90
o := fmt .Sprintf (buildTemplate , apiVersion ,
87
91
desiredAPIVersion , strategyName , strategyKind )
@@ -122,6 +126,11 @@ request:
122
126
Kind : (* v1alpha1 .BuildStrategyKind )(& strategyKind ),
123
127
},
124
128
},
129
+ Status : v1alpha1.BuildStatus {
130
+ Message : pointer .String ("all validations succeeded" ),
131
+ Reason : v1alpha1 .BuildReasonPtr (v1alpha1 .SucceedStatus ),
132
+ Registered : v1alpha1 .ConditionStatusPtr (corev1 .ConditionTrue ),
133
+ },
125
134
}
126
135
127
136
// Use ComparableTo and assert the whole object
@@ -1029,6 +1038,154 @@ request:
1029
1038
// Use ComparableTo and assert the whole object
1030
1039
Expect (buildRun ).To (BeComparableTo (desiredBuildRun ))
1031
1040
})
1041
+
1042
+ It ("converts for status" , func () {
1043
+ // Create the yaml in v1beta1
1044
+ buildTemplate := `kind: ConversionReview
1045
+ apiVersion: %s
1046
+ request:
1047
+ uid: 0000-0000-0000-0000
1048
+ desiredAPIVersion: %s
1049
+ objects:
1050
+ - apiVersion: shipwright.io/v1beta1
1051
+ kind: BuildRun
1052
+ metadata:
1053
+ name: buildkit-run
1054
+ spec:
1055
+ build:
1056
+ name: a_build
1057
+ source:
1058
+ type: Local
1059
+ local:
1060
+ name: foobar_local
1061
+ timeout: 1m
1062
+ status:
1063
+ buildSpec:
1064
+ output:
1065
+ image: somewhere
1066
+ pushSecret: some-secret
1067
+ paramValues:
1068
+ - name: dockerfile
1069
+ value: Dockerfile
1070
+ source:
1071
+ git:
1072
+ url: https://github.com/shipwright-io/sample-go
1073
+ type: Git
1074
+ strategy:
1075
+ kind: ClusterBuildStrategy
1076
+ name: buildkit
1077
+ timeout: 10m0s
1078
+ completionTime: "2023-10-17T07:35:10Z"
1079
+ conditions:
1080
+ - lastTransitionTime: "2023-10-17T07:35:10Z"
1081
+ message: All Steps have completed executing
1082
+ reason: Succeeded
1083
+ status: "True"
1084
+ type: Succeeded
1085
+ output:
1086
+ digest: sha256:9befa6f5f7142a5bf92174b54bb6e0a1dd04e5252aa9dc8f6962f6da966f68a8
1087
+ source:
1088
+ git:
1089
+ commitAuthor: somebody
1090
+ commitSha: 6a45e68454ca0f319b1a82c65bea09a10fa9eec6
1091
+ startTime: "2023-10-17T07:31:55Z"
1092
+ taskRunName: buildkit-run-n5sxr
1093
+ `
1094
+ o := fmt .Sprintf (buildTemplate , apiVersion ,
1095
+ desiredAPIVersion )
1096
+
1097
+ // Invoke the /convert webhook endpoint
1098
+ conversionReview , err := getConversionReview (o )
1099
+ Expect (err ).To (BeNil ())
1100
+ Expect (conversionReview .Response .Result .Status ).To (Equal (v1 .StatusSuccess ))
1101
+
1102
+ convertedObj , err := ToUnstructured (conversionReview )
1103
+ Expect (err ).To (BeNil ())
1104
+
1105
+ buildRun , err := toV1Alpha1BuildRunObject (convertedObj )
1106
+ Expect (err ).To (BeNil ())
1107
+
1108
+ // Prepare our desired v1alpha1 BuildRun
1109
+ completionTime , err := time .Parse (time .RFC3339 , "2023-10-17T07:35:10Z" )
1110
+ Expect (err ).To (BeNil ())
1111
+ startTime , err := time .Parse (time .RFC3339 , "2023-10-17T07:31:55Z" )
1112
+ Expect (err ).To (BeNil ())
1113
+ buildStrategyKind := v1alpha1 .BuildStrategyKind (v1alpha1 .ClusterBuildStrategyKind )
1114
+ desiredBuildRun := v1alpha1.BuildRun {
1115
+ ObjectMeta : v1.ObjectMeta {
1116
+ Name : "buildkit-run" ,
1117
+ },
1118
+ TypeMeta : v1.TypeMeta {
1119
+ APIVersion : "shipwright.io/v1alpha1" ,
1120
+ Kind : "BuildRun" ,
1121
+ },
1122
+ Spec : v1alpha1.BuildRunSpec {
1123
+ BuildRef : & v1alpha1.BuildRef {
1124
+ Name : "a_build" ,
1125
+ },
1126
+ Sources : []v1alpha1.BuildSource {
1127
+ {
1128
+ Name : "foobar_local" ,
1129
+ Type : v1alpha1 .LocalCopy ,
1130
+ Timeout : & v1.Duration {
1131
+ Duration : 1 * time .Minute ,
1132
+ },
1133
+ },
1134
+ },
1135
+ ServiceAccount : & v1alpha1.ServiceAccount {},
1136
+ },
1137
+ Status : v1alpha1.BuildRunStatus {
1138
+ BuildSpec : & v1alpha1.BuildSpec {
1139
+ Source : v1alpha1.Source {
1140
+ URL : pointer .String ("https://github.com/shipwright-io/sample-go" ),
1141
+ },
1142
+ Dockerfile : pointer .String ("Dockerfile" ),
1143
+ Output : v1alpha1.Image {
1144
+ Image : "somewhere" ,
1145
+ Credentials : & corev1.LocalObjectReference {
1146
+ Name : "some-secret" ,
1147
+ },
1148
+ },
1149
+ Strategy : v1alpha1.Strategy {
1150
+ Kind : & buildStrategyKind ,
1151
+ Name : "buildkit" ,
1152
+ },
1153
+ Timeout : & v1.Duration {
1154
+ Duration : 10 * time .Minute ,
1155
+ },
1156
+ },
1157
+ CompletionTime : & v1.Time {
1158
+ Time : completionTime ,
1159
+ },
1160
+ Conditions : v1alpha1.Conditions {{
1161
+ LastTransitionTime : v1.Time {
1162
+ Time : completionTime ,
1163
+ },
1164
+ Message : "All Steps have completed executing" ,
1165
+ Reason : "Succeeded" ,
1166
+ Status : corev1 .ConditionTrue ,
1167
+ Type : v1alpha1 .Succeeded ,
1168
+ }},
1169
+ LatestTaskRunRef : pointer .String ("buildkit-run-n5sxr" ),
1170
+ Output : & v1alpha1.Output {
1171
+ Digest : "sha256:9befa6f5f7142a5bf92174b54bb6e0a1dd04e5252aa9dc8f6962f6da966f68a8" ,
1172
+ },
1173
+ Sources : []v1alpha1.SourceResult {{
1174
+ Name : "default" ,
1175
+ Git : & v1alpha1.GitSourceResult {
1176
+ CommitAuthor : "somebody" ,
1177
+ CommitSha : "6a45e68454ca0f319b1a82c65bea09a10fa9eec6" ,
1178
+ },
1179
+ }},
1180
+ StartTime : & v1.Time {
1181
+ Time : startTime ,
1182
+ },
1183
+ },
1184
+ }
1185
+
1186
+ // Use ComparableTo and assert the whole object
1187
+ Expect (buildRun ).To (BeComparableTo (desiredBuildRun ))
1188
+ })
1032
1189
})
1033
1190
Context ("for a BuildRun CR from v1alpha1 to v1beta1" , func () {
1034
1191
var desiredAPIVersion = "shipwright.io/v1beta1"
0 commit comments