Skip to content

Commit

Permalink
Updating golang version to 1.20 (dell#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
boyamurthy authored Feb 15, 2023
1 parent 73d5cfc commit 5db6b59
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 49 deletions.
72 changes: 60 additions & 12 deletions VolumeReplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *Client) GetFreeLocalAndRemoteRDFg(ctx context.Context, localSymID strin
log.Error("GetFreeLocalAndRemoteRDFg failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -66,6 +66,10 @@ func (c *Client) GetFreeLocalAndRemoteRDFg(ctx context.Context, localSymID strin
if err := json.NewDecoder(resp.Body).Decode(freeRdfGroups); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return freeRdfGroups, nil

}
Expand All @@ -85,7 +89,7 @@ func (c *Client) GetLocalOnlineRDFDirs(ctx context.Context, localSymID string) (
log.Error("GetLocalOnlineRDFDirs failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -94,6 +98,10 @@ func (c *Client) GetLocalOnlineRDFDirs(ctx context.Context, localSymID string) (
if err := json.NewDecoder(resp.Body).Decode(rdfDirList); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfDirList, nil

}
Expand All @@ -114,7 +122,7 @@ func (c *Client) GetLocalOnlineRDFPorts(ctx context.Context, rdfDir string, loca
log.Error("GetLocalOnlineRDFPorts failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -123,6 +131,10 @@ func (c *Client) GetLocalOnlineRDFPorts(ctx context.Context, rdfDir string, loca
if err := json.NewDecoder(resp.Body).Decode(rdfPortList); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfPortList, nil

}
Expand All @@ -143,7 +155,7 @@ func (c *Client) GetRemoteRDFPortOnSAN(ctx context.Context, localSymID string, r
log.Error("GetRemoteRDFPortOnSAN failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -152,6 +164,10 @@ func (c *Client) GetRemoteRDFPortOnSAN(ctx context.Context, localSymID string, r
if err := json.NewDecoder(resp.Body).Decode(remoteRDFPortDetails); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return remoteRDFPortDetails, nil

}
Expand All @@ -172,7 +188,7 @@ func (c *Client) GetLocalRDFPortDetails(ctx context.Context, localSymID string,
log.Error("GetLocalRDFportDetails failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -181,6 +197,10 @@ func (c *Client) GetLocalRDFPortDetails(ctx context.Context, localSymID string,
if err := json.NewDecoder(resp.Body).Decode(LocalRDFPortDetails); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return LocalRDFPortDetails, nil
}

Expand All @@ -198,7 +218,7 @@ func (c *Client) GetRDFGroupByID(ctx context.Context, symID, rdfGroupNo string)
log.Error("GetRdfGroup failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -207,6 +227,10 @@ func (c *Client) GetRDFGroupByID(ctx context.Context, symID, rdfGroupNo string)
if err := json.NewDecoder(resp.Body).Decode(rdfGrpInfo); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfGrpInfo, nil
}

Expand Down Expand Up @@ -237,7 +261,7 @@ func (c *Client) GetRDFGroupList(ctx context.Context, symID string, queryParams
log.Error("GetRdfGroupList failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -246,6 +270,10 @@ func (c *Client) GetRDFGroupList(ctx context.Context, symID string, queryParams
if err := json.NewDecoder(resp.Body).Decode(rdfGrpList); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfGrpList, nil
}

Expand All @@ -263,7 +291,7 @@ func (c *Client) GetProtectedStorageGroup(ctx context.Context, symID, storageGro
log.Error("GetProtectedStorageGroup failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -272,6 +300,10 @@ func (c *Client) GetProtectedStorageGroup(ctx context.Context, symID, storageGro
if err := json.NewDecoder(resp.Body).Decode(rdfSgInfo); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfSgInfo, nil
}

Expand Down Expand Up @@ -471,13 +503,17 @@ func (c *Client) CreateSGReplica(ctx context.Context, symID, remoteSymID, rdfMod
if err = c.checkResponse(resp); err != nil {
return nil, err
}
defer resp.Body.Close()

rdfSG := &types.SGRDFInfo{}
decoder := json.NewDecoder(resp.Body)
if err = decoder.Decode(rdfSG); err != nil {
return nil, err
}
log.Info(fmt.Sprintf("Successfully created SG replica for %s", sourceSG))
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfSG, nil
}

Expand Down Expand Up @@ -541,13 +577,17 @@ func (c *Client) CreateRDFPair(ctx context.Context, symID, rdfGroupNo, deviceID,
if err = c.checkResponse(resp); err != nil {
return nil, err
}
defer resp.Body.Close()

rdfPairList := &types.RDFDevicePairList{}
decoder := json.NewDecoder(resp.Body)
if err = decoder.Decode(rdfPairList); err != nil {
return nil, err
}
log.Info(fmt.Sprintf("Successfully created volume replica for %s", deviceID))
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfPairList, nil
}

Expand All @@ -566,7 +606,7 @@ func (c *Client) GetRDFDevicePairInfo(ctx context.Context, symID, rdfGroup, volu
log.Error("GetRDFDevicePairInfo failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -575,6 +615,10 @@ func (c *Client) GetRDFDevicePairInfo(ctx context.Context, symID, rdfGroup, volu
if err := json.NewDecoder(resp.Body).Decode(rdfDevPairInfo); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return rdfDevPairInfo, nil
}

Expand All @@ -593,7 +637,7 @@ func (c *Client) GetStorageGroupRDFInfo(ctx context.Context, symID, sgName, rdfG
log.Error("GetStorageGroupRDFInfo failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -602,5 +646,9 @@ func (c *Client) GetStorageGroupRDFInfo(ctx context.Context, symID, sgName, rdfG
if err := json.NewDecoder(resp.Body).Decode(sgRdfInfo); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return sgRdfInfo, nil
}
23 changes: 18 additions & 5 deletions VolumeSnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (c *Client) GetSnapVolumeList(ctx context.Context, symID string, queryParam
log.Error("GetSnapVolumeList failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -78,6 +78,10 @@ func (c *Client) GetSnapVolumeList(ctx context.Context, symID string, queryParam
if err = decoder.Decode(snapVolList); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return snapVolList, nil
}

Expand All @@ -95,16 +99,19 @@ func (c *Client) GetVolumeSnapInfo(ctx context.Context, symID string, volumeID s
log.Error("GetVolumeSnapInfo failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()

if err = c.checkResponse(resp); err != nil {
return nil, err
}

snapinfo := &types.SnapshotVolumeGeneration{}
decoder := json.NewDecoder(resp.Body)
if err = decoder.Decode(snapinfo); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return snapinfo, nil
}

Expand All @@ -122,7 +129,6 @@ func (c *Client) GetSnapshotInfo(ctx context.Context, symID, volumeID, snapID st
log.Error("GetSnapshotInfo failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()
if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -131,6 +137,10 @@ func (c *Client) GetSnapshotInfo(ctx context.Context, symID, volumeID, snapID st
if err := json.NewDecoder(resp.Body).Decode(snapshotInfo); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return snapshotInfo, nil
}

Expand Down Expand Up @@ -390,7 +400,6 @@ func (c *Client) GetPrivVolumeByID(ctx context.Context, symID string, volumeID s
log.Error("GetPrivVolumeByID failed: " + err.Error())
return nil, err
}
defer resp.Body.Close()
if err = c.checkResponse(resp); err != nil {
return nil, err
}
Expand All @@ -401,6 +410,10 @@ func (c *Client) GetPrivVolumeByID(ctx context.Context, symID string, volumeID s
if err = decoder.Decode(privateVolumeIterator); err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
return nil, err
}
return &privateVolumeIterator.ResultList.PrivVolumeList[0], nil
}

Expand Down
9 changes: 5 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
"encoding/json"
"errors"
"fmt"
types "github.com/dell/gopowermax/v2/types/v100"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"net/url"
"strings"
"time"

types "github.com/dell/gopowermax/v2/types/v100"
log "github.com/sirupsen/logrus"
)

// constants
Expand Down Expand Up @@ -253,7 +254,7 @@ func (c *client) DoWithHeaders(
if err != nil {
return err
}
defer res.Body.Close()
defer res.Body.Close() // #nosec G307

// parse the response
switch {
Expand Down Expand Up @@ -317,7 +318,7 @@ func (c *client) DoAndGetResponseBody(
// marshal the message body (assumes json format)
if r, ok := body.(io.ReadCloser); ok {
req, err = http.NewRequest(method, u.String(), r)
defer r.Close()
defer r.Close() // #nosec G307
if v, ok := headers[HeaderKeyContentType]; ok {
req.Header.Set(HeaderKeyContentType, v)
} else {
Expand Down
5 changes: 4 additions & 1 deletion authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (c *Client) Authenticate(ctx context.Context, configConnect *ConfigConnect)
doLog(log.WithError(err).Error, "")
return err
}
defer resp.Body.Close()

// parse the response
switch {
Expand All @@ -84,6 +83,10 @@ func (c *Client) Authenticate(ctx context.Context, configConnect *ConfigConnect)
return c.api.ParseJSONError(resp)
}
doLog(log.Infoln, "authentication successful")
err = resp.Body.Close()
if err != nil {
return err
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dell/gopowermax/v2

go 1.19
go 1.20

require (
github.com/cucumber/godog v0.10.0
Expand Down
Loading

0 comments on commit 5db6b59

Please sign in to comment.