-
Notifications
You must be signed in to change notification settings - Fork 83
/
next_step_runner.go
77 lines (62 loc) · 2.42 KB
/
next_step_runner.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package actions
import (
"fmt"
"strconv"
"github.com/openshift/assisted-installer-agent/src/util"
"github.com/openshift/assisted-installer-agent/src/config"
"github.com/go-openapi/swag"
"github.com/openshift/assisted-service/models"
)
type nextStepRunnerAction struct {
args []string
nextStepRunnerParams models.NextStepCmdRequest
agentConfig *config.AgentConfig
}
func NewNextStepRunnerAction(agentConfig *config.AgentConfig, args []string) ActionInterface {
return &nextStepRunnerAction{args: args, agentConfig: agentConfig}
}
func (a *nextStepRunnerAction) Validate() error {
err := ValidateCommon("next step runner", 1, a.args, &a.nextStepRunnerParams)
if err != nil {
return err
}
return nil
}
func (a *nextStepRunnerAction) Run() (stdout, stderr string, exitCode int) {
return util.ExecutePrivileged(a.Command(), a.Args()...)
}
func (a *nextStepRunnerAction) Command() string {
return podman
}
func (a *nextStepRunnerAction) Args() []string {
arguments := []string{"run", "--rm", "-ti", "--privileged", "--pid=host", "--net=host",
// unlimited number of processes in the container
"--pids-limit=0",
"-v", "/dev:/dev:rw", "-v", "/opt:/opt:rw",
"-v", "/run/systemd/journal/socket:/run/systemd/journal/socket",
"-v", "/var/log:/var/log:rw",
"-v", "/run/media:/run/media:rw",
"-v", "/usr/bin/chronyc:/usr/bin/chronyc",
"-v", "/var/run/chrony:/var/run/chrony",
"-v", "/etc/pki:/etc/pki"}
if a.agentConfig.CACertificatePath != "" {
arguments = append(arguments, "-v", fmt.Sprintf("%s:%s", a.agentConfig.CACertificatePath,
a.agentConfig.CACertificatePath))
}
arguments = append(arguments,
"--env", "PULL_SECRET_TOKEN",
"--env", "CONTAINERS_CONF",
"--env", "CONTAINERS_STORAGE_CONF",
"--env", "HTTP_PROXY", "--env", "HTTPS_PROXY", "--env", "NO_PROXY",
"--env", "http_proxy", "--env", "https_proxy", "--env", "no_proxy",
"--name", "next-step-runner", swag.StringValue(a.nextStepRunnerParams.AgentVersion), "next_step_runner",
"--url", a.agentConfig.TargetURL,
"--infra-env-id", a.nextStepRunnerParams.InfraEnvID.String(),
"--host-id", a.nextStepRunnerParams.HostID.String(),
"--agent-version", swag.StringValue(a.nextStepRunnerParams.AgentVersion),
fmt.Sprintf("--insecure=%s", strconv.FormatBool(a.agentConfig.InsecureConnection)))
if a.agentConfig.CACertificatePath != "" {
arguments = append(arguments, "--cacert", a.agentConfig.CACertificatePath)
}
return arguments
}