@@ -134,7 +134,7 @@ func newGitopsAPI(codefresh *codefresh) GitopsAPI {
134134}
135135
136136func (a * gitops ) CreateEnvironment (name string , project string , application string , integration string , namespace string ) error {
137- _ , err := a .codefresh .requestAPI (& requestOptions {
137+ resp , err := a .codefresh .requestAPI (& requestOptions {
138138 method : "POST" ,
139139 path : "/api/gitops/application" ,
140140 body : & EnvironmentPayload {
@@ -155,6 +155,8 @@ func (a *gitops) CreateEnvironment(name string, project string, application stri
155155 return err
156156 }
157157
158+ defer resp .Body .Close ()
159+
158160 return nil
159161}
160162
@@ -171,17 +173,20 @@ func (a *gitops) SendEnvironment(environment Environment) (map[string]interface{
171173 return nil , err
172174 }
173175
176+ defer resp .Body .Close ()
177+
174178 return result , nil
175179}
176180
177181func (a * gitops ) DeleteEnvironment (name string ) error {
178- _ , err := a .codefresh .requestAPI (& requestOptions {
182+ resp , err := a .codefresh .requestAPI (& requestOptions {
179183 method : "DELETE" ,
180184 path : fmt .Sprintf ("/api/environments-v2/%s" , name ),
181185 })
182186 if err != nil {
183187 return err
184188 }
189+ defer resp .Body .Close ()
185190
186191 return nil
187192}
@@ -196,6 +201,8 @@ func (a *gitops) GetEnvironments() ([]CFEnvironment, error) {
196201 return nil , err
197202 }
198203
204+ defer resp .Body .Close ()
205+
199206 err = a .codefresh .decodeResponseInto (resp , & result )
200207
201208 if err != nil {
@@ -208,7 +215,7 @@ func (a *gitops) GetEnvironments() ([]CFEnvironment, error) {
208215func (a * gitops ) SendEvent (name string , props map [string ]string ) error {
209216 event := CodefreshEvent {Event : name , Props : props }
210217
211- _ , err := a .codefresh .requestAPI (& requestOptions {
218+ resp , err := a .codefresh .requestAPI (& requestOptions {
212219 method : "POST" ,
213220 path : "/api/gitops/system/events" ,
214221 body : event ,
@@ -217,17 +224,20 @@ func (a *gitops) SendEvent(name string, props map[string]string) error {
217224 return err
218225 }
219226
227+ defer resp .Body .Close ()
228+
220229 return nil
221230}
222231
223232func (a * gitops ) SendApplicationResources (resources * ApplicationResources ) error {
224- _ , err := a .codefresh .requestAPI (& requestOptions {
233+ resp , err := a .codefresh .requestAPI (& requestOptions {
225234 method : "POST" ,
226235 path : fmt .Sprintf ("/api/gitops/resources" ),
227236 body : & resources ,
228237 })
229238 if err != nil {
230239 return err
231240 }
241+ defer resp .Body .Close ()
232242 return nil
233243}
0 commit comments