forked from devtron-labs/devtron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbean.go
129 lines (117 loc) · 6.68 KB
/
bean.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package plugin
import (
"github.com/devtron-labs/devtron/pkg/plugin/repository"
"github.com/devtron-labs/devtron/pkg/sql"
)
const (
CREATEPLUGIN = 0
UPDATEPLUGIN = 1
DELETEPLUGIN = 2
CI_TYPE_PLUGIN = "CI"
CD_TYPE_PLUGIN = "CD"
CI_CD_TYPE_PLUGIN = "CI_CD"
)
type PluginDetailDto struct {
Metadata *PluginMetadataDto `json:"metadata"`
InputVariables []*PluginVariableDto `json:"inputVariables"`
OutputVariables []*PluginVariableDto `json:"outputVariables"`
}
type PluginListComponentDto struct { //created new struct for backward compatibility (needed to add input and output Vars along with metadata fields)
*PluginMetadataDto
InputVariables []*PluginVariableDto `json:"inputVariables"`
OutputVariables []*PluginVariableDto `json:"outputVariables"`
}
type PluginMetadataDto struct {
Id int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type" validate:"oneof=SHARED PRESET"` // SHARED, PRESET etc
Icon string `json:"icon"`
Tags []string `json:"tags"`
Action int `json:"action"`
PluginStage string `json:"pluginStage,omitempty"`
PluginSteps []*PluginStepsDto `json:"pluginSteps,omitempty"`
}
func (r *PluginMetadataDto) getPluginMetadataSqlObj(userId int32) *repository.PluginMetadata {
return &repository.PluginMetadata{
Name: r.Name,
Description: r.Description,
Type: repository.PluginType(r.Type),
Icon: r.Icon,
AuditLog: sql.NewDefaultAuditLog(userId),
}
}
type PluginStepsDto struct {
Id int `json:"id,pk"`
Name string `json:"name"`
Description string `json:"description"`
Index int `json:"index"`
StepType repository.PluginStepType `json:"stepType"`
RefPluginId int `json:"refPluginId"` //id of plugin used as reference
OutputDirectoryPath []string `json:"outputDirectoryPath"`
DependentOnStep string `json:"dependentOnStep"`
PluginStepVariable []*PluginVariableDto `json:"pluginStepVariable,omitempty"`
PluginPipelineScript *PluginPipelineScript `json:"pluginPipelineScript,omitempty"`
}
type PluginVariableDto struct {
Id int `json:"id,omitempty"`
Name string `json:"name"`
Format repository.PluginStepVariableFormatType `json:"format"`
Description string `json:"description"`
IsExposed bool `json:"isExposed"`
AllowEmptyValue bool `json:"allowEmptyValue"`
DefaultValue string `json:"defaultValue"`
Value string `json:"value,omitempty"`
VariableType repository.PluginStepVariableType `json:"variableType"`
ValueType repository.PluginStepVariableValueType `json:"valueType,omitempty"`
PreviousStepIndex int `json:"previousStepIndex,omitempty"`
VariableStepIndex int `json:"variableStepIndex"`
VariableStepIndexInPlugin int `json:"variableStepIndexInPlugin"`
ReferenceVariableName string `json:"referenceVariableName,omitempty"`
PluginStepCondition []*PluginStepCondition `json:"pluginStepCondition,omitempty"`
}
type PluginPipelineScript struct {
Id int `json:"id"`
Script string `json:"script"`
StoreScriptAt string `json:"storeScriptAt"`
Type repository.ScriptType `json:"type"`
DockerfileExists bool `json:"dockerfileExists"`
MountPath string `json:"mountPath"`
MountCodeToContainer bool `json:"mountCodeToContainer"`
MountCodeToContainerPath string `json:"mountCodeToContainerPath"`
MountDirectoryFromHost bool `json:"mountDirectoryFromHost"`
ContainerImagePath string `json:"containerImagePath"`
ImagePullSecretType repository.ScriptImagePullSecretType `json:"imagePullSecretType"`
ImagePullSecret string `json:"imagePullSecret"`
Deleted bool `json:"deleted"`
PathArgPortMapping []*ScriptPathArgPortMapping `json:"pathArgPortMapping"`
}
type PluginStepCondition struct {
Id int `json:"id"`
PluginStepId int `json:"pluginStepId"`
ConditionVariableId int `json:"conditionVariableId"` //id of variable on which condition is written
ConditionType repository.PluginStepConditionType `json:"conditionType"`
ConditionalOperator string `json:"conditionalOperator"`
ConditionalValue string `json:"conditionalValue"`
Deleted bool `json:"deleted"`
}
type ScriptPathArgPortMapping struct {
Id int `json:"id"`
TypeOfMapping repository.ScriptMappingType `json:"typeOfMapping"`
FilePathOnDisk string `json:"filePathOnDisk"`
FilePathOnContainer string `json:"filePathOnContainer"`
Command string `json:"command"`
Args []string `json:"args"`
PortOnLocal int `json:"portOnLocal"`
PortOnContainer int `json:"portOnContainer"`
ScriptId int `json:"scriptId"`
}
type RegistryCredentials struct {
RegistryType string `json:"registryType" validate:"required"`
RegistryURL string `json:"registryURL"`
Username string `json:"username"`
Password string `json:"password"`
AWSAccessKeyId string `json:"awsAccessKeyId,omitempty"`
AWSSecretAccessKey string `json:"awsSecretAccessKey,omitempty"`
AWSRegion string `json:"awsRegion,omitempty"`
}