generated from LinuxSuRen/.github
/
s2i_types.go
107 lines (93 loc) · 3.56 KB
/
s2i_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
// Code generated by github.com/kubesphere/kubesphere; DO NOT EDIT.
// copy this file due to cannot import them directly
package source2image
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
ResourceKindS2iBuilderTemplate = "S2iBuilderTemplate"
ResourceSingularS2iBuilderTemplate = "s2ibuildertemplate"
ResourcePluralS2iBuilderTemplate = "s2ibuildertemplates"
)
type Parameter struct {
Description string `json:"description,omitempty"`
Key string `json:"key,omitempty"`
Type string `json:"type,omitempty"`
OptValues []string `json:"optValues,omitempty"`
Required bool `json:"required,omitempty"`
DefaultValue string `json:"defaultValue,omitempty"`
Value string `json:"value,omitempty"`
}
// CodeFramework is the alias of string
type CodeFramework string
const (
// Ruby is the name of Ruby framework
Ruby CodeFramework = "ruby"
// Go is the name of Go framework
Go CodeFramework = "go"
// Java is the name of Java framework
Java CodeFramework = "Java"
// JavaTomcat is the name of JavaTomcat framework
JavaTomcat CodeFramework = "JavaTomcat"
// Nodejs is the name of Nodejs framework
Nodejs CodeFramework = "Nodejs"
// Python is the name of python framework
Python CodeFramework = "python"
)
func (p *Parameter) ToEnvonment() *EnvironmentSpec {
var v string
if p.Value == "" && p.DefaultValue != "" {
v = p.DefaultValue
} else if p.Value != "" {
v = p.Value
} else {
return nil
}
return &EnvironmentSpec{
Name: p.Key,
Value: v,
}
}
// S2iBuilderTemplateSpec defines the desired state of S2iBuilderTemplate
type S2iBuilderTemplateSpec struct {
//DefaultBaseImage is the image that will be used by default
DefaultBaseImage string `json:"defaultBaseImage,omitempty"`
//Images are the images this template will use.
ContainerInfo []ContainerInfo `json:"containerInfo,omitempty"`
//CodeFramework means which language this template is designed for and which framework is using if has framework. Like Java, NodeJS etc
CodeFramework CodeFramework `json:"codeFramework,omitempty"`
// Parameters is a set of environment variables to be passed to the image.
Parameters []Parameter `json:"environment,omitempty"`
// Version of template
Version string `json:"version,omitempty"`
// Description illustrate the purpose of this template
Description string `json:"description,omitempty"`
// IconPath is used for frontend display
IconPath string `json:"iconPath,omitempty"`
}
type ContainerInfo struct {
//BaseImage are the images this template will use.
BuilderImage string `json:"builderImage,omitempty"`
RuntimeImage string `json:"runtimeImage,omitempty"`
RuntimeArtifacts []VolumeSpec `json:"runtimeArtifacts,omitempty"`
// BuildVolumes specifies a list of volumes to mount to container running the
// build.
BuildVolumes []string `json:"buildVolumes,omitempty"`
}
// S2iBuilderTemplateStatus defines the observed state of S2iBuilderTemplate
type S2iBuilderTemplateStatus struct {
}
// S2iBuilderTemplate is the Schema for the s2ibuildertemplates API
type S2iBuilderTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec S2iBuilderTemplateSpec `json:"spec,omitempty"`
Status S2iBuilderTemplateStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// S2iBuilderTemplateList contains a list of S2iBuilderTemplate
type S2iBuilderTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []S2iBuilderTemplate `json:"items"`
}