[19.03 backport] builder entitlements configuration added.
| ... | ... |
@@ -196,10 +196,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
| 196 | 196 |
ResolveCacheExporterFuncs: map[string]remotecache.ResolveCacheExporterFunc{
|
| 197 | 197 |
"inline": inlineremotecache.ResolveCacheExporterFunc(), |
| 198 | 198 |
}, |
| 199 |
- Entitlements: []string{
|
|
| 200 |
- string(entitlements.EntitlementNetworkHost), |
|
| 201 |
- // string(entitlements.EntitlementSecurityInsecure), |
|
| 202 |
- }, |
|
| 199 |
+ Entitlements: getEntitlements(opt.BuilderConfig), |
|
| 203 | 200 |
}) |
| 204 | 201 |
} |
| 205 | 202 |
|
| ... | ... |
@@ -255,3 +252,15 @@ func parsePlatforms(platformsStr []string) ([]specs.Platform, error) {
|
| 255 | 255 |
} |
| 256 | 256 |
return out, nil |
| 257 | 257 |
} |
| 258 |
+ |
|
| 259 |
+func getEntitlements(conf config.BuilderConfig) []string {
|
|
| 260 |
+ var ents []string |
|
| 261 |
+ // Incase of no config settings, NetworkHost should be enabled & SecurityInsecure must be disabled. |
|
| 262 |
+ if conf.Entitlements.NetworkHost == nil || *conf.Entitlements.NetworkHost {
|
|
| 263 |
+ ents = append(ents, string(entitlements.EntitlementNetworkHost)) |
|
| 264 |
+ } |
|
| 265 |
+ if conf.Entitlements.SecurityInsecure != nil && *conf.Entitlements.SecurityInsecure {
|
|
| 266 |
+ ents = append(ents, string(entitlements.EntitlementSecurityInsecure)) |
|
| 267 |
+ } |
|
| 268 |
+ return ents |
|
| 269 |
+} |
| ... | ... |
@@ -61,7 +61,14 @@ type BuilderGCConfig struct {
|
| 61 | 61 |
DefaultKeepStorage string `json:",omitempty"` |
| 62 | 62 |
} |
| 63 | 63 |
|
| 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 |
+ |
|
| 64 | 70 |
// BuilderConfig contains config for the builder |
| 65 | 71 |
type BuilderConfig struct {
|
| 66 |
- GC BuilderGCConfig `json:",omitempty"` |
|
| 72 |
+ GC BuilderGCConfig `json:",omitempty"` |
|
| 73 |
+ Entitlements BuilderEntitlements `json:",omitempty"` |
|
| 67 | 74 |
} |