This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #410 from thaJeztah/19.03_backport_fix_buildkit_pr…
…unegc_filter_config [19.03 backport] daemon/config: fix filter type in BuildKit GC config Upstream-commit: e2e3abec71f30e533a01e8f1f9669e55b1361fc1 Component: engine
- Loading branch information
Showing
4 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/docker/docker/api/types/filters" | ||
"github.com/google/go-cmp/cmp" | ||
"gotest.tools/assert" | ||
"gotest.tools/fs" | ||
) | ||
|
||
func TestBuilderGC(t *testing.T) { | ||
tempFile := fs.NewFile(t, "config", fs.WithContent(`{ | ||
"builder": { | ||
"gc": { | ||
"enabled": true, | ||
"policy": [ | ||
{"keepStorage": "10GB", "filter": ["unused-for=2200h"]}, | ||
{"keepStorage": "50GB", "filter": {"unused-for": {"3300h": true}}}, | ||
{"keepStorage": "100GB", "all": true} | ||
] | ||
} | ||
} | ||
}`)) | ||
defer tempFile.Remove() | ||
configFile := tempFile.Path() | ||
|
||
cfg, err := MergeDaemonConfigurations(&Config{}, nil, configFile) | ||
assert.NilError(t, err) | ||
assert.Assert(t, cfg.Builder.GC.Enabled) | ||
f1 := filters.NewArgs() | ||
f1.Add("unused-for", "2200h") | ||
f2 := filters.NewArgs() | ||
f2.Add("unused-for", "3300h") | ||
expectedPolicy := []BuilderGCRule{ | ||
{KeepStorage: "10GB", Filter: BuilderGCFilter(f1)}, | ||
{KeepStorage: "50GB", Filter: BuilderGCFilter(f2)}, /* parsed from deprecated form */ | ||
{KeepStorage: "100GB", All: true}, | ||
} | ||
assert.DeepEqual(t, cfg.Builder.GC.Policy, expectedPolicy, cmp.AllowUnexported(BuilderGCFilter{})) | ||
// double check to please the skeptics | ||
assert.Assert(t, filters.Args(cfg.Builder.GC.Policy[0].Filter).UniqueExactMatch("unused-for", "2200h")) | ||
assert.Assert(t, filters.Args(cfg.Builder.GC.Policy[1].Filter).UniqueExactMatch("unused-for", "3300h")) | ||
} |