@@ -85,7 +85,7 @@ func (r *Repo) CreateDeployment(c *gin.Context) {
85
85
vr , _ := c .Get (KeyRepo )
86
86
re := vr .(* ent.Repo )
87
87
88
- cf , err := r .i .GetConfig (ctx , u , re )
88
+ env , err := r .i .GetEnv (ctx , u , re , p . Env )
89
89
if e .HasErrorCode (err , e .ErrorCodeEntityNotFound ) {
90
90
r .log .Check (gb .GetZapLogLevel (err ), "The configuration file is not found." ).Write (zap .Error (err ))
91
91
// To override the HTTP status 422.
@@ -97,24 +97,13 @@ func (r *Repo) CreateDeployment(c *gin.Context) {
97
97
return
98
98
}
99
99
100
- var env * vo.Env
101
- if env = cf .GetEnv (p .Env ); env == nil {
102
- r .log .Warn ("The environment is not defined in the configuration." )
103
- gb .ResponseWithError (
104
- c ,
105
- e .NewErrorWithMessage (e .ErrorCodeConfigParseError , "The environment is not defiend in the configuration." , nil ),
106
- )
107
- return
108
- }
109
-
110
100
d , err := r .i .Deploy (ctx , u , re ,
111
101
& ent.Deployment {
112
102
Type : deployment .Type (p .Type ),
113
103
Env : p .Env ,
114
104
Ref : p .Ref ,
115
105
},
116
- cf .GetEnv (p .Env ),
117
- )
106
+ env )
118
107
if err != nil {
119
108
r .log .Check (gb .GetZapLogLevel (err ), "Failed to deploy." ).Write (zap .Error (err ))
120
109
gb .ResponseWithError (c , err )
@@ -160,7 +149,7 @@ func (r *Repo) UpdateDeployment(c *gin.Context) {
160
149
return
161
150
}
162
151
163
- cf , err := r .i .GetConfig (ctx , u , re )
152
+ env , err := r .i .GetEnv (ctx , u , re , d . Env )
164
153
if e .HasErrorCode (err , e .ErrorCodeEntityNotFound ) {
165
154
r .log .Check (gb .GetZapLogLevel (err ), "The configuration file is not found." ).Write (zap .Error (err ))
166
155
// To override the HTTP status 422.
@@ -172,16 +161,6 @@ func (r *Repo) UpdateDeployment(c *gin.Context) {
172
161
return
173
162
}
174
163
175
- var env * vo.Env
176
- if env = cf .GetEnv (d .Env ); env == nil {
177
- r .log .Warn ("The environment is not defined in the configuration." )
178
- gb .ResponseWithError (
179
- c ,
180
- e .NewErrorWithMessage (e .ErrorCodeConfigParseError , "The environment is not defiend in the configuration." , nil ),
181
- )
182
- return
183
- }
184
-
185
164
if d , err = r .i .DeployToRemote (ctx , u , re , d , env ); err != nil {
186
165
r .log .Check (gb .GetZapLogLevel (err ), "It has failed to deploy to the remote." ).Write (zap .Error (err ))
187
166
gb .ResponseWithError (c , err )
@@ -224,7 +203,7 @@ func (r *Repo) RollbackDeployment(c *gin.Context) {
224
203
return
225
204
}
226
205
227
- cf , err := r .i .GetConfig (ctx , u , re )
206
+ env , err := r .i .GetEnv (ctx , u , re , d . Env )
228
207
if e .HasErrorCode (err , e .ErrorCodeEntityNotFound ) {
229
208
r .log .Check (gb .GetZapLogLevel (err ), "The configuration file is not found." ).Write (zap .Error (err ))
230
209
// To override the HTTP status 422.
@@ -236,25 +215,14 @@ func (r *Repo) RollbackDeployment(c *gin.Context) {
236
215
return
237
216
}
238
217
239
- var env * vo.Env
240
- if env = cf .GetEnv (d .Env ); env == nil {
241
- r .log .Warn ("The environment is not defined in the configuration." )
242
- gb .ResponseWithError (
243
- c ,
244
- e .NewErrorWithMessage (e .ErrorCodeConfigParseError , "The environment is not defiend in the configuration." , nil ),
245
- )
246
- return
247
- }
248
-
249
218
d , err = r .i .Deploy (ctx , u , re ,
250
219
& ent.Deployment {
251
220
Type : d .Type ,
252
221
Env : d .Env ,
253
222
Ref : d .Ref ,
254
223
IsRollback : true ,
255
224
},
256
- cf .GetEnv (d .Env ),
257
- )
225
+ env )
258
226
if err != nil {
259
227
r .log .Check (gb .GetZapLogLevel (err ), "Failed to deploy." ).Write (zap .Error (err ))
260
228
gb .ResponseWithError (c , err )
0 commit comments