-
Notifications
You must be signed in to change notification settings - Fork 12
/
step.go
53 lines (45 loc) · 1.3 KB
/
step.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
// SPDX-License-Identifier: Apache-2.0
package pipeline
import (
"github.com/sirupsen/logrus"
"github.com/go-vela/server/compiler/types/yaml"
)
func steps(pipelineType string) *yaml.Build {
logrus.Debugf("creating %s steps pipeline", pipelineType)
// create default image for steps pipeline
image := "alpine:latest"
// create default commands for steps pipeline
commands := []string{"echo hello"}
// handle the pipeline based off the provided type
switch pipelineType {
case "go", "golang":
// set the image for a go steps pipeline
image = "golang:latest"
// set the commands for a go steps pipeline
commands = []string{"go version"}
case "java":
// set the image for a java steps pipeline
image = "openjdk:latest"
// set the commands for a java steps pipeline
commands = []string{"java --version"}
case "node", "node.js":
// set the image for a node steps pipeline
image = "node:latest"
// set the commands for a node steps pipeline
commands = []string{"node --version"}
}
// return a steps 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",
Steps: yaml.StepSlice{
{
Commands: commands,
Image: image,
Name: "version",
Pull: "always",
},
},
}
}