mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-01 12:01:14 +02:00
33 lines
985 B
Go
33 lines
985 B
Go
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package containerd
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/containerd/containerd/containers"
|
|
"github.com/containerd/containerd/oci"
|
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
|
)
|
|
|
|
// WithMemoryLimit sets the linux resource memory limit field.
|
|
func WithMemoryLimit(limit int64) oci.SpecOpts {
|
|
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
|
|
s.Linux.Resources.Memory = &specs.LinuxMemory{
|
|
Limit: &limit,
|
|
// DisableOOMKiller: &disable,
|
|
}
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRootfsPropagation sets the root filesystem propagation.
|
|
func WithRootfsPropagation(rp string) oci.SpecOpts {
|
|
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
|
|
s.Linux.RootfsPropagation = rp
|
|
return nil
|
|
}
|
|
}
|