BlueGit

timfa bluegit

Files

bluegit / internal / ci / model.go

model.go

model.go 3.4 KiB Download Raw
1package ci
2
3import "time"
4
5// Pipeline is een geparset blue-ci-cd.yml.
6type Pipeline struct {
7 Stages []string
8 Variables map[string]string
9 Image string
10 Before []string
11 After []string
12 Cache Cache
13 Timeout time.Duration
14 Tags []string
15 Jobs []Job
16 Warnings []Issue
17 Workflow []Rule
18}
19
20// Job is één containerstap.
21type Job struct {
22 Name string
23 Stage string
24 Image string
25 Before []string
26 Script []string
27 After []string
28 Needs []string
29 Optional []string
30 NeedsSet bool
31 Variables map[string]string
32 Artifacts Artifacts
33 Rules []Rule
34 AllowFailure bool
35 When string
36 Timeout time.Duration
37 Tags []string
38 Cache Cache
39 ResourceGroup string
40 Only []string
41 Except []string
42 Retry Retry
43 Parallel int
44 Matrix []MatrixSpec
45 Services []Service
46 Environment Environment
47 Interruptible bool
48 // DoNotInterrupt: nooit automatisch halverwege stoppen (doNotInterrupt).
49 DoNotInterrupt bool
50}
51
52// Retry is het aantal extra pogingen na een mislukking. Max is hoogstens 2.
53// Een lege When betekent elke mislukking behalve een annulering.
54type Retry struct {
55 Max int
56 When []string
57}
58
59// MatrixSpec is één item uit parallel:matrix. Keys staan in YAML-volgorde.
60type MatrixSpec struct {
61 Keys []string
62 Vals [][]string
63}
64
65// Service is een sidecar-container op hetzelfde Docker-netwerk als de job.
66type Service struct {
67 Name string
68 Alias string
69 Command []string
70 Entrypoint []string
71 Variables map[string]string
72}
73
74// Environment is de naam en een optionele URL. Er is geen deployment.
75type Environment struct {
76 Name string
77 URL string
78}
79
80// Artifacts zijn paden die na een geslaagde job bewaard blijven.
81type Artifacts struct {
82 Paths []string
83 ExpireIn time.Duration
84}
85
86// Cache is een map die tussen jobs van één repository gedeeld wordt.
87type Cache struct {
88 Key string
89 Paths []string
90}
91
92// Rule is één voorwaarde. De eerste rule die klopt wint.
93// Zonder rules draait de job, tenzij only of except dat tegenhoudt.
94type Rule struct {
95 If string
96 Changes []string
97 Exists []string
98 When string
99}
100
101// Issue is een fout of een waarschuwing met een regelnummer.
102type Issue struct {
103 Line int
104 Key string
105 Args []any
106 Warning bool
107}
108
109// Eval is de context waarin rules worden beoordeeld.
110// Changed == nil betekent dat de diff onbekend is; changes klopt dan.
111// Files == nil betekent dat de boom onbekend is; exists klopt dan.
112type Eval struct {
113 Env map[string]string
114 Changed []string
115 Files []string
116 // workflowMR: workflow:rules staat merge-request-pipelines expliciet
117 // toe. Jobs zonder rules of only draaien dan ook daarin.
118 workflowMR bool
119}
120
121// MRInfo is de merge request waar een pipeline bij hoort.
122// Leeg betekent een gewone branch- of tag-pipeline.
123type MRInfo struct {
124 ID int64
125 IID int64
126 Title string
127 SourceBranch string
128 TargetBranch string
129 ProjectPath string
130 ProjectURL string
131 TargetSHA string
132}
133
134// Ref beschrijft de commit waarvoor voorgedefinieerde variabelen gelden.
135type Ref struct {
136 SHA string
137 FullRef string
138 Name string
139 Kind string
140 Title string
141 Timestamp string // committer-tijd, ISO 8601
142 DefaultBranch string
143 Source string
144 ProjectPath string
145 ProjectURL string
146 APIURL string
147 PipelineID int64
148 MR *MRInfo
149}