Skip to content

Commit 3c4fc86

Browse files
author
Mrunal Patel
authored
Merge pull request #137 from hmeng-19/expand_libgen
Add resource set funcs into generate library
2 parents e05b847 + c92ad7a commit 3c4fc86

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

generate/generate.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,71 @@ func (g Generator) SetLinuxMountLabel(label string) {
342342
g.spec.Linux.MountLabel = label
343343
}
344344

345+
// SetLinuxResourcesCPUShares sets g.spec.Linux.Resources.CPU.Shares.
346+
func (g Generator) SetLinuxResourcesCPUShares(shares uint64) {
347+
g.spec.Linux.Resources.CPU.Shares = &shares
348+
}
349+
350+
// SetLinuxResourcesCPUQuota sets g.spec.Linux.Resources.CPU.Quota.
351+
func (g Generator) SetLinuxResourcesCPUQuota(quota uint64) {
352+
g.spec.Linux.Resources.CPU.Quota = &quota
353+
}
354+
355+
// SetLinuxResourcesCPUPeriod sets g.spec.Linux.Resources.CPU.Period.
356+
func (g Generator) SetLinuxResourcesCPUPeriod(period uint64) {
357+
g.spec.Linux.Resources.CPU.Period = &period
358+
}
359+
360+
// SetLinuxResourcesCPURealtimeRuntime sets g.spec.Linux.Resources.CPU.RealtimeRuntime.
361+
func (g Generator) SetLinuxResourcesCPURealtimeRuntime(time uint64) {
362+
g.spec.Linux.Resources.CPU.RealtimeRuntime = &time
363+
}
364+
365+
// SetLinuxResourcesCPURealtimePeriod sets g.spec.Linux.Resources.CPU.RealtimePeriod.
366+
func (g Generator) SetLinuxResourcesCPURealtimePeriod(period uint64) {
367+
g.spec.Linux.Resources.CPU.RealtimePeriod = &period
368+
}
369+
370+
// SetLinuxResourcesCPUCpus sets g.spec.Linux.Resources.CPU.Cpus.
371+
func (g Generator) SetLinuxResourcesCPUCpus(cpus string) {
372+
g.spec.Linux.Resources.CPU.Cpus = &cpus
373+
}
374+
375+
// SetLinuxResourcesCPUMems sets g.spec.Linux.Resources.CPU.Mems.
376+
func (g Generator) SetLinuxResourcesCPUMems(mems string) {
377+
g.spec.Linux.Resources.CPU.Mems = &mems
378+
}
379+
380+
// SetLinuxResourcesMemoryLimit sets g.spec.Linux.Resources.Memory.Limit.
381+
func (g Generator) SetLinuxResourcesMemoryLimit(limit uint64) {
382+
g.spec.Linux.Resources.Memory.Limit = &limit
383+
}
384+
385+
// SetLinuxResourcesMemoryReservation sets g.spec.Linux.Resources.Memory.Reservation.
386+
func (g Generator) SetLinuxResourcesMemoryReservation(reservation uint64) {
387+
g.spec.Linux.Resources.Memory.Reservation = &reservation
388+
}
389+
390+
// SetLinuxResourcesMemorySwap sets g.spec.Linux.Resources.Memory.Swap.
391+
func (g Generator) SetLinuxResourcesMemorySwap(swap uint64) {
392+
g.spec.Linux.Resources.Memory.Swap = &swap
393+
}
394+
395+
// SetLinuxResourcesMemoryKernel sets g.spec.Linux.Resources.Memory.Kernel.
396+
func (g Generator) SetLinuxResourcesMemoryKernel(kernel uint64) {
397+
g.spec.Linux.Resources.Memory.Kernel = &kernel
398+
}
399+
400+
// SetLinuxResourcesMemoryKernelTCP sets g.spec.Linux.Resources.Memory.KernelTCP.
401+
func (g Generator) SetLinuxResourcesMemoryKernelTCP(kernelTCP uint64) {
402+
g.spec.Linux.Resources.Memory.KernelTCP = &kernelTCP
403+
}
404+
405+
// SetLinuxResourcesMemorySwappiness sets g.spec.Linux.Resources.Memory.Swappiness.
406+
func (g Generator) SetLinuxResourcesMemorySwappiness(swappiness uint64) {
407+
g.spec.Linux.Resources.Memory.Swappiness = &swappiness
408+
}
409+
345410
// ClearLinuxSysctl clears g.spec.Linux.Sysctl.
346411
func (g Generator) ClearLinuxSysctl() {
347412
g.spec.Linux.Sysctl = make(map[string]string)

0 commit comments

Comments
 (0)