/
tekton_task.go
82 lines (77 loc) · 2.26 KB
/
tekton_task.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package system
import (
"fmt"
"github.com/3scale-ops/basereconciler/util"
"github.com/3scale-ops/saas-operator/pkg/resource_builders/twemproxy"
pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func (gen *SystemTektonGenerator) task() *pipelinev1beta1.Task {
task := &pipelinev1beta1.Task{
ObjectMeta: metav1.ObjectMeta{
Name: gen.GetComponent(),
Namespace: gen.GetNamespace(),
Labels: gen.GetLabels(),
},
Spec: pipelinev1beta1.TaskSpec{
DisplayName: gen.GetComponent(),
Description: *gen.Spec.Description,
Params: []pipelinev1beta1.ParamSpec{
{
Name: "container-image",
Description: "Container image for the task",
Default: &pipelinev1beta1.ParamValue{
StringVal: fmt.Sprint(*gen.Image.Name),
Type: pipelinev1beta1.ParamTypeString,
},
Type: pipelinev1beta1.ParamTypeString,
},
{
Name: "container-tag",
Description: "Container tag for the task",
Default: &pipelinev1beta1.ParamValue{
StringVal: fmt.Sprint(*gen.Image.Tag),
Type: pipelinev1beta1.ParamTypeString,
},
Type: pipelinev1beta1.ParamTypeString,
},
},
StepTemplate: &pipelinev1beta1.StepTemplate{
Image: "$(params.container-image):$(params.container-tag)",
Env: gen.Options.WithExtraEnv(gen.Spec.Config.ExtraEnv).BuildEnvironment(),
},
Steps: []pipelinev1beta1.Step{
{
Name: "task-command",
Command: gen.Spec.Config.Command,
Args: gen.Spec.Config.Args,
Resources: corev1.ResourceRequirements(*gen.Spec.Resources),
VolumeMounts: []corev1.VolumeMount{
{
Name: "system-config",
ReadOnly: true,
MountPath: "/opt/system-extra-configs",
},
},
Timeout: gen.Spec.Config.Timeout,
},
},
Volumes: []corev1.Volume{
{
Name: "system-config",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
DefaultMode: util.Pointer[int32](420),
SecretName: gen.ConfigFilesSecret,
},
},
},
},
},
}
if gen.TwemproxySpec != nil {
task.Spec = twemproxy.AddTwemproxyTaskSidecar(task.Spec, gen.TwemproxySpec)
}
return task
}