@@ -97,13 +97,13 @@ func configureContainer(rt *Runtime, c *Container) error {
97
97
}
98
98
99
99
if c .Spec .Process .OOMScoreAdj != nil {
100
- if err := c .SetConfigItem ("lxc.proc.oom_score_adj" , fmt .Sprintf ("%d" , * c .Spec .Process .OOMScoreAdj )); err != nil {
100
+ if err := c .setConfigItem ("lxc.proc.oom_score_adj" , fmt .Sprintf ("%d" , * c .Spec .Process .OOMScoreAdj )); err != nil {
101
101
return err
102
102
}
103
103
}
104
104
105
105
if c .Spec .Process .NoNewPrivileges {
106
- if err := c .SetConfigItem ("lxc.no_new_privs" , "1" ); err != nil {
106
+ if err := c .setConfigItem ("lxc.no_new_privs" , "1" ); err != nil {
107
107
return err
108
108
}
109
109
}
@@ -122,7 +122,7 @@ func configureContainer(rt *Runtime, c *Container) error {
122
122
if err := writeSeccompProfile (profilePath , c .Spec .Linux .Seccomp ); err != nil {
123
123
return err
124
124
}
125
- if err := c .SetConfigItem ("lxc.seccomp.profile" , profilePath ); err != nil {
125
+ if err := c .setConfigItem ("lxc.seccomp.profile" , profilePath ); err != nil {
126
126
return err
127
127
}
128
128
}
@@ -139,7 +139,7 @@ func configureContainer(rt *Runtime, c *Container) error {
139
139
}
140
140
141
141
// make sure autodev is disabled
142
- if err := c .SetConfigItem ("lxc.autodev" , "0" ); err != nil {
142
+ if err := c .setConfigItem ("lxc.autodev" , "0" ); err != nil {
143
143
return err
144
144
}
145
145
@@ -190,7 +190,7 @@ func configureContainer(rt *Runtime, c *Container) error {
190
190
}
191
191
192
192
for key , val := range c .Spec .Linux .Sysctl {
193
- if err := c .SetConfigItem ("lxc.sysctl." + key , val ); err != nil {
193
+ if err := c .setConfigItem ("lxc.sysctl." + key , val ); err != nil {
194
194
return err
195
195
}
196
196
}
@@ -207,7 +207,7 @@ func configureContainer(rt *Runtime, c *Container) error {
207
207
}
208
208
seenLimits = append (seenLimits , name )
209
209
val := fmt .Sprintf ("%d:%d" , limit .Soft , limit .Hard )
210
- if err := c .SetConfigItem ("lxc.prlimit." + name , val ); err != nil {
210
+ if err := c .setConfigItem ("lxc.prlimit." + name , val ); err != nil {
211
211
return err
212
212
}
213
213
}
@@ -226,7 +226,7 @@ func configureHostname(rt *Runtime, c *Container) error {
226
226
if c .Spec .Hostname == "" {
227
227
return nil
228
228
}
229
- if err := c .SetConfigItem ("lxc.uts.name" , c .Spec .Hostname ); err != nil {
229
+ if err := c .setConfigItem ("lxc.uts.name" , c .Spec .Hostname ); err != nil {
230
230
return err
231
231
}
232
232
@@ -256,20 +256,20 @@ func configureRootfs(rt *Runtime, c *Container) error {
256
256
if ! filepath .IsAbs (rootfs ) {
257
257
rootfs = filepath .Join (c .BundlePath , rootfs )
258
258
}
259
- if err := c .SetConfigItem ("lxc.rootfs.path" , rootfs ); err != nil {
259
+ if err := c .setConfigItem ("lxc.rootfs.path" , rootfs ); err != nil {
260
260
return err
261
261
}
262
262
263
- if err := c .SetConfigItem ("lxc.rootfs.mount" , rootfs ); err != nil {
263
+ if err := c .setConfigItem ("lxc.rootfs.mount" , rootfs ); err != nil {
264
264
return err
265
265
}
266
266
267
- if err := c .SetConfigItem ("lxc.rootfs.managed" , "0" ); err != nil {
267
+ if err := c .setConfigItem ("lxc.rootfs.managed" , "0" ); err != nil {
268
268
return err
269
269
}
270
270
271
271
// Resources not created by the container runtime MUST NOT be deleted by it.
272
- if err := c .SetConfigItem ("lxc.ephemeral" , "0" ); err != nil {
272
+ if err := c .setConfigItem ("lxc.ephemeral" , "0" ); err != nil {
273
273
return err
274
274
}
275
275
@@ -280,20 +280,20 @@ func configureRootfs(rt *Runtime, c *Container) error {
280
280
if c .Spec .Root .Readonly {
281
281
rootfsOptions = append (rootfsOptions , "ro" )
282
282
}
283
- if err := c .SetConfigItem ("lxc.rootfs.options" , strings .Join (rootfsOptions , "," )); err != nil {
283
+ if err := c .setConfigItem ("lxc.rootfs.options" , strings .Join (rootfsOptions , "," )); err != nil {
284
284
return err
285
285
}
286
286
return nil
287
287
}
288
288
289
289
func configureReadonlyPaths (c * Container ) error {
290
- rootmnt := c .GetConfigItem ("lxc.rootfs.mount" )
290
+ rootmnt := c .getConfigItem ("lxc.rootfs.mount" )
291
291
if rootmnt == "" {
292
292
return fmt .Errorf ("lxc.rootfs.mount unavailable" )
293
293
}
294
294
for _ , p := range c .Spec .Linux .ReadonlyPaths {
295
295
mnt := fmt .Sprintf ("%s %s %s %s" , filepath .Join (rootmnt , p ), strings .TrimPrefix (p , "/" ), "bind" , "bind,ro,optional" )
296
- if err := c .SetConfigItem ("lxc.mount.entry" , mnt ); err != nil {
296
+ if err := c .setConfigItem ("lxc.mount.entry" , mnt ); err != nil {
297
297
return fmt .Errorf ("failed to make path readonly: %w" , err )
298
298
}
299
299
}
@@ -306,7 +306,7 @@ func configureApparmor(c *Container) error {
306
306
if aaprofile == "" {
307
307
aaprofile = "unconfined"
308
308
}
309
- return c .SetConfigItem ("lxc.apparmor.profile" , aaprofile )
309
+ return c .setConfigItem ("lxc.apparmor.profile" , aaprofile )
310
310
}
311
311
312
312
// configureCapabilities configures the linux capabilities / privileges granted to the container processes.
@@ -326,7 +326,7 @@ func configureCapabilities(c *Container) error {
326
326
}
327
327
}
328
328
329
- return c .SetConfigItem ("lxc.cap.keep" , keepCaps )
329
+ return c .setConfigItem ("lxc.cap.keep" , keepCaps )
330
330
}
331
331
332
332
// NOTE keep in sync with cmd/lxcri-hook#ociHooksAndState
@@ -359,22 +359,22 @@ func configureHooks(rt *Runtime, c *Container) error {
359
359
c .Spec .Hooks = & hooks
360
360
361
361
// pass context information as environment variables to hook scripts
362
- if err := c .SetConfigItem ("lxc.hook.version" , "1" ); err != nil {
362
+ if err := c .setConfigItem ("lxc.hook.version" , "1" ); err != nil {
363
363
return err
364
364
}
365
365
366
366
if len (c .Spec .Hooks .Prestart ) > 0 || len (c .Spec .Hooks .CreateRuntime ) > 0 {
367
- if err := c .SetConfigItem ("lxc.hook.pre-mount" , rt .libexec (ExecHook )); err != nil {
367
+ if err := c .setConfigItem ("lxc.hook.pre-mount" , rt .libexec (ExecHook )); err != nil {
368
368
return err
369
369
}
370
370
}
371
371
if len (c .Spec .Hooks .CreateContainer ) > 0 {
372
- if err := c .SetConfigItem ("lxc.hook.mount" , rt .libexec (ExecHook )); err != nil {
372
+ if err := c .setConfigItem ("lxc.hook.mount" , rt .libexec (ExecHook )); err != nil {
373
373
return err
374
374
}
375
375
}
376
376
if len (c .Spec .Hooks .StartContainer ) > 0 {
377
- if err := c .SetConfigItem ("lxc.hook.start" , rt .libexec (ExecHook )); err != nil {
377
+ if err := c .setConfigItem ("lxc.hook.start" , rt .libexec (ExecHook )); err != nil {
378
378
return err
379
379
}
380
380
}
0 commit comments