forked from kata-containers/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kata_shim.go
61 lines (47 loc) · 1.32 KB
/
kata_shim.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
54
55
56
57
58
59
60
61
// Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package virtcontainers
import (
"fmt"
)
type kataShim struct{}
// start is the ccShim start implementation.
// It starts the cc-shim binary with URL and token flags provided by
// the proxy.
func (s *kataShim) start(sandbox *Sandbox, params ShimParams) (int, error) {
if sandbox.config == nil {
return -1, fmt.Errorf("Sandbox config cannot be nil")
}
config, ok := newShimConfig(*(sandbox.config)).(ShimConfig)
if !ok {
return -1, fmt.Errorf("Wrong shim config type, should be ShimConfig type")
}
if config.Path == "" {
return -1, fmt.Errorf("Shim path cannot be empty")
}
if params.URL == "" {
return -1, fmt.Errorf("URL cannot be empty")
}
if params.Container == "" {
return -1, fmt.Errorf("Container cannot be empty")
}
if params.Token == "" {
return -1, fmt.Errorf("Process token cannot be empty")
}
args := []string{config.Path, "-agent", params.URL, "-container", params.Container, "-exec-id", params.Token}
if params.Terminal {
args = append(args, "-terminal")
}
if config.Debug {
args = append(args, "-log", "debug")
if params.ConsoleURL != "" {
args = append(args, "-agent-logs-socket", params.ConsoleURL)
}
}
if config.Trace {
args = append(args, "-trace")
}
return startShim(args, params)
}