-
Notifications
You must be signed in to change notification settings - Fork 41
/
windows.go
29 lines (22 loc) · 897 Bytes
/
windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package bundlerules
import (
spec "code.cloudfoundry.org/guardian/gardener/container-spec"
"code.cloudfoundry.org/guardian/rundmc/goci"
"github.com/opencontainers/runtime-spec/specs-go"
)
type Windows struct{}
func (w Windows) Apply(bndl goci.Bndl, spec spec.DesiredContainerSpec) (goci.Bndl, error) {
if spec.BaseConfig.Windows == nil {
return bndl, nil
}
bndl = bndl.WithWindows(*spec.BaseConfig.Windows)
limit := uint64(spec.Limits.Memory.LimitInBytes)
bndl = bndl.WithWindowsMemoryLimit(specs.WindowsMemoryResources{Limit: &limit})
//lint:ignore SA1019 - we still specify this to make the deprecated logic work until we get rid of the code in garden
shares := uint16(spec.Limits.CPU.LimitInShares)
if spec.Limits.CPU.Weight > 0 {
shares = uint16(spec.Limits.CPU.Weight)
}
bndl = bndl.WithWindowsCPUShares(specs.WindowsCPUResources{Shares: &shares})
return bndl, nil
}