-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathspec.go
More file actions
40 lines (36 loc) · 1.47 KB
/
spec.go
File metadata and controls
40 lines (36 loc) · 1.47 KB
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
package types
import "time"
// Task is a unit of work that should be run.
type Spec struct {
// Port is the port that should be used for the user interface.
Port *uint16 `json:"port,omitempty"`
// TerminationGracePeriodSeconds is the grace period for terminating the workflow.
TerminationGracePeriodSeconds *int32 `json:"terminationGracePeriodSeconds,omitempty"`
// Tasks is a list of tasks that should be run.
Tasks Tasks `json:"tasks,omitempty"`
// Volumes is a list of volumes that can be mounted by containers belonging to the workflow.
Volumes []Volume `json:"volumes,omitempty"`
// Semaphores is a list of semaphores that can be acquired by tasks.
Semaphores map[string]int `json:"semaphores,omitempty"`
// Environment variables to set in the container or on the host
Env EnvVars `json:"env,omitempty"`
// Environment file (e.g. .env) to use
Envfile Envfile `json:"envfile,omitempty"`
// Lifecycle describes actions that the system should take in response to graph-level lifecycle events.
Lifecycle *Lifecycle `json:"lifecycle,omitempty"`
}
func (s *Spec) GetTerminationGracePeriod() time.Duration {
if s.TerminationGracePeriodSeconds != nil {
return time.Duration(*s.TerminationGracePeriodSeconds) * time.Second
}
return 3 * time.Second
}
// Retuns the environment variables for the spec.
func (s *Spec) Environ() ([]string, error) {
environ, err := s.Envfile.Environ("")
if err != nil {
return nil, err
}
e, err := s.Env.Environ()
return append(environ, e...), err
}