Stitch any CI into Tangled
151
fork

Configure Feed

Select the types of activity you want to include in your feed.

provider/tekton: add workspace config to tangled config

This allows you to create a workspace PVC for cloning a git repo so you
can run go test in it.

Signed-off-by: Xe Iaso <me@xeiaso.net>

authored by

Xe Iaso and committed by
Tangled
029d13be a318f262

+52 -3
+52 -3
provider_tekton.go
··· 57 57 // runner and pass a small amount of routing data, not mirror Tekton's 58 58 // entire PipelineRun API. 59 59 type tektonWorkflowConfig struct { 60 - Pipeline string `yaml:"pipeline"` 61 - ServiceAccount string `yaml:"service_account"` 62 - Params map[string]string `yaml:"params"` 60 + Pipeline string `yaml:"pipeline"` 61 + ServiceAccount string `yaml:"service_account"` 62 + Params map[string]string `yaml:"params"` 63 + Workspaces []tektonWorkspaceConfig `yaml:"workspaces"` 64 + } 65 + 66 + type tektonWorkspaceConfig struct { 67 + Name string `yaml:"name"` 68 + AccessModes []string `yaml:"access_modes"` 69 + Storage *string `yaml:"storage"` 70 + PVC *string `yaml:"pvc"` 63 71 } 64 72 65 73 type tektonWorkflowDoc struct { ··· 261 269 }, 262 270 }, 263 271 } 272 + 264 273 spec := obj["spec"].(map[string]any) 274 + 275 + if len(cfg.Workspaces) != 0 { 276 + spec["podTemplate"] = map[string]any{ 277 + "securityContext": map[string]any{ 278 + "fsGroup": 65532, 279 + }, 280 + } 281 + 282 + workspaces := []any{} 283 + 284 + for _, ws := range cfg.Workspaces { 285 + switch { 286 + case ws.Storage != nil: 287 + workspaces = append(workspaces, map[string]any{ 288 + "name": ws.Name, 289 + "volumeClaimTemplate": map[string]any{ 290 + "spec": map[string]any{ 291 + "accessModes": ws.AccessModes, 292 + "resources": map[string]any{ 293 + "requests": map[string]any{ 294 + "storage": *ws.Storage, 295 + }, 296 + }, 297 + }, 298 + }, 299 + }) 300 + 301 + case ws.PVC != nil: 302 + workspaces = append(workspaces, map[string]any{ 303 + "name": ws.Name, 304 + "persistentVolumeClaim": map[string]any{ 305 + "claimName": *ws.PVC, 306 + }, 307 + }) 308 + } 309 + } 310 + 311 + spec["workspaces"] = workspaces 312 + } 313 + 265 314 if cfg.ServiceAccount != "" { 266 315 spec["serviceAccountName"] = cfg.ServiceAccount 267 316 }