|
| 1 | +package generate |
| 2 | + |
| 3 | +import ( |
| 4 | + rspec "github.com/opencontainers/runtime-spec/specs-go" |
| 5 | +) |
| 6 | + |
| 7 | +func (g *Generator) initConfig() { |
| 8 | + if g.Config == nil { |
| 9 | + g.Config = &rspec.Spec{} |
| 10 | + } |
| 11 | +} |
| 12 | + |
| 13 | +func (g *Generator) initConfigProcess() { |
| 14 | + g.initConfig() |
| 15 | + if g.Config.Process == nil { |
| 16 | + g.Config.Process = &rspec.Process{} |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +func (g *Generator) initConfigProcessConsoleSize() { |
| 21 | + g.initConfigProcess() |
| 22 | + if g.Config.Process.ConsoleSize == nil { |
| 23 | + g.Config.Process.ConsoleSize = &rspec.Box{} |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +func (g *Generator) initConfigProcessCapabilities() { |
| 28 | + g.initConfigProcess() |
| 29 | + if g.Config.Process.Capabilities == nil { |
| 30 | + g.Config.Process.Capabilities = &rspec.LinuxCapabilities{} |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +func (g *Generator) initConfigRoot() { |
| 35 | + g.initConfig() |
| 36 | + if g.Config.Root == nil { |
| 37 | + g.Config.Root = &rspec.Root{} |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +func (g *Generator) initConfigAnnotations() { |
| 42 | + g.initConfig() |
| 43 | + if g.Config.Annotations == nil { |
| 44 | + g.Config.Annotations = make(map[string]string) |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +func (g *Generator) initConfigHooks() { |
| 49 | + g.initConfig() |
| 50 | + if g.Config.Hooks == nil { |
| 51 | + g.Config.Hooks = &rspec.Hooks{} |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +func (g *Generator) initConfigLinux() { |
| 56 | + g.initConfig() |
| 57 | + if g.Config.Linux == nil { |
| 58 | + g.Config.Linux = &rspec.Linux{} |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +func (g *Generator) initConfigLinuxIntelRdt() { |
| 63 | + g.initConfigLinux() |
| 64 | + if g.Config.Linux.IntelRdt == nil { |
| 65 | + g.Config.Linux.IntelRdt = &rspec.LinuxIntelRdt{} |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +func (g *Generator) initConfigLinuxSysctl() { |
| 70 | + g.initConfigLinux() |
| 71 | + if g.Config.Linux.Sysctl == nil { |
| 72 | + g.Config.Linux.Sysctl = make(map[string]string) |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +func (g *Generator) initConfigLinuxSeccomp() { |
| 77 | + g.initConfigLinux() |
| 78 | + if g.Config.Linux.Seccomp == nil { |
| 79 | + g.Config.Linux.Seccomp = &rspec.LinuxSeccomp{} |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +func (g *Generator) initConfigLinuxResources() { |
| 84 | + g.initConfigLinux() |
| 85 | + if g.Config.Linux.Resources == nil { |
| 86 | + g.Config.Linux.Resources = &rspec.LinuxResources{} |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +func (g *Generator) initConfigLinuxResourcesBlockIO() { |
| 91 | + g.initConfigLinuxResources() |
| 92 | + if g.Config.Linux.Resources.BlockIO == nil { |
| 93 | + g.Config.Linux.Resources.BlockIO = &rspec.LinuxBlockIO{} |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +func (g *Generator) initConfigLinuxResourcesCPU() { |
| 98 | + g.initConfigLinuxResources() |
| 99 | + if g.Config.Linux.Resources.CPU == nil { |
| 100 | + g.Config.Linux.Resources.CPU = &rspec.LinuxCPU{} |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +func (g *Generator) initConfigLinuxResourcesMemory() { |
| 105 | + g.initConfigLinuxResources() |
| 106 | + if g.Config.Linux.Resources.Memory == nil { |
| 107 | + g.Config.Linux.Resources.Memory = &rspec.LinuxMemory{} |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +func (g *Generator) initConfigLinuxResourcesNetwork() { |
| 112 | + g.initConfigLinuxResources() |
| 113 | + if g.Config.Linux.Resources.Network == nil { |
| 114 | + g.Config.Linux.Resources.Network = &rspec.LinuxNetwork{} |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +func (g *Generator) initConfigLinuxResourcesPids() { |
| 119 | + g.initConfigLinuxResources() |
| 120 | + if g.Config.Linux.Resources.Pids == nil { |
| 121 | + g.Config.Linux.Resources.Pids = &rspec.LinuxPids{} |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | +func (g *Generator) initConfigSolaris() { |
| 126 | + g.initConfig() |
| 127 | + if g.Config.Solaris == nil { |
| 128 | + g.Config.Solaris = &rspec.Solaris{} |
| 129 | + } |
| 130 | +} |
| 131 | + |
| 132 | +func (g *Generator) initConfigSolarisCappedCPU() { |
| 133 | + g.initConfigSolaris() |
| 134 | + if g.Config.Solaris.CappedCPU == nil { |
| 135 | + g.Config.Solaris.CappedCPU = &rspec.SolarisCappedCPU{} |
| 136 | + } |
| 137 | +} |
| 138 | + |
| 139 | +func (g *Generator) initConfigSolarisCappedMemory() { |
| 140 | + g.initConfigSolaris() |
| 141 | + if g.Config.Solaris.CappedMemory == nil { |
| 142 | + g.Config.Solaris.CappedMemory = &rspec.SolarisCappedMemory{} |
| 143 | + } |
| 144 | +} |
| 145 | + |
| 146 | +func (g *Generator) initConfigWindows() { |
| 147 | + g.initConfig() |
| 148 | + if g.Config.Windows == nil { |
| 149 | + g.Config.Windows = &rspec.Windows{} |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +func (g *Generator) initConfigWindowsHyperV() { |
| 154 | + g.initConfigWindows() |
| 155 | + if g.Config.Windows.HyperV == nil { |
| 156 | + g.Config.Windows.HyperV = &rspec.WindowsHyperV{} |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | +func (g *Generator) initConfigWindowsResources() { |
| 161 | + g.initConfigWindows() |
| 162 | + if g.Config.Windows.Resources == nil { |
| 163 | + g.Config.Windows.Resources = &rspec.WindowsResources{} |
| 164 | + } |
| 165 | +} |
| 166 | + |
| 167 | +func (g *Generator) initConfigWindowsResourcesMemory() { |
| 168 | + g.initConfigWindowsResources() |
| 169 | + if g.Config.Windows.Resources.Memory == nil { |
| 170 | + g.Config.Windows.Resources.Memory = &rspec.WindowsMemoryResources{} |
| 171 | + } |
| 172 | +} |
0 commit comments