mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat: add support for sysctls compose key (#239)
* feat: add support for `sysctls` compose key * lint --------- Co-authored-by: Pasha Sviderski <me@psviderski.name>
This commit is contained in:
co-authored by
Pasha Sviderski
parent
7e739dd2f0
commit
06c3fba96e
+15
-8
@@ -247,6 +247,8 @@ type ContainerSpec struct {
|
||||
PullPolicy string
|
||||
// Resource allocation for the container.
|
||||
Resources ContainerResources
|
||||
// Namespaced kernel parameters to be set in container
|
||||
Sysctls map[string]string
|
||||
// User overrides the default user of the image used to run the container. Format: user|UID[:group|GID].
|
||||
User string
|
||||
// VolumeMounts specifies how volumes are mounted into the container filesystem.
|
||||
@@ -312,6 +314,14 @@ func (s *ContainerSpec) Equals(spec ContainerSpec) bool {
|
||||
func (s *ContainerSpec) Clone() ContainerSpec {
|
||||
spec := *s
|
||||
|
||||
if s.CapAdd != nil {
|
||||
spec.CapAdd = make([]string, len(s.CapAdd))
|
||||
copy(spec.CapAdd, s.CapAdd)
|
||||
}
|
||||
if s.CapDrop != nil {
|
||||
spec.CapDrop = make([]string, len(s.CapDrop))
|
||||
copy(spec.CapDrop, s.CapDrop)
|
||||
}
|
||||
if s.Command != nil {
|
||||
spec.Command = make([]string, len(s.Command))
|
||||
copy(spec.Command, s.Command)
|
||||
@@ -347,15 +357,12 @@ func (s *ContainerSpec) Clone() ContainerSpec {
|
||||
spec.ConfigMounts[i] = cm.Clone()
|
||||
}
|
||||
}
|
||||
if s.CapAdd != nil {
|
||||
spec.CapAdd = make([]string, len(s.CapAdd))
|
||||
copy(spec.CapAdd, s.CapAdd)
|
||||
if s.Sysctls != nil {
|
||||
spec.Sysctls = make(map[string]string, len(s.Sysctls))
|
||||
for k, v := range s.Sysctls {
|
||||
spec.Sysctls[k] = v
|
||||
}
|
||||
}
|
||||
if s.CapDrop != nil {
|
||||
spec.CapDrop = make([]string, len(s.CapDrop))
|
||||
copy(spec.CapDrop, s.CapDrop)
|
||||
}
|
||||
|
||||
return spec
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user