github.com/opencontainers/runtime-tools@v0.9.0/generate/config.go (about)

     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  // InitConfigLinuxResourcesCPU initializes CPU of Linux resources
    98  func (g *Generator) InitConfigLinuxResourcesCPU() {
    99  	g.initConfigLinuxResources()
   100  	if g.Config.Linux.Resources.CPU == nil {
   101  		g.Config.Linux.Resources.CPU = &rspec.LinuxCPU{}
   102  	}
   103  }
   104  
   105  func (g *Generator) initConfigLinuxResourcesMemory() {
   106  	g.initConfigLinuxResources()
   107  	if g.Config.Linux.Resources.Memory == nil {
   108  		g.Config.Linux.Resources.Memory = &rspec.LinuxMemory{}
   109  	}
   110  }
   111  
   112  func (g *Generator) initConfigLinuxResourcesNetwork() {
   113  	g.initConfigLinuxResources()
   114  	if g.Config.Linux.Resources.Network == nil {
   115  		g.Config.Linux.Resources.Network = &rspec.LinuxNetwork{}
   116  	}
   117  }
   118  
   119  func (g *Generator) initConfigLinuxResourcesPids() {
   120  	g.initConfigLinuxResources()
   121  	if g.Config.Linux.Resources.Pids == nil {
   122  		g.Config.Linux.Resources.Pids = &rspec.LinuxPids{}
   123  	}
   124  }
   125  
   126  func (g *Generator) initConfigSolaris() {
   127  	g.initConfig()
   128  	if g.Config.Solaris == nil {
   129  		g.Config.Solaris = &rspec.Solaris{}
   130  	}
   131  }
   132  
   133  func (g *Generator) initConfigSolarisCappedCPU() {
   134  	g.initConfigSolaris()
   135  	if g.Config.Solaris.CappedCPU == nil {
   136  		g.Config.Solaris.CappedCPU = &rspec.SolarisCappedCPU{}
   137  	}
   138  }
   139  
   140  func (g *Generator) initConfigSolarisCappedMemory() {
   141  	g.initConfigSolaris()
   142  	if g.Config.Solaris.CappedMemory == nil {
   143  		g.Config.Solaris.CappedMemory = &rspec.SolarisCappedMemory{}
   144  	}
   145  }
   146  
   147  func (g *Generator) initConfigWindows() {
   148  	g.initConfig()
   149  	if g.Config.Windows == nil {
   150  		g.Config.Windows = &rspec.Windows{}
   151  	}
   152  }
   153  
   154  func (g *Generator) initConfigWindowsNetwork() {
   155  	g.initConfigWindows()
   156  	if g.Config.Windows.Network == nil {
   157  		g.Config.Windows.Network = &rspec.WindowsNetwork{}
   158  	}
   159  }
   160  
   161  func (g *Generator) initConfigWindowsHyperV() {
   162  	g.initConfigWindows()
   163  	if g.Config.Windows.HyperV == nil {
   164  		g.Config.Windows.HyperV = &rspec.WindowsHyperV{}
   165  	}
   166  }
   167  
   168  func (g *Generator) initConfigWindowsResources() {
   169  	g.initConfigWindows()
   170  	if g.Config.Windows.Resources == nil {
   171  		g.Config.Windows.Resources = &rspec.WindowsResources{}
   172  	}
   173  }
   174  
   175  func (g *Generator) initConfigWindowsResourcesMemory() {
   176  	g.initConfigWindowsResources()
   177  	if g.Config.Windows.Resources.Memory == nil {
   178  		g.Config.Windows.Resources.Memory = &rspec.WindowsMemoryResources{}
   179  	}
   180  }
   181  
   182  func (g *Generator) initConfigVM() {
   183  	g.initConfig()
   184  	if g.Config.VM == nil {
   185  		g.Config.VM = &rspec.VM{}
   186  	}
   187  }
   188  
   189  func (g *Generator) initConfigVMHypervisor() {
   190  	g.initConfigVM()
   191  	if &g.Config.VM.Hypervisor == nil {
   192  		g.Config.VM.Hypervisor = rspec.VMHypervisor{}
   193  	}
   194  }
   195  
   196  func (g *Generator) initConfigVMKernel() {
   197  	g.initConfigVM()
   198  	if &g.Config.VM.Kernel == nil {
   199  		g.Config.VM.Kernel = rspec.VMKernel{}
   200  	}
   201  }
   202  
   203  func (g *Generator) initConfigVMImage() {
   204  	g.initConfigVM()
   205  	if &g.Config.VM.Image == nil {
   206  		g.Config.VM.Image = rspec.VMImage{}
   207  	}
   208  }