| 1 | package ci |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | // Pipeline is een geparset blue-ci-cd.yml. |
| 6 | type 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. |
| 21 | type 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 | } |
| 49 | |
| 50 | // Retry is het aantal extra pogingen na een mislukking. Max is hoogstens 2. |
| 51 | // Een lege When betekent elke mislukking behalve een annulering. |
| 52 | type Retry struct { |
| 53 | Max int |
| 54 | When []string |
| 55 | } |
| 56 | |
| 57 | // MatrixSpec is één item uit parallel:matrix. Keys staan in YAML-volgorde. |
| 58 | type MatrixSpec struct { |
| 59 | Keys []string |
| 60 | Vals [][]string |
| 61 | } |
| 62 | |
| 63 | // Service is een sidecar-container op hetzelfde Docker-netwerk als de job. |
| 64 | type Service struct { |
| 65 | Name string |
| 66 | Alias string |
| 67 | Command []string |
| 68 | Entrypoint []string |
| 69 | Variables map[string]string |
| 70 | } |
| 71 | |
| 72 | // Environment is de naam en een optionele URL. Er is geen deployment. |
| 73 | type Environment struct { |
| 74 | Name string |
| 75 | URL string |
| 76 | } |
| 77 | |
| 78 | // Artifacts zijn paden die na een geslaagde job bewaard blijven. |
| 79 | type Artifacts struct { |
| 80 | Paths []string |
| 81 | ExpireIn time.Duration |
| 82 | } |
| 83 | |
| 84 | // Cache is een map die tussen jobs van één repository gedeeld wordt. |
| 85 | type Cache struct { |
| 86 | Key string |
| 87 | Paths []string |
| 88 | } |
| 89 | |
| 90 | // Rule is één voorwaarde. De eerste rule die klopt wint. |
| 91 | // Zonder rules draait de job, tenzij only of except dat tegenhoudt. |
| 92 | type Rule struct { |
| 93 | If string |
| 94 | Changes []string |
| 95 | Exists []string |
| 96 | When string |
| 97 | } |
| 98 | |
| 99 | // Issue is een fout of een waarschuwing met een regelnummer. |
| 100 | type Issue struct { |
| 101 | Line int |
| 102 | Key string |
| 103 | Args []any |
| 104 | Warning bool |
| 105 | } |
| 106 | |
| 107 | // Eval is de context waarin rules worden beoordeeld. |
| 108 | // Changed == nil betekent dat de diff onbekend is; changes klopt dan. |
| 109 | // Files == nil betekent dat de boom onbekend is; exists klopt dan. |
| 110 | type Eval struct { |
| 111 | Env map[string]string |
| 112 | Changed []string |
| 113 | Files []string |
| 114 | // workflowMR: workflow:rules staat merge-request-pipelines expliciet |
| 115 | // toe. Jobs zonder rules of only draaien dan ook daarin. |
| 116 | workflowMR bool |
| 117 | } |
| 118 | |
| 119 | // MRInfo is de merge request waar een pipeline bij hoort. |
| 120 | // Leeg betekent een gewone branch- of tag-pipeline. |
| 121 | type MRInfo struct { |
| 122 | ID int64 |
| 123 | IID int64 |
| 124 | Title string |
| 125 | SourceBranch string |
| 126 | TargetBranch string |
| 127 | ProjectPath string |
| 128 | ProjectURL string |
| 129 | TargetSHA string |
| 130 | } |
| 131 | |
| 132 | // Ref beschrijft de commit waarvoor voorgedefinieerde variabelen gelden. |
| 133 | type Ref struct { |
| 134 | SHA string |
| 135 | FullRef string |
| 136 | Name string |
| 137 | Kind string |
| 138 | Title string |
| 139 | Timestamp string // committer-tijd, ISO 8601 |
| 140 | DefaultBranch string |
| 141 | Source string |
| 142 | ProjectPath string |
| 143 | ProjectURL string |
| 144 | APIURL string |
| 145 | PipelineID int64 |
| 146 | MR *MRInfo |
| 147 | } |