MCPcopy
hub / github.com/caddyserver/caddy / downloadBuild

Function downloadBuild

cmd/packagesfuncs.go:280–305  ·  view source on GitHub ↗
(qs url.Values)

Source from the content-addressed store, hash-verified

278}
279
280func downloadBuild(qs url.Values) (*http.Response, error) {
281 l := caddy.Log()
282 l.Info("requesting build",
283 zap.String("os", qs.Get("os")),
284 zap.String("arch", qs.Get("arch")),
285 zap.Strings("packages", qs["p"]))
286 resp, err := http.Get(fmt.Sprintf("%s?%s", downloadPath, qs.Encode()))
287 if err != nil {
288 return nil, fmt.Errorf("secure request failed: %v", err)
289 }
290 if resp.StatusCode >= 400 {
291 var details struct {
292 StatusCode int `json:"status_code"`
293 Error struct {
294 Message string `json:"message"`
295 ID string `json:"id"`
296 } `json:"error"`
297 }
298 err2 := json.NewDecoder(resp.Body).Decode(&details)
299 if err2 != nil {
300 return nil, fmt.Errorf("download and error decoding failed: HTTP %d: %v", resp.StatusCode, err2)
301 }
302 return nil, fmt.Errorf("download failed: HTTP %d: %s (id=%s)", resp.StatusCode, details.Error.Message, details.Error.ID)
303 }
304 return resp, nil
305}
306
307func getPluginPackages(modules []moduleInfo) (map[string]pluginPackage, error) {
308 pluginPkgs := make(map[string]pluginPackage)

Callers 1

upgradeBuildFunction · 0.85

Calls 2

GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected