Skip to content

Commit 6687b1f

Browse files
authored
[mod] postrun, prerun API에 tektonTaskParam을 body request로 받아 적용 (#404)
1 parent 149976e commit 6687b1f

File tree

9 files changed

+312
-141
lines changed

9 files changed

+312
-141
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Current Operator version
2-
VERSION ?= v0.6.2
2+
VERSION ?= v0.6.3
33
REGISTRY ?= tmaxcloudck
44

55
# Image URL to use all building/pushing image targets

api/v1/integrationconfig_types.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,28 @@ const (
292292
// IntegrationConfigAPIReqRunPreBody is a body struct for IntegrationConfig's api request
293293
// +kubebuilder:object:generate=false
294294
type IntegrationConfigAPIReqRunPreBody struct {
295-
BaseBranch string `json:"base_branch"`
296-
HeadBranch string `json:"head_branch"`
295+
BaseBranch string `json:"base_branch"`
296+
HeadBranch string `json:"head_branch"`
297+
AddTektonTaskParams []AddTektonTaskParam `json:"addTektonTaskParams,omitempty"`
297298
}
298299

299300
// IntegrationConfigAPIReqRunPostBody is a body struct for IntegrationConfig's api request
300301
// +kubebuilder:object:generate=false
301302
type IntegrationConfigAPIReqRunPostBody struct {
302-
Branch string `json:"branch"`
303+
Branch string `json:"branch"`
304+
AddTektonTaskParams []AddTektonTaskParam `json:"addTektonTaskParams,omitempty"`
305+
}
306+
307+
// AddTektonTaskParam represents additional Tekton task parameters
308+
type AddTektonTaskParam struct {
309+
JobName string `json:"jobName"`
310+
TektonTask []TektonTaskDef `json:"tektonTask"`
311+
}
312+
313+
// TektonTaskDef represents a definition for a Tekton task
314+
type TektonTaskDef struct {
315+
Name string `json:"name"`
316+
StringVal string `json:"stringVal"`
303317
}
304318

305319
// IntegrationConfigAPIReqWebhookURL is a body struct for IntegrationConfig's api request

api/v1/zz_generated.deepcopy.go

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ spec:
8484
containers:
8585
- command:
8686
- /controller
87-
image: docker.io/tmaxcloudck/cicd-operator:v0.6.2
87+
image: docker.io/tmaxcloudck/cicd-operator:v0.6.3
8888
imagePullPolicy: Always
8989
name: manager
9090
env:
@@ -171,7 +171,7 @@ spec:
171171
containers:
172172
- command:
173173
- /blocker
174-
image: docker.io/tmaxcloudck/cicd-blocker:v0.6.2
174+
image: docker.io/tmaxcloudck/cicd-blocker:v0.6.3
175175
imagePullPolicy: Always
176176
name: manager
177177
resources:
@@ -231,7 +231,7 @@ spec:
231231
containers:
232232
- command:
233233
- /webhook
234-
image: docker.io/tmaxcloudck/cicd-webhook:v0.6.2
234+
image: docker.io/tmaxcloudck/cicd-webhook:v0.6.3
235235
imagePullPolicy: Always
236236
name: manager
237237
resources:
@@ -291,7 +291,7 @@ spec:
291291
containers:
292292
- command:
293293
- /apiserver
294-
image: docker.io/tmaxcloudck/cicd-api-server:v0.6.2
294+
image: docker.io/tmaxcloudck/cicd-api-server:v0.6.3
295295
imagePullPolicy: Always
296296
name: manager
297297
resources:

go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ require (
2222
sigs.k8s.io/controller-runtime v0.10.2
2323
)
2424

25+
require (
26+
github.com/fatih/color v1.12.0 // indirect
27+
github.com/gobuffalo/flect v0.2.3 // indirect
28+
github.com/mattn/go-colorable v0.1.8 // indirect
29+
github.com/mattn/go-isatty v0.0.12 // indirect
30+
golang.org/x/mod v0.4.2 // indirect
31+
golang.org/x/tools v0.1.5 // indirect
32+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
33+
sigs.k8s.io/controller-tools v0.7.0 // indirect
34+
)
35+
2536
require (
2637
cloud.google.com/go v0.83.0 // indirect
2738
github.com/PuerkitoBio/purell v1.1.1 // indirect

go.sum

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQL
373373
github.com/evanphx/json-patch/v5 v5.5.0 h1:bAmFiUJ+o0o2B4OiTFeE3MqCOtyo+jjPP9iZ0VRxYUc=
374374
github.com/evanphx/json-patch/v5 v5.5.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4=
375375
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
376+
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
377+
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
376378
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
377379
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
378380
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
@@ -467,6 +469,7 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
467469
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
468470
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
469471
github.com/gobuffalo/flect v0.2.2/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc=
472+
github.com/gobuffalo/flect v0.2.3 h1:f/ZukRnSNA/DUpSNDadko7Qc0PhGvsew35p/2tu+CRY=
470473
github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc=
471474
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
472475
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
@@ -733,8 +736,12 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
733736
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
734737
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
735738
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
739+
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
740+
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
736741
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
737742
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
743+
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
744+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
738745
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
739746
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
740747
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@@ -817,6 +824,7 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
817824
github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
818825
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
819826
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
827+
github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
820828
github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU=
821829
github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
822830
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
@@ -1677,12 +1685,10 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
16771685
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
16781686
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
16791687
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1680-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16811688
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16821689
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
16831690
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16841691
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
1685-
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
16861692
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
16871693
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
16881694
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
@@ -1778,6 +1784,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyz
17781784
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
17791785
sigs.k8s.io/controller-runtime v0.10.2 h1:jW8qiY+yMnnPx6O9hu63tgcwaKzd1yLYui+mpvClOOc=
17801786
sigs.k8s.io/controller-runtime v0.10.2/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY=
1787+
sigs.k8s.io/controller-tools v0.7.0 h1:iZIz1vEcavyEfxjcTLs1WH/MPf4vhPCtTKhoHqV8/G0=
1788+
sigs.k8s.io/controller-tools v0.7.0/go.mod h1:bpBAo0VcSDDLuWt47evLhMLPxRPxMDInTEH/YbdeMK0=
17811789
sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
17821790
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
17831791
sigs.k8s.io/structured-merge-diff/v4 v4.0.3/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=

hack/release-manifest.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ for target in "${TARGETS[@]}"; do
5252
append_target "$target"
5353
done
5454

55-
sed -i "s/tmaxcloudck\/cicd-operator:latest/$REGISTRY\/cicd-operator:$VERSION/g" "$RELEASE_MANIFEST"
56-
sed -i "s/tmaxcloudck\/cicd-blocker:latest/$REGISTRY\/cicd-blocker:$VERSION/g" "$RELEASE_MANIFEST"
57-
sed -i "s/tmaxcloudck\/cicd-webhook:latest/$REGISTRY\/cicd-webhook:$VERSION/g" "$RELEASE_MANIFEST"
58-
sed -i "s/tmaxcloudck\/cicd-api-server:latest/$REGISTRY\/cicd-api-server:$VERSION/g" "$RELEASE_MANIFEST"
55+
sed -i "s|tmaxcloudck/cicd-operator:latest|$REGISTRY/cicd-operator:$VERSION|g" "$RELEASE_MANIFEST"
56+
sed -i "s|tmaxcloudck/cicd-blocker:latest|$REGISTRY/cicd-blocker:$VERSION|g" "$RELEASE_MANIFEST"
57+
sed -i "s|tmaxcloudck/cicd-webhook:latest|$REGISTRY/cicd-webhook:$VERSION|g" "$RELEASE_MANIFEST"
58+
sed -i "s|tmaxcloudck/cicd-api-server:latest|$REGISTRY/cicd-api-server:$VERSION|g" "$RELEASE_MANIFEST"

pkg/apiserver/apis/v1/integrationconfigs/run.go

Lines changed: 118 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package integrationconfigs
1919
import (
2020
"context"
2121
"encoding/json"
22+
"errors"
2223
"fmt"
23-
"io"
2424
"net/http"
2525
"regexp"
2626

@@ -93,17 +93,32 @@ func (h *handler) runHandler(w http.ResponseWriter, req *http.Request, et git.Ev
9393
},
9494
}
9595

96+
userReqPre := &cicdv1.IntegrationConfigAPIReqRunPreBody{}
97+
userReqPost := &cicdv1.IntegrationConfigAPIReqRunPostBody{}
98+
9699
switch et {
97100
case git.EventTypePullRequest:
98-
pr, err := buildPullRequestWebhook(req.Body, userEscaped)
101+
decoder := json.NewDecoder(req.Body)
102+
if err := decoder.Decode(userReqPre); err != nil {
103+
log.Info(err.Error())
104+
_ = utils.RespondError(w, http.StatusBadRequest, fmt.Sprintf("req: %s, cannot build pull_request webhook", reqID))
105+
return
106+
}
107+
pr, err := buildPullRequestWebhook(userReqPre, userEscaped)
99108
if err != nil {
100109
log.Info(err.Error())
101110
_ = utils.RespondError(w, http.StatusBadRequest, fmt.Sprintf("req: %s, cannot build pull_request webhook", reqID))
102111
return
103112
}
104113
wh.PullRequest = pr
105114
case git.EventTypePush:
106-
push, err := buildPushWebhook(req.Body)
115+
decoder := json.NewDecoder(req.Body)
116+
if err := decoder.Decode(userReqPost); err != nil {
117+
log.Info(err.Error())
118+
_ = utils.RespondError(w, http.StatusBadRequest, fmt.Sprintf("req: %s, cannot build pull_request webhook", reqID))
119+
return
120+
}
121+
push, err := buildPushWebhook(userReqPost)
107122
if err != nil {
108123
log.Info(err.Error())
109124
_ = utils.RespondError(w, http.StatusBadRequest, fmt.Sprintf("req: %s, cannot build push webhook", reqID))
@@ -115,6 +130,26 @@ func (h *handler) runHandler(w http.ResponseWriter, req *http.Request, et git.Ev
115130
Name: fmt.Sprintf("trigger-%s-end", userEscaped),
116131
}
117132

133+
// Update IntegrationConfig based on the request
134+
switch et {
135+
case git.EventTypePullRequest:
136+
updatedIC, err := updateIntegrationConfigPre(ic, userReqPre, et)
137+
if err != nil {
138+
log.Info(err.Error())
139+
_ = utils.RespondError(w, http.StatusBadRequest, "cannot update pull_request integrationconfig. please check jobName is valid")
140+
return
141+
}
142+
ic = updatedIC
143+
case git.EventTypePush:
144+
updatedIC, err := updateIntegrationConfigPost(ic, userReqPost, et)
145+
if err != nil {
146+
log.Info(err.Error())
147+
_ = utils.RespondError(w, http.StatusBadRequest, "cannot update push integrationconfig. please check jobName is valid")
148+
return
149+
}
150+
ic = updatedIC
151+
}
152+
118153
// Trigger Run!
119154
if err := server.HandleEvent(wh, ic, "dispatcher"); err != nil {
120155
log.Info(err.Error())
@@ -125,13 +160,87 @@ func (h *handler) runHandler(w http.ResponseWriter, req *http.Request, et git.Ev
125160
_ = utils.RespondJSON(w, struct{}{})
126161
}
127162

128-
func buildPullRequestWebhook(body io.Reader, user string) (*git.PullRequest, error) {
129-
userReq := &cicdv1.IntegrationConfigAPIReqRunPreBody{}
130-
decoder := json.NewDecoder(body)
131-
if err := decoder.Decode(userReq); err != nil {
132-
return nil, err
163+
func updateIntegrationConfigPost(ic *cicdv1.IntegrationConfig, userReqBody *cicdv1.IntegrationConfigAPIReqRunPostBody, et git.EventType) (*cicdv1.IntegrationConfig, error) {
164+
targetJob := &ic.Spec.Jobs.PostSubmit
165+
var existingJob *cicdv1.Job
166+
167+
for _, addParams := range userReqBody.AddTektonTaskParams {
168+
jobName := addParams.JobName
169+
if jobName == "" {
170+
return nil, errors.New("JobName must be set")
171+
}
172+
173+
for i, job := range *targetJob {
174+
if job.Name == jobName {
175+
existingJob = &(*targetJob)[i]
176+
break
177+
}
178+
}
179+
180+
if existingJob == nil {
181+
return nil, fmt.Errorf("job with name '%s' not found", jobName)
182+
}
183+
184+
for _, taskDef := range addParams.TektonTask {
185+
// Check if a parameter with the same name already exists
186+
for i, existingParam := range existingJob.TektonTask.Params {
187+
if existingParam.Name == taskDef.Name {
188+
existingJob.TektonTask.Params = append(existingJob.TektonTask.Params[:i], existingJob.TektonTask.Params[i+1:]...)
189+
break
190+
}
191+
}
192+
193+
existingJob.TektonTask.Params = append(existingJob.TektonTask.Params, cicdv1.ParameterValue{
194+
Name: taskDef.Name,
195+
StringVal: taskDef.StringVal,
196+
})
197+
}
198+
}
199+
200+
return ic, nil
201+
}
202+
203+
func updateIntegrationConfigPre(ic *cicdv1.IntegrationConfig, userReqBody *cicdv1.IntegrationConfigAPIReqRunPreBody, et git.EventType) (*cicdv1.IntegrationConfig, error) {
204+
targetJob := &ic.Spec.Jobs.PreSubmit
205+
var existingJob *cicdv1.Job
206+
207+
for _, addParams := range userReqBody.AddTektonTaskParams {
208+
jobName := addParams.JobName
209+
if jobName == "" {
210+
return nil, errors.New("JobName must be set")
211+
}
212+
213+
for i, job := range *targetJob {
214+
if job.Name == jobName {
215+
existingJob = &(*targetJob)[i]
216+
break
217+
}
218+
}
219+
220+
if existingJob == nil {
221+
return nil, fmt.Errorf("job with name '%s' not found", jobName)
222+
}
223+
224+
for _, taskDef := range addParams.TektonTask {
225+
// Check if a parameter with the same name already exists
226+
for i, existingParam := range existingJob.TektonTask.Params {
227+
if existingParam.Name == taskDef.Name {
228+
existingJob.TektonTask.Params = append(existingJob.TektonTask.Params[:i], existingJob.TektonTask.Params[i+1:]...)
229+
break
230+
}
231+
}
232+
233+
existingJob.TektonTask.Params = append(existingJob.TektonTask.Params, cicdv1.ParameterValue{
234+
Name: taskDef.Name,
235+
StringVal: taskDef.StringVal,
236+
})
237+
}
133238
}
134239

240+
return ic, nil
241+
}
242+
243+
func buildPullRequestWebhook(userReq *cicdv1.IntegrationConfigAPIReqRunPreBody, user string) (*git.PullRequest, error) {
135244
baseBranch := userReq.BaseBranch
136245
headBranch := userReq.HeadBranch
137246
if baseBranch == "" {
@@ -158,13 +267,7 @@ func buildPullRequestWebhook(body io.Reader, user string) (*git.PullRequest, err
158267
}, nil
159268
}
160269

161-
func buildPushWebhook(body io.Reader) (*git.Push, error) {
162-
userReq := &cicdv1.IntegrationConfigAPIReqRunPostBody{}
163-
decoder := json.NewDecoder(body)
164-
if err := decoder.Decode(userReq); err != nil {
165-
return nil, err
166-
}
167-
270+
func buildPushWebhook(userReq *cicdv1.IntegrationConfigAPIReqRunPostBody) (*git.Push, error) {
168271
branch := userReq.Branch
169272
if branch == "" {
170273
branch = defaultBranch

0 commit comments

Comments
 (0)