-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBean.go
More file actions
192 lines (165 loc) · 6.15 KB
/
Bean.go
File metadata and controls
192 lines (165 loc) · 6.15 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
* Copyright (c) 2020 Devtron Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package git
import (
"github.com/devtron-labs/git-sensor/internal/sql"
"github.com/devtron-labs/go-git/plumbing/object"
"time"
)
type FetchScmChangesRequest struct {
PipelineMaterialId int `json:"pipelineMaterialId"`
From string `json:"from"`
To string `json:"to"`
Count int `json:"count"`
ShowAll bool `json:"showAll"`
}
type HeadRequest struct {
MaterialIds []int `json:"materialIds"`
}
type CiPipelineMaterialBean struct {
Id int
GitMaterialId int
Type sql.SourceType
Value string
Active bool
GitCommit *GitCommit
ExtraEnvironmentVariables map[string]string // extra env variables which will be used for CI
}
type MaterialChangeResp struct {
Commits []*GitCommit `json:"commits"`
LastFetchTime time.Time `json:"lastFetchTime"`
IsRepoError bool `json:"isRepoError"`
RepoErrorMsg string `json:"repoErrorMsg"`
IsBranchError bool `json:"isBranchError"`
BranchErrorMsg string `json:"branchErrorMsg"`
}
type GitCommit struct {
Commit string
Author string
Date time.Time
Message string
Changes []string `json:",omitempty"`
FileStats *object.FileStats `json:",omitempty"`
WebhookData *WebhookData `json:"webhookData"`
Excluded bool `json:",omitempty"`
}
func (gitCommit *GitCommit) TruncateMessageIfExceedsMaxLength() {
maxLength := 1024
if len(gitCommit.Message) > maxLength {
gitCommit.Message = gitCommit.Message[:maxLength-3] + "..."
}
}
type WebhookAndCiData struct {
ExtraEnvironmentVariables map[string]string `json:"extraEnvironmentVariables"` // extra env variables which will be used for CI
WebhookData *WebhookData `json:"webhookData"`
}
type WebhookData struct {
Id int `json:"id"`
EventActionType string `json:"eventActionType"`
Data map[string]string `json:"data"`
}
type CommitMetadataRequest struct {
PipelineMaterialId int `json:"pipelineMaterialId"`
GitHash string `json:"gitHash"`
GitTag string `json:"gitTag"`
BranchName string `json:"branchName"`
}
type WebhookDataRequest struct {
Id int `json:"id"`
CiPipelineMaterialId int `json:"ciPipelineMaterialId"`
}
type WebhookEventConfigRequest struct {
GitHostId int `json:"gitHostId"`
EventId int `json:"eventId"`
}
type RefreshGitMaterialRequest struct {
GitMaterialId int `json:"gitMaterialId"`
}
type RefreshGitMaterialResponse struct {
Message string `json:"message"`
ErrorMsg string `json:"errorMsg"`
LastFetchTime time.Time `json:"lastFetchTime"`
}
type WebhookEvent struct {
PayloadId int `json:"payloadId"`
RequestPayloadJson string `json:"requestPayloadJson"`
GitHostId int `json:"gitHostId"`
EventType string `json:"eventType"`
}
type WebhookEventResponse struct {
success bool
}
type WebhookEventConfig struct {
Id int `json:"id"`
GitHostId int `json:"gitHostId"`
Name string `json:"name"`
EventTypesCsv string `json:"eventTypesCsv"`
ActionType string `json:"actionType"`
IsActive bool `json:"isActive"`
CreatedOn time.Time `json:"createdOn"`
UpdatedOn time.Time `json:"updatedOn"`
Selectors []*WebhookEventSelectors `json:"selectors"`
}
type WebhookEventSelectors struct {
Id int `json:"id"`
EventId int `json:"eventId"`
Name string `json:"name"`
Selector string `json:"selector"`
ToShow bool `json:"toShow"`
ToShowInCiFilter bool `json:"toShowInCiFilter"`
FixValue string `json:"fixValue"`
PossibleValues string `json:"possibleValues"`
IsActive bool `json:"isActive"`
CreatedOn time.Time `json:"createdOn"`
UpdatedOn time.Time `json:"updatedOn"`
}
// key in condition is selectorId
type WebhookSourceTypeValue struct {
EventId int `json:"eventId,omitempty"`
Condition map[int]string `json:"condition,omitempty"`
}
type WebhookPayloadDataRequest struct {
CiPipelineMaterialId int `json:"ciPipelineMaterialId"`
Limit int `json:"limit"`
Offset int `json:"offset"`
EventTimeSortOrder string `json:"eventTimeSortOrder"`
}
type WebhookPayloadDataResponse struct {
Filters map[string]string `json:"filters"`
RepositoryUrl string `json:"repositoryUrl"`
Payloads []*WebhookPayloadDataPayloadsResponse `json:"payloads"`
}
type WebhookPayloadDataPayloadsResponse struct {
ParsedDataId int `json:"parsedDataId"`
EventTime time.Time `json:"eventTime"`
MatchedFiltersCount int `json:"matchedFiltersCount"`
FailedFiltersCount int `json:"failedFiltersCount"`
MatchedFilters bool `json:"matchedFilters"`
}
type WebhookPayloadFilterDataRequest struct {
CiPipelineMaterialId int `json:"ciPipelineMaterialId"`
ParsedDataId int `json:"parsedDataId"`
}
type WebhookPayloadFilterDataResponse struct {
PayloadId int `json:"payloadId"`
SelectorsData []*WebhookPayloadFilterDataSelectorResponse `json:"selectorsData"`
}
type WebhookPayloadFilterDataSelectorResponse struct {
SelectorName string `json:"selectorName"`
SelectorCondition string `json:"selectorCondition"`
SelectorValue string `json:"selectorValue"`
Match bool `json:"match"`
}