@@ -107,45 +107,33 @@ func (s *server) markDeployedPR(w http.ResponseWriter, req *http.Request) {
107
107
108
108
if team == "" || commitSHA == "" {
109
109
110
- var preconditionFailed struct {
111
- Errors []string
112
- }
113
-
114
- preconditionFailed .Errors = make ([]string , 0 , 1 )
115
- preconditionFailed .Errors = append (preconditionFailed .Errors , fmt .Sprintf ("team and commit are required parameters. Team: '%v', commit: '%v'" , team , commitSHA ))
116
-
117
110
s .log .WithFields (
118
111
logrus.Fields {
119
112
"team" : team ,
120
113
"commit" : commitSHA ,
121
114
},
122
115
).Error ("team and commit are required parameters" )
123
116
124
- w .Header ().Set ("Content-Type" , "application/json; charset=utf-8" )
125
- w .Header ().Set ("X-Content-Type-Options" , "nosniff" )
126
117
w .WriteHeader (http .StatusPreconditionFailed )
127
- json .NewEncoder (w ).Encode (preconditionFailed )
118
+ enc := json .NewEncoder (w )
119
+ enc .SetIndent ("" , " " )
120
+ enc .Encode (map [string ]string {
121
+ "error" : "team and commit are required parameters" ,
122
+ })
128
123
return
129
124
}
130
125
131
- var errs []error
132
-
133
126
switch req .Method {
134
127
case "GET" :
135
128
var msg struct {
136
129
PRs struct {
137
130
Labeled []string `json:"labeled"`
138
131
Unlabeled []string `json:"unlabeled"`
139
132
}
140
- Errors []string `json:"errors"`
133
+ Errors []error `json:"errors"`
141
134
}
142
135
143
- msg .PRs .Labeled , msg .PRs .Unlabeled , errs = s .handleGetUnmarkedPRs (req .Context (), commitSHA , team )
144
-
145
- msg .Errors = make ([]string , 0 , len (errs ))
146
- for _ , err := range errs {
147
- msg .Errors = append (msg .Errors , err .Error ())
148
- }
136
+ msg .PRs .Labeled , msg .PRs .Unlabeled , msg .Errors = s .handleGetUnmarkedPRs (req .Context (), commitSHA , team )
149
137
150
138
if len (msg .Errors ) > 0 {
151
139
w .WriteHeader (http .StatusUnprocessableEntity )
@@ -165,11 +153,6 @@ func (s *server) markDeployedPR(w http.ResponseWriter, req *http.Request) {
165
153
}
166
154
msg .DeployedPRs .Team , msg .DeployedPRs .All , msg .Errors = s .handleMarkDeployedPRs (req .Context (), commitSHA , team )
167
155
168
- msg .Errors = make ([]string , 0 , len (errs ))
169
- for _ , err := range errs {
170
- msg .Errors = append (msg .Errors , err .Error ())
171
- }
172
-
173
156
if len (msg .Errors ) > 0 {
174
157
w .WriteHeader (http .StatusUnprocessableEntity )
175
158
}
0 commit comments