-
Notifications
You must be signed in to change notification settings - Fork 68
/
types.go
237 lines (212 loc) · 8.27 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package houston
// Response wraps all houston response structs used for json marashalling
type Response struct {
Data struct {
AddWorkspaceUser *Workspace `json:"workspaceAddUser,omitempty"`
RemoveWorkspaceUser *Workspace `json:"workspaceRemoveUser,omitempty"`
CreateDeployment *Deployment `json:"createDeployment,omitempty"`
CreateToken *AuthUser `json:"createToken,omitempty"`
CreateWorkspaceServiceAccount *WorkspaceServiceAccount `json:"createWorkspaceServiceAccount,omitempty"`
CreateDeploymentServiceAccount *DeploymentServiceAccount `json:"createDeploymentServiceAccount,omitempty"`
CreateUser *AuthUser `json:"createUser,omitempty"`
CreateWorkspace *Workspace `json:"createWorkspace,omitempty"`
DeleteDeployment *Deployment `json:"deleteDeployment,omitempty"`
DeleteWorkspaceServiceAccount *ServiceAccount `json:"deleteWorkspaceServiceAccount,omitempty"`
DeleteDeploymentServiceAccount *ServiceAccount `json:"deleteDeploymentServiceAccount,omitempty"`
DeleteWorkspace *Workspace `json:"deleteWorkspace,omitempty"`
GetDeployments []Deployment `json:"workspaceDeployments,omitempty"`
GetAuthConfig *AuthConfig `json:"authConfig,omitempty"`
GetAppConfig *AppConfig `json:"appConfig,omitempty"`
GetServiceAccounts []ServiceAccount `json:"serviceAccounts,omitempty"`
GetUsers []User `json:"users,omitempty"`
GetWorkspaces []Workspace `json:"workspaces,omitempty"`
UpdateDeployment *Deployment `json:"updateDeployment,omitempty"`
UpdateWorkspace *Workspace `json:"updateWorkspace,omitempty"`
DeploymentLog []DeploymentLog `json:"logs,omitempty"`
WorkspaceUpdateUserRole string `json:"workspaceUpdateUserRole,omitempty"`
DeploymentConfig DeploymentConfig `json:"deploymentConfig,omitempty"`
} `json:"data"`
Errors []Error `json:"errors,omitempty"`
}
type AuthProvider struct {
Name string `json:"name"`
DisplayName string `json:"displayName"`
Url string `json:"url"`
}
// AuthConfig holds data related to oAuth and basic authentication
type AuthConfig struct {
LocalEnabled bool `json:"localEnabled"`
PublicSignup bool `json:"publicSignup"`
InitialSignup bool `json:"initialSignup"`
AuthProviders []AuthProvider `json:"providers"`
}
type AuthUser struct {
User User `json:"user"`
Token Token `json:"token"`
}
// Decoded defines structure of a houston response Decoded object
type Decoded struct {
ID string `json:"id"`
SU bool `json:"sU"`
Iat int `json:"iat"`
Exp int `json:"exp"`
}
// Deployment defines structure of a houston response Deployment object
type Deployment struct {
Id string `json:"id"`
Type string `json:"type"`
Label string `json:"label"`
ReleaseName string `json:"releaseName"`
Version string `json:"version"`
DeploymentInfo DeploymentInfo `json:"deployInfo"`
Workspace Workspace `json:"workspace"`
Urls []DeploymentUrl `json:"urls"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
// DeploymentUrl defines structure of a houston response DeploymentUrl object
type DeploymentUrl struct {
Type string `json:"type"`
Url string `json:"url"`
}
// DeploymentInfo contains registry related information for a deployment
type DeploymentInfo struct {
NextCli string `json:"NextCli"`
Current string `json:"current"`
}
// Email contains various pieces of a users email
type Email struct {
Address string `json:"address"`
Verified bool `json:"verified"`
Primary bool `json:"primary"`
// created at
// updated at
}
// Error defines struct of a houston response Error object
type Error struct {
Message string `json:"message"`
Name string `json:"name"`
}
// Status defines structure of a houston response StatusResponse object
type Status struct {
Success bool `json:"success"`
Message string `json:"message"`
Code string `json:"code"`
Id string `json:"id"`
}
// ServiceAccount defines a structure of a ServiceAccountResponse object
type ServiceAccount struct {
Id string `json:"id"`
ApiKey string `json:"apiKey"`
Label string `json:"label"`
Category string `json:"category"`
EntityType string `json:"entityType"`
EntityId string `json:"entityUuid"`
LastUsedAt string `json:"lastUsedAt"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Active bool `json:"active"`
}
// WorkspaceServiceAccount defines a structure of a WorkspaceServiceAccountResponse object
type WorkspaceServiceAccount struct {
Id string `json:"id"`
ApiKey string `json:"apiKey"`
Label string `json:"label"`
Category string `json:"category"`
EntityType string `json:"entityType"`
WorkspaceUuid string `json:"workspaceUuid"`
LastUsedAt string `json:"lastUsedAt"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Active bool `json:"active"`
}
// DeploymentServiceAccount defines a structure of a DeploymentServiceAccountResponse object
type DeploymentServiceAccount struct {
Id string `json:"id"`
ApiKey string `json:"apiKey"`
Label string `json:"label"`
Category string `json:"category"`
EntityType string `json:"entityType"`
DeploymentUuid string `json:"deploymentUuid"`
LastUsedAt string `json:"lastUsedAt"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Active bool `json:"active"`
}
// Token contains a houston auth token as well as it's payload of components
type Token struct {
Value string `json:"value"`
Payload TokenPayload `json:"payload"`
}
// TokenPayload contains components of a houston auth token
type TokenPayload struct {
Id string `json:"id"`
Iat int `json:"iat"`
Exp int `json:"exp"`
}
// User contains all components of an Astronomer user
type User struct {
Id string `json:"id"`
Emails []Email `json:"emails"`
Username string `json:"username"`
Status string `json:"status"`
// created at
// updated at
// profile
}
type RoleBinding struct {
Role string `json:"role"`
User struct {
Id string `json:"id"`
Username string `json:"username"`
} `json:"user"`
}
// Workspace contains all components of an Astronomer Workspace
type Workspace struct {
Id string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
Users []User `json:"users"`
// groups
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
RoleBindings []RoleBinding `json:"roleBindings"`
}
// DeploymentLog contains all log related to deployment components
type DeploymentLog struct {
Id string `json:"id"`
Component string `json:"component"`
CreatedAt string `json:"createdAt"`
Log string `json:"log"`
}
// AirflowImage contains all airflow image attributes
type AirflowImage struct {
Version string `json:"version"`
Tag string `json:"tag"`
}
// DeploymentConfig contains current airflow image tag
type DeploymentConfig struct {
AirflowImages []AirflowImage `json:"airflowImages"`
DefaultAirflowImageTag string `json:"defaultAirflowImageTag"`
}
func (config *DeploymentConfig) GetValidTags() (tags []string) {
for _, image := range config.AirflowImages {
tags = append(tags, image.Tag)
}
return
}
func (config *DeploymentConfig) IsValidTag(tag string) bool {
for _, validTag := range config.GetValidTags() {
if tag == validTag {
return true
}
}
return false
}
// AppConfig contains current houston config
type AppConfig struct {
Version string `json:"version"`
BaseDomain string `json:"baseDomain"`
SmtpConfigured bool `json:"smtpConfigured"`
ManualReleaseNames bool `json:"manualReleaseNames"`
}