github.com/hpcng/singularity@v3.1.1+incompatible/internal/pkg/runtime/engines/oci/config.go (about)

     1  // Copyright (c) 2018, Sylabs Inc. All rights reserved.
     2  // This software is licensed under a 3-clause BSD license. Please consult the
     3  // LICENSE.md file distributed with the sources of this project regarding your
     4  // rights to use or distribute this software.
     5  
     6  package oci
     7  
     8  import (
     9  	"sync"
    10  
    11  	"github.com/sylabs/singularity/internal/pkg/cgroups"
    12  	"github.com/sylabs/singularity/internal/pkg/runtime/engines/config/oci"
    13  	"github.com/sylabs/singularity/pkg/ociruntime"
    14  )
    15  
    16  // Name of the engine
    17  const Name = "oci"
    18  
    19  // EngineConfig is the config for the OCI engine.
    20  type EngineConfig struct {
    21  	BundlePath    string           `json:"bundlePath"`
    22  	LogPath       string           `json:"logPath"`
    23  	LogFormat     string           `json:"logFormat"`
    24  	PidFile       string           `json:"pidFile"`
    25  	OciConfig     *oci.Config      `json:"ociConfig"`
    26  	State         ociruntime.State `json:"state"`
    27  	MasterPts     int              `json:"masterPts"`
    28  	SlavePts      int              `json:"slavePts"`
    29  	OutputStreams [2]int           `json:"outputStreams"`
    30  	ErrorStreams  [2]int           `json:"errorStreams"`
    31  	InputStreams  [2]int           `json:"inputStreams"`
    32  	SyncSocket    string           `json:"syncSocket"`
    33  	EmptyProcess  bool             `json:"emptyProcess"`
    34  	Exec          bool             `json:"exec"`
    35  	Cgroups       *cgroups.Manager `json:"-"`
    36  	sync.Mutex    `json:"-"`
    37  }
    38  
    39  // NewConfig returns an oci.EngineConfig.
    40  func NewConfig() *EngineConfig {
    41  	ret := &EngineConfig{
    42  		OciConfig: &oci.Config{},
    43  	}
    44  
    45  	return ret
    46  }
    47  
    48  // SetBundlePath sets the container bundle path.
    49  func (e *EngineConfig) SetBundlePath(path string) {
    50  	e.BundlePath = path
    51  }
    52  
    53  // GetBundlePath returns the container bundle path.
    54  func (e *EngineConfig) GetBundlePath() string {
    55  	return e.BundlePath
    56  }
    57  
    58  // SetState sets the container state as defined by OCI state
    59  // specification
    60  func (e *EngineConfig) SetState(state *ociruntime.State) {
    61  	e.State = *state
    62  }
    63  
    64  // GetState returns the container state as defined by OCI state
    65  // specification
    66  func (e *EngineConfig) GetState() *ociruntime.State {
    67  	return &e.State
    68  }
    69  
    70  // SetLogPath sets the container log path.
    71  func (e *EngineConfig) SetLogPath(path string) {
    72  	e.LogPath = path
    73  }
    74  
    75  // GetLogPath returns the container log path.
    76  func (e *EngineConfig) GetLogPath() string {
    77  	return e.LogPath
    78  }
    79  
    80  // SetLogFormat sets the container log format.
    81  func (e *EngineConfig) SetLogFormat(format string) {
    82  	e.LogFormat = format
    83  }
    84  
    85  // GetLogFormat returns the container log format.
    86  func (e *EngineConfig) GetLogFormat() string {
    87  	return e.LogFormat
    88  }
    89  
    90  // SetPidFile sets the pid file path.
    91  func (e *EngineConfig) SetPidFile(path string) {
    92  	e.PidFile = path
    93  }
    94  
    95  // GetPidFile gets the pid file path.
    96  func (e *EngineConfig) GetPidFile() string {
    97  	return e.PidFile
    98  }