| 181 | } |
| 182 | |
| 183 | func publishRelease(httpClient *http.Client, host string, releaseURL safeurl.SafeURL, discussionCategory string, isLatest *bool) (*shared.Release, error) { |
| 184 | params := map[string]interface{}{"draft": false} |
| 185 | if discussionCategory != "" { |
| 186 | params["discussion_category_name"] = discussionCategory |
| 187 | } |
| 188 | |
| 189 | if isLatest != nil { |
| 190 | params["make_latest"] = fmt.Sprintf("%v", *isLatest) |
| 191 | } |
| 192 | |
| 193 | bodyBytes, err := json.Marshal(params) |
| 194 | if err != nil { |
| 195 | return nil, err |
| 196 | } |
| 197 | |
| 198 | var release shared.Release |
| 199 | // TODO(api-client-rollout) |
| 200 | // This line of code is part of a mechanical roll out of the api client. |
| 201 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 202 | err = api.NewClientFromHTTP(httpClient).REST(host, http.MethodPatch, releaseURL.String(), bytes.NewBuffer(bodyBytes), &release) |
| 203 | if err != nil { |
| 204 | return nil, err |
| 205 | } |
| 206 | return &release, nil |
| 207 | } |
| 208 | |
| 209 | func deleteRelease(httpClient *http.Client, host string, releaseURL safeurl.SafeURL) error { |
| 210 | // TODO(api-client-rollout) |