mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-20 05:23:15 -04:00
Bumps [github.com/testcontainers/testcontainers-go/modules/opensearch](https://github.com/testcontainers/testcontainers-go) from 0.38.0 to 0.39.0. - [Release notes](https://github.com/testcontainers/testcontainers-go/releases) - [Commits](https://github.com/testcontainers/testcontainers-go/compare/v0.38.0...v0.39.0) --- updated-dependencies: - dependency-name: github.com/testcontainers/testcontainers-go/modules/opensearch dependency-version: 0.39.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
"strconv"
|
|
|
|
"github.com/docker/docker/api/types/build"
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// BuildCachePrune requests the daemon to delete unused cache data
|
|
func (cli *Client) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
|
|
if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
query := url.Values{}
|
|
if opts.All {
|
|
query.Set("all", "1")
|
|
}
|
|
|
|
if opts.KeepStorage != 0 {
|
|
query.Set("keep-storage", strconv.Itoa(int(opts.KeepStorage)))
|
|
}
|
|
if opts.ReservedSpace != 0 {
|
|
query.Set("reserved-space", strconv.Itoa(int(opts.ReservedSpace)))
|
|
}
|
|
if opts.MaxUsedSpace != 0 {
|
|
query.Set("max-used-space", strconv.Itoa(int(opts.MaxUsedSpace)))
|
|
}
|
|
if opts.MinFreeSpace != 0 {
|
|
query.Set("min-free-space", strconv.Itoa(int(opts.MinFreeSpace)))
|
|
}
|
|
f, err := filters.ToJSON(opts.Filters)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "prune could not marshal filters option")
|
|
}
|
|
query.Set("filters", f)
|
|
|
|
resp, err := cli.post(ctx, "/build/prune", query, nil, nil)
|
|
defer ensureReaderClosed(resp)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
report := build.CachePruneReport{}
|
|
if err := json.NewDecoder(resp.Body).Decode(&report); err != nil {
|
|
return nil, errors.Wrap(err, "error retrieving disk usage")
|
|
}
|
|
|
|
return &report, nil
|
|
}
|