-
Notifications
You must be signed in to change notification settings - Fork 89
/
engine_linux.go
53 lines (46 loc) · 1.84 KB
/
engine_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2018-2019, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
package singularity
import (
"github.com/sylabs/singularity/v4/internal/pkg/runtime/engine"
"github.com/sylabs/singularity/v4/internal/pkg/runtime/engine/singularity/rpc/server"
"github.com/sylabs/singularity/v4/pkg/runtime/engine/config"
singularityConfig "github.com/sylabs/singularity/v4/pkg/runtime/engine/singularity/config"
)
// EngineOperations is a Singularity runtime engine that implements engine.Operations.
// Basically, this is the core of `singularity run/exec/shell/instance` commands.
type EngineOperations struct {
CommonConfig *config.Common `json:"-"`
EngineConfig *singularityConfig.EngineConfig `json:"engineConfig"`
}
// InitConfig stores the parsed config.Common inside the engine.
//
// Since this method simply stores config.Common, it does not matter
// whether or not there are any elevated privileges during this call.
func (e *EngineOperations) InitConfig(cfg *config.Common) {
e.CommonConfig = cfg
}
// Config returns a pointer to a singularityConfig.EngineConfig
// literal as a config.EngineConfig interface. This pointer
// gets stored in the engine.Engine.Common field.
//
// Since this method simply returns a zero value of the concrete
// EngineConfig, it does not matter whether or not there are any elevated
// privileges during this call.
func (e *EngineOperations) Config() config.EngineConfig {
return e.EngineConfig
}
func init() {
engine.RegisterOperations(
singularityConfig.Name,
&EngineOperations{
EngineConfig: singularityConfig.NewConfig(),
},
)
engine.RegisterRPCMethods(
singularityConfig.Name,
new(server.Methods),
)
}