-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate: Move Generator.spec to Generator.Config
This makes the attribute public, since quite a few config manipulations are easier using Go's types than they are via getter/setter/mutator methods. This also means that we can drop methods that are more awkward than direct access (although we'll want to keep methods that are more convenient than direct access). I haven't done any method-dropping in this commit though, although I have deprecated a few of the more redundant methods. I'd called for this back when we started adding these methods [1], and Mrunal was sounding more positive about the public-attribute approach a few weeks ago [2]. I've also renamed this from "spec" to "config", because it is a config. I'm not sure why runtime-spec decided to call the main config.go type 'Spec' [3], but I don't think we should repeat that idiosyncrasy. [1]: #137 (comment) [2]: #253 (comment) [3]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc2/specs-go/config.go#L6 Signed-off-by: W. Trevor King <wking@tremily.us>
- Loading branch information
Showing
4 changed files
with
633 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package generate | ||
|
||
import ( | ||
rspec "github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
func (g *Generator) initConfig() { | ||
if g.Config == nil { | ||
g.Config = &rspec.Spec{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigProcess() { | ||
g.initConfig() | ||
if g.Config.Process == nil { | ||
g.Config.Process = &rspec.Process{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigProcessConsoleSize() { | ||
g.initConfigProcess() | ||
if g.Config.Process.ConsoleSize == nil { | ||
g.Config.Process.ConsoleSize = &rspec.Box{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigProcessCapabilities() { | ||
g.initConfigProcess() | ||
if g.Config.Process.Capabilities == nil { | ||
g.Config.Process.Capabilities = &rspec.LinuxCapabilities{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigRoot() { | ||
g.initConfig() | ||
if g.Config.Root == nil { | ||
g.Config.Root = &rspec.Root{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigAnnotations() { | ||
g.initConfig() | ||
if g.Config.Annotations == nil { | ||
g.Config.Annotations = make(map[string]string) | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigHooks() { | ||
g.initConfig() | ||
if g.Config.Hooks == nil { | ||
g.Config.Hooks = &rspec.Hooks{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinux() { | ||
g.initConfig() | ||
if g.Config.Linux == nil { | ||
g.Config.Linux = &rspec.Linux{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxIntelRdt() { | ||
g.initConfigLinux() | ||
if g.Config.Linux.IntelRdt == nil { | ||
g.Config.Linux.IntelRdt = &rspec.LinuxIntelRdt{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxSysctl() { | ||
g.initConfigLinux() | ||
if g.Config.Linux.Sysctl == nil { | ||
g.Config.Linux.Sysctl = make(map[string]string) | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxSeccomp() { | ||
g.initConfigLinux() | ||
if g.Config.Linux.Seccomp == nil { | ||
g.Config.Linux.Seccomp = &rspec.LinuxSeccomp{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxResources() { | ||
g.initConfigLinux() | ||
if g.Config.Linux.Resources == nil { | ||
g.Config.Linux.Resources = &rspec.LinuxResources{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxResourcesBlockIO() { | ||
g.initConfigLinuxResources() | ||
if g.Config.Linux.Resources.BlockIO == nil { | ||
g.Config.Linux.Resources.BlockIO = &rspec.LinuxBlockIO{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxResourcesCPU() { | ||
g.initConfigLinuxResources() | ||
if g.Config.Linux.Resources.CPU == nil { | ||
g.Config.Linux.Resources.CPU = &rspec.LinuxCPU{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxResourcesMemory() { | ||
g.initConfigLinuxResources() | ||
if g.Config.Linux.Resources.Memory == nil { | ||
g.Config.Linux.Resources.Memory = &rspec.LinuxMemory{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxResourcesNetwork() { | ||
g.initConfigLinuxResources() | ||
if g.Config.Linux.Resources.Network == nil { | ||
g.Config.Linux.Resources.Network = &rspec.LinuxNetwork{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigLinuxResourcesPids() { | ||
g.initConfigLinuxResources() | ||
if g.Config.Linux.Resources.Pids == nil { | ||
g.Config.Linux.Resources.Pids = &rspec.LinuxPids{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigSolaris() { | ||
g.initConfig() | ||
if g.Config.Solaris == nil { | ||
g.Config.Solaris = &rspec.Solaris{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigSolarisCappedCPU() { | ||
g.initConfigSolaris() | ||
if g.Config.Solaris.CappedCPU == nil { | ||
g.Config.Solaris.CappedCPU = &rspec.SolarisCappedCPU{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigSolarisCappedMemory() { | ||
g.initConfigSolaris() | ||
if g.Config.Solaris.CappedMemory == nil { | ||
g.Config.Solaris.CappedMemory = &rspec.SolarisCappedMemory{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigWindows() { | ||
g.initConfig() | ||
if g.Config.Windows == nil { | ||
g.Config.Windows = &rspec.Windows{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigWindowsHyperV() { | ||
g.initConfigWindows() | ||
if g.Config.Windows.HyperV == nil { | ||
g.Config.Windows.HyperV = &rspec.WindowsHyperV{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigWindowsResources() { | ||
g.initConfigWindows() | ||
if g.Config.Windows.Resources == nil { | ||
g.Config.Windows.Resources = &rspec.WindowsResources{} | ||
} | ||
} | ||
|
||
func (g *Generator) initConfigWindowsResourcesMemory() { | ||
g.initConfigWindowsResources() | ||
if g.Config.Windows.Resources.Memory == nil { | ||
g.Config.Windows.Resources.Memory = &rspec.WindowsMemoryResources{} | ||
} | ||
} |
Oops, something went wrong.