@@ -85,7 +85,7 @@ func (r *Repo) CreateDeployment(c *gin.Context) {
8585 vr , _ := c .Get (KeyRepo )
8686 re := vr .(* ent.Repo )
8787
88- cf , err := r .i .GetConfig (ctx , u , re )
88+ env , err := r .i .GetEnv (ctx , u , re , p . Env )
8989 if e .HasErrorCode (err , e .ErrorCodeEntityNotFound ) {
9090 r .log .Check (gb .GetZapLogLevel (err ), "The configuration file is not found." ).Write (zap .Error (err ))
9191 // To override the HTTP status 422.
@@ -97,24 +97,13 @@ func (r *Repo) CreateDeployment(c *gin.Context) {
9797 return
9898 }
9999
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-
110100 d , err := r .i .Deploy (ctx , u , re ,
111101 & ent.Deployment {
112102 Type : deployment .Type (p .Type ),
113103 Env : p .Env ,
114104 Ref : p .Ref ,
115105 },
116- cf .GetEnv (p .Env ),
117- )
106+ env )
118107 if err != nil {
119108 r .log .Check (gb .GetZapLogLevel (err ), "Failed to deploy." ).Write (zap .Error (err ))
120109 gb .ResponseWithError (c , err )
@@ -160,7 +149,7 @@ func (r *Repo) UpdateDeployment(c *gin.Context) {
160149 return
161150 }
162151
163- cf , err := r .i .GetConfig (ctx , u , re )
152+ env , err := r .i .GetEnv (ctx , u , re , d . Env )
164153 if e .HasErrorCode (err , e .ErrorCodeEntityNotFound ) {
165154 r .log .Check (gb .GetZapLogLevel (err ), "The configuration file is not found." ).Write (zap .Error (err ))
166155 // To override the HTTP status 422.
@@ -172,16 +161,6 @@ func (r *Repo) UpdateDeployment(c *gin.Context) {
172161 return
173162 }
174163
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-
185164 if d , err = r .i .DeployToRemote (ctx , u , re , d , env ); err != nil {
186165 r .log .Check (gb .GetZapLogLevel (err ), "It has failed to deploy to the remote." ).Write (zap .Error (err ))
187166 gb .ResponseWithError (c , err )
@@ -224,7 +203,7 @@ func (r *Repo) RollbackDeployment(c *gin.Context) {
224203 return
225204 }
226205
227- cf , err := r .i .GetConfig (ctx , u , re )
206+ env , err := r .i .GetEnv (ctx , u , re , d . Env )
228207 if e .HasErrorCode (err , e .ErrorCodeEntityNotFound ) {
229208 r .log .Check (gb .GetZapLogLevel (err ), "The configuration file is not found." ).Write (zap .Error (err ))
230209 // To override the HTTP status 422.
@@ -236,25 +215,14 @@ func (r *Repo) RollbackDeployment(c *gin.Context) {
236215 return
237216 }
238217
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-
249218 d , err = r .i .Deploy (ctx , u , re ,
250219 & ent.Deployment {
251220 Type : d .Type ,
252221 Env : d .Env ,
253222 Ref : d .Ref ,
254223 IsRollback : true ,
255224 },
256- cf .GetEnv (d .Env ),
257- )
225+ env )
258226 if err != nil {
259227 r .log .Check (gb .GetZapLogLevel (err ), "Failed to deploy." ).Write (zap .Error (err ))
260228 gb .ResponseWithError (c , err )
0 commit comments