-
Notifications
You must be signed in to change notification settings - Fork 12
/
stage.go
58 lines (50 loc) · 1.39 KB
/
stage.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: Apache-2.0
package pipeline
import (
"github.com/sirupsen/logrus"
"github.com/go-vela/server/compiler/types/yaml"
)
func stages(pipelineType string) *yaml.Build {
logrus.Debugf("creating %s stages pipeline", pipelineType)
// create default image for stages pipeline
image := "alpine:latest"
// create default commands for stages pipeline
commands := []string{"echo hello"}
// handle the pipeline based off the provided type
switch pipelineType {
case "go", "golang":
// set the image for a go stages pipeline
image = "golang:latest"
// set the commands for a go stages pipeline
commands = []string{"go version"}
case "java":
// set the image for a java stages pipeline
image = "openjdk:latest"
// set the commands for a java stages pipeline
commands = []string{"java --version"}
case "node", "node.js":
// set the image for a node stages pipeline
image = "node:latest"
// set the commands for a node stages pipeline
commands = []string{"node --version"}
}
// return a stages pipeline based off the type
//
// https://pkg.go.dev/github.com/go-vela/server/compiler/types/yaml?tab=doc#Build
return &yaml.Build{
Version: "1",
Stages: yaml.StageSlice{
{
Name: "version",
Steps: yaml.StepSlice{
{
Commands: commands,
Image: image,
Name: "version",
Pull: "always",
},
},
},
},
}
}