diff options
author | Jhon Honce <jhonce@redhat.com> | 2021-08-02 14:09:55 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2021-08-24 16:36:10 -0700 |
commit | 1dc6d14735eef1e51368103aefba3d7c704dcfe3 (patch) | |
tree | 61109c0b3d99cb3bcf85f53b0f8a837a995b0569 /pkg/bindings/volumes/volumes.go | |
parent | e9daaf62e3921b8c696f3abd92f001a9447c8aa1 (diff) | |
download | podman-1dc6d14735eef1e51368103aefba3d7c704dcfe3.tar.gz podman-1dc6d14735eef1e51368103aefba3d7c704dcfe3.tar.bz2 podman-1dc6d14735eef1e51368103aefba3d7c704dcfe3.zip |
Fix file descriptor leaks and add test
* Add response.Body.Close() where needed to release HTTP
connections to API server.
* Add tests to ensure no general leaks occur. 100% coverage would be
required to ensure no leaks on any call.
* Update code comments to be godoc correct
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/bindings/volumes/volumes.go')
-rw-r--r-- | pkg/bindings/volumes/volumes.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/bindings/volumes/volumes.go b/pkg/bindings/volumes/volumes.go index fb58a1d1f..56cf13ade 100644 --- a/pkg/bindings/volumes/volumes.go +++ b/pkg/bindings/volumes/volumes.go @@ -33,6 +33,8 @@ func Create(ctx context.Context, config entities.VolumeCreateOptions, options *C if err != nil { return nil, err } + defer response.Body.Close() + return &v, response.Process(&v) } @@ -53,6 +55,8 @@ func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*en if err != nil { return &inspect, err } + defer response.Body.Close() + return &inspect, response.Process(&inspect) } @@ -74,6 +78,8 @@ func List(ctx context.Context, options *ListOptions) ([]*entities.VolumeListRepo if err != nil { return vols, err } + defer response.Body.Close() + return vols, response.Process(&vols) } @@ -94,6 +100,8 @@ func Prune(ctx context.Context, options *PruneOptions) ([]*reports.PruneReport, if err != nil { return nil, err } + defer response.Body.Close() + return pruned, response.Process(&pruned) } @@ -112,6 +120,8 @@ func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) error if err != nil { return err } + defer response.Body.Close() + return response.Process(nil) } @@ -125,5 +135,7 @@ func Exists(ctx context.Context, nameOrID string, options *ExistsOptions) (bool, if err != nil { return false, err } + defer response.Body.Close() + return response.IsSuccess(), nil } |