@@ -97,13 +97,13 @@ func configureContainer(rt *Runtime, c *Container) error {
9797 }
9898
9999 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 {
101101 return err
102102 }
103103 }
104104
105105 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 {
107107 return err
108108 }
109109 }
@@ -122,7 +122,7 @@ func configureContainer(rt *Runtime, c *Container) error {
122122 if err := writeSeccompProfile (profilePath , c .Spec .Linux .Seccomp ); err != nil {
123123 return err
124124 }
125- if err := c .SetConfigItem ("lxc.seccomp.profile" , profilePath ); err != nil {
125+ if err := c .setConfigItem ("lxc.seccomp.profile" , profilePath ); err != nil {
126126 return err
127127 }
128128 }
@@ -139,7 +139,7 @@ func configureContainer(rt *Runtime, c *Container) error {
139139 }
140140
141141 // 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 {
143143 return err
144144 }
145145
@@ -190,7 +190,7 @@ func configureContainer(rt *Runtime, c *Container) error {
190190 }
191191
192192 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 {
194194 return err
195195 }
196196 }
@@ -207,7 +207,7 @@ func configureContainer(rt *Runtime, c *Container) error {
207207 }
208208 seenLimits = append (seenLimits , name )
209209 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 {
211211 return err
212212 }
213213 }
@@ -226,7 +226,7 @@ func configureHostname(rt *Runtime, c *Container) error {
226226 if c .Spec .Hostname == "" {
227227 return nil
228228 }
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 {
230230 return err
231231 }
232232
@@ -256,20 +256,20 @@ func configureRootfs(rt *Runtime, c *Container) error {
256256 if ! filepath .IsAbs (rootfs ) {
257257 rootfs = filepath .Join (c .BundlePath , rootfs )
258258 }
259- if err := c .SetConfigItem ("lxc.rootfs.path" , rootfs ); err != nil {
259+ if err := c .setConfigItem ("lxc.rootfs.path" , rootfs ); err != nil {
260260 return err
261261 }
262262
263- if err := c .SetConfigItem ("lxc.rootfs.mount" , rootfs ); err != nil {
263+ if err := c .setConfigItem ("lxc.rootfs.mount" , rootfs ); err != nil {
264264 return err
265265 }
266266
267- if err := c .SetConfigItem ("lxc.rootfs.managed" , "0" ); err != nil {
267+ if err := c .setConfigItem ("lxc.rootfs.managed" , "0" ); err != nil {
268268 return err
269269 }
270270
271271 // 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 {
273273 return err
274274 }
275275
@@ -280,20 +280,20 @@ func configureRootfs(rt *Runtime, c *Container) error {
280280 if c .Spec .Root .Readonly {
281281 rootfsOptions = append (rootfsOptions , "ro" )
282282 }
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 {
284284 return err
285285 }
286286 return nil
287287}
288288
289289func configureReadonlyPaths (c * Container ) error {
290- rootmnt := c .GetConfigItem ("lxc.rootfs.mount" )
290+ rootmnt := c .getConfigItem ("lxc.rootfs.mount" )
291291 if rootmnt == "" {
292292 return fmt .Errorf ("lxc.rootfs.mount unavailable" )
293293 }
294294 for _ , p := range c .Spec .Linux .ReadonlyPaths {
295295 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 {
297297 return fmt .Errorf ("failed to make path readonly: %w" , err )
298298 }
299299 }
@@ -306,7 +306,7 @@ func configureApparmor(c *Container) error {
306306 if aaprofile == "" {
307307 aaprofile = "unconfined"
308308 }
309- return c .SetConfigItem ("lxc.apparmor.profile" , aaprofile )
309+ return c .setConfigItem ("lxc.apparmor.profile" , aaprofile )
310310}
311311
312312// configureCapabilities configures the linux capabilities / privileges granted to the container processes.
@@ -326,7 +326,7 @@ func configureCapabilities(c *Container) error {
326326 }
327327 }
328328
329- return c .SetConfigItem ("lxc.cap.keep" , keepCaps )
329+ return c .setConfigItem ("lxc.cap.keep" , keepCaps )
330330}
331331
332332// NOTE keep in sync with cmd/lxcri-hook#ociHooksAndState
@@ -359,22 +359,22 @@ func configureHooks(rt *Runtime, c *Container) error {
359359 c .Spec .Hooks = & hooks
360360
361361 // 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 {
363363 return err
364364 }
365365
366366 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 {
368368 return err
369369 }
370370 }
371371 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 {
373373 return err
374374 }
375375 }
376376 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 {
378378 return err
379379 }
380380 }
0 commit comments