-
Notifications
You must be signed in to change notification settings - Fork 28
/
types.go
108 lines (94 loc) · 3.37 KB
/
types.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package testdefinition
import (
"fmt"
"path"
argov1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
apiv1 "k8s.io/api/core/v1"
tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
"github.com/gardener/test-infra/pkg/testmachinery"
"github.com/gardener/test-infra/pkg/testmachinery/config"
)
// TestDefinition represents a TestDefinition which was fetched from locations.
type TestDefinition struct {
Info *tmv1beta1.TestDefinition
Location Location
FileName string
Template *argov1.Template
Volumes []apiv1.Volume
inputArtifacts ArtifactSet
outputArtifacts ArtifactSet
config config.Set
}
// Location is an interface for different testDefLocation types like git or local
type Location interface {
// SetTestDefs adds Testdefinitions to the map.
SetTestDefs(map[string]*TestDefinition) error
// Type returns the tmv1beta1.LocationType type.
Type() tmv1beta1.LocationType
// Name returns the unique name of the location.
Name() string
// GetLocation returns the original TestLocation object
GetLocation() *tmv1beta1.TestLocation
// GitInfo returns the current git information
GitInfo() GitInfo
}
// GitInfo describes additional information about the used sources.
type GitInfo struct {
SHA string
Ref string
}
// GetStdInputArtifacts returns the default input artifacts of testdefionitions.
// The artifacts include kubeconfigs and shared folder inputs
func GetStdInputArtifacts() []argov1.Artifact {
return []argov1.Artifact{
{
Name: testmachinery.ArtifactKubeconfigs,
Path: testmachinery.TM_KUBECONFIG_PATH,
Optional: true,
},
{
Name: testmachinery.ArtifactSharedFolder,
Path: testmachinery.TM_SHARED_PATH,
Optional: true,
},
}
}
// GetUntrustedInputArtifacts returns the untrusted input artifacts of testdefionitions.
// The artifacts only include minimal configuration
func GetUntrustedInputArtifacts() []argov1.Artifact {
return []argov1.Artifact{
{
Name: testmachinery.ArtifactUntrustedKubeconfigs,
Path: path.Join(testmachinery.TM_KUBECONFIG_PATH, tmv1beta1.ShootKubeconfigName),
Optional: true,
},
}
}
// GetStdOutputArtifacts returns the default output artifacts of a step.
// These artifacts include kubeconfigs and the shared folder.
func GetStdOutputArtifacts(global bool) []argov1.Artifact {
kubeconfigArtifact := argov1.Artifact{
Name: testmachinery.ArtifactKubeconfigs,
Path: testmachinery.TM_KUBECONFIG_PATH,
Optional: true,
}
untrustedKubeconfigArtifact := argov1.Artifact{
Name: testmachinery.ArtifactUntrustedKubeconfigs,
Path: path.Join(testmachinery.TM_KUBECONFIG_PATH, tmv1beta1.ShootKubeconfigName),
Optional: true,
}
sharedFolderArtifact := argov1.Artifact{
Name: testmachinery.ArtifactSharedFolder,
Path: testmachinery.TM_SHARED_PATH,
Optional: true,
}
if global {
kubeconfigArtifact.GlobalName = kubeconfigArtifact.Name
kubeconfigArtifact.Name = fmt.Sprintf("%s-global", kubeconfigArtifact.Name)
untrustedKubeconfigArtifact.GlobalName = untrustedKubeconfigArtifact.Name
untrustedKubeconfigArtifact.Name = fmt.Sprintf("%s-global", untrustedKubeconfigArtifact.Name)
sharedFolderArtifact.GlobalName = sharedFolderArtifact.Name
sharedFolderArtifact.Name = fmt.Sprintf("%s-global", sharedFolderArtifact.Name)
}
return []argov1.Artifact{kubeconfigArtifact, untrustedKubeconfigArtifact, sharedFolderArtifact}
}