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

Commit 2f1d819

Browse files
authored
Merge pull request #412 from thaJeztah/19.03_backport_builder_entitilement_confg
[19.03 backport] builder entitlements configuration added. Upstream-commit: 370def6b30a6566bc6a3413ad1b5bac37a82db16 Component: engine
2 parents b0d190a + 6c72dac commit 2f1d819

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
@@ -196,10 +196,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
196196
ResolveCacheExporterFuncs: map[string]remotecache.ResolveCacheExporterFunc{
197197
"inline": inlineremotecache.ResolveCacheExporterFunc(),
198198
},
199-
Entitlements: []string{
200-
string(entitlements.EntitlementNetworkHost),
201-
// string(entitlements.EntitlementSecurityInsecure),
202-
},
199+
Entitlements: getEntitlements(opt.BuilderConfig),
203200
})
204201
}
205202

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

components/engine/daemon/config/builder.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ type BuilderGCConfig struct {
6161
DefaultKeepStorage string `json:",omitempty"`
6262
}
6363

64+
// BuilderEntitlements contains settings to enable/disable entitlements
65+
type BuilderEntitlements struct {
66+
NetworkHost *bool `json:"network-host,omitempty"`
67+
SecurityInsecure *bool `json:"security-insecure,omitempty"`
68+
}
69+
6470
// BuilderConfig contains config for the builder
6571
type BuilderConfig struct {
66-
GC BuilderGCConfig `json:",omitempty"`
72+
GC BuilderGCConfig `json:",omitempty"`
73+
Entitlements BuilderEntitlements `json:",omitempty"`
6774
}

0 commit comments

Comments
 (0)