Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 6c72dac

Browse files
kunalkushwahathaJeztah
authored andcommitted
builder entitlements configutation added.
buildkit supports entitlements like network-host and security-insecure. this patch aims to make it configurable through daemon.json file. by default network-host is enabled & secuirty-insecure is disabled. Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com> (cherry picked from commit 8b7bbf180fc65013bc9ec0269b4a475d3eb038ee) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: ce74774c096b1abcf872b45a3aa15c08120ff0c7 Component: engine
1 parent a4cbe9c commit 6c72dac

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

components/engine/builder/builder-next/controller.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
195195
ResolveCacheExporterFuncs: map[string]remotecache.ResolveCacheExporterFunc{
196196
"inline": inlineremotecache.ResolveCacheExporterFunc(),
197197
},
198-
Entitlements: []string{
199-
string(entitlements.EntitlementNetworkHost),
200-
// string(entitlements.EntitlementSecurityInsecure),
201-
},
198+
Entitlements: getEntitlements(opt.BuilderConfig),
202199
})
203200
}
204201

@@ -254,3 +251,15 @@ func parsePlatforms(platformsStr []string) ([]specs.Platform, error) {
254251
}
255252
return out, nil
256253
}
254+
255+
func getEntitlements(conf config.BuilderConfig) []string {
256+
var ents []string
257+
// Incase of no config settings, NetworkHost should be enabled & SecurityInsecure must be disabled.
258+
if conf.Entitlements.NetworkHost == nil || *conf.Entitlements.NetworkHost {
259+
ents = append(ents, string(entitlements.EntitlementNetworkHost))
260+
}
261+
if conf.Entitlements.SecurityInsecure != nil && *conf.Entitlements.SecurityInsecure {
262+
ents = append(ents, string(entitlements.EntitlementSecurityInsecure))
263+
}
264+
return ents
265+
}

components/engine/daemon/config/builder.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ type BuilderGCConfig struct {
1616
DefaultKeepStorage string `json:",omitempty"`
1717
}
1818

19+
// BuilderEntitlements contains settings to enable/disable entitlements
20+
type BuilderEntitlements struct {
21+
NetworkHost *bool `json:"network-host,omitempty"`
22+
SecurityInsecure *bool `json:"security-insecure,omitempty"`
23+
}
24+
1925
// BuilderConfig contains config for the builder
2026
type BuilderConfig struct {
21-
GC BuilderGCConfig `json:",omitempty"`
27+
GC BuilderGCConfig `json:",omitempty"`
28+
Entitlements BuilderEntitlements `json:",omitempty"`
2229
}

0 commit comments

Comments
 (0)