ImageBuild sends a request to the daemon to build images. The Body in the response implements an [io.ReadCloser] and it's up to the caller to close it.
(ctx context.Context, buildContext io.Reader, options ImageBuildOptions)
| 18 | // The Body in the response implements an [io.ReadCloser] and it's up to the caller to |
| 19 | // close it. |
| 20 | func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options ImageBuildOptions) (ImageBuildResult, error) { |
| 21 | query, err := cli.imageBuildOptionsToQuery(ctx, options) |
| 22 | if err != nil { |
| 23 | return ImageBuildResult{}, err |
| 24 | } |
| 25 | |
| 26 | buf, err := json.Marshal(options.AuthConfigs) // #nosec G117 -- ignore "Marshaled struct field "Password" (JSON key "password") matches secret pattern" |
| 27 | if err != nil { |
| 28 | return ImageBuildResult{}, err |
| 29 | } |
| 30 | |
| 31 | headers := http.Header{} |
| 32 | headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) |
| 33 | headers.Set("Content-Type", "application/x-tar") |
| 34 | |
| 35 | resp, err := cli.postRaw(ctx, "/build", query, buildContext, headers) |
| 36 | if err != nil { |
| 37 | return ImageBuildResult{}, err |
| 38 | } |
| 39 | |
| 40 | return ImageBuildResult{ |
| 41 | Body: resp.Body, |
| 42 | }, nil |
| 43 | } |
| 44 | |
| 45 | func (cli *Client) imageBuildOptionsToQuery(_ context.Context, options ImageBuildOptions) (url.Values, error) { |
| 46 | query := url.Values{} |
nothing calls this directly
no test coverage detected