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