File: config.go

package info (click to toggle)
gitlab-ci-multi-runner 14.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 31,248 kB
  • sloc: sh: 1,694; makefile: 384; asm: 79; ruby: 68
file content (45 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download
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
package custom

import (
	"time"

	"gitlab.com/gitlab-org/gitlab-runner/common"
	"gitlab.com/gitlab-org/gitlab-runner/helpers/process"
)

type config struct {
	*common.CustomConfig
}

func (c *config) GetConfigExecTimeout() time.Duration {
	return getDuration(c.ConfigExecTimeout, defaultConfigExecTimeout)
}

func (c *config) GetPrepareExecTimeout() time.Duration {
	return getDuration(c.PrepareExecTimeout, defaultPrepareExecTimeout)
}

func (c *config) GetCleanupScriptTimeout() time.Duration {
	return getDuration(c.CleanupExecTimeout, defaultCleanupExecTimeout)
}

func (c *config) GetGracefulKillTimeout() time.Duration {
	return getDuration(c.GracefulKillTimeout, process.GracefulTimeout)
}

func (c *config) GetForceKillTimeout() time.Duration {
	return getDuration(c.ForceKillTimeout, process.KillTimeout)
}

func getDuration(source *int, defaultValue time.Duration) time.Duration {
	if source == nil {
		return defaultValue
	}

	timeout := *source
	if timeout <= 0 {
		return defaultValue
	}

	return time.Duration(timeout) * time.Second
}