madmin: Rename HealObjectResult to HealResult (#4035)

madmin.HealObjectResult is used in HealObject and HealUpload. It only
makes sense to rename it to HealResult.
master
Krishnan Parthasarathi 8 years ago committed by Harshavardhana
parent 3bf67668b6
commit 96c46c15e7
  1. 4
      pkg/madmin/API.md
  2. 32
      pkg/madmin/heal-commands.go

@ -242,7 +242,7 @@ __Example__
```
<a name="HealObject"></a>
### HealObject(bucket, object string, isDryRun bool) (HealObjectResult, error)
### HealObject(bucket, object string, isDryRun bool) (HealResult, error)
If object is successfully healed returns nil, otherwise returns error indicating the reason for failure. If isDryRun is true, then the object is not healed, but heal object request is validated by the server. e.g, if the object exists, if object name is valid etc.
__Example__
@ -324,7 +324,7 @@ __Example__
```
<a name="HealUpload"></a>
### HealUpload(bucket, object, uploadID string, isDryRun bool) (HealObjectResult, error)
### HealUpload(bucket, object, uploadID string, isDryRun bool) (HealResult, error)
If upload is successfully healed returns nil, otherwise returns error indicating the reason for failure. If isDryRun is true, then the upload is not healed, but heal upload request is validated by the server. e.g, if the upload exists, if upload name is valid etc.
``` go

@ -440,7 +440,7 @@ func (adm *AdminClient) HealBucket(bucket string, dryrun bool) error {
}
// HealUpload - Heal the given upload.
func (adm *AdminClient) HealUpload(bucket, object, uploadID string, dryrun bool) (HealObjectResult, error) {
func (adm *AdminClient) HealUpload(bucket, object, uploadID string, dryrun bool) (HealResult, error) {
// Construct query params.
queryVal := url.Values{}
queryVal.Set("heal", "")
@ -466,40 +466,40 @@ func (adm *AdminClient) HealUpload(bucket, object, uploadID string, dryrun bool)
defer closeResponse(resp)
if err != nil {
return HealObjectResult{}, err
return HealResult{}, err
}
if resp.StatusCode != http.StatusOK {
return HealObjectResult{}, httpRespToErrorResponse(resp)
return HealResult{}, httpRespToErrorResponse(resp)
}
// Healing is not performed so heal object result is empty.
if dryrun {
return HealObjectResult{}, nil
return HealResult{}, nil
}
jsonBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return HealObjectResult{}, err
return HealResult{}, err
}
healResult := HealObjectResult{}
healResult := HealResult{}
err = json.Unmarshal(jsonBytes, &healResult)
if err != nil {
return HealObjectResult{}, err
return HealResult{}, err
}
return healResult, nil
}
// HealObjectResult - represents result of heal-object admin API.
type HealObjectResult struct {
// HealResult - represents result of heal-object admin API.
type HealResult struct {
HealedCount int // number of disks that were healed.
OfflineCount int // number of disks that needed healing but were offline.
}
// HealObject - Heal the given object.
func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) (HealObjectResult, error) {
func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) (HealResult, error) {
// Construct query params.
queryVal := url.Values{}
queryVal.Set("heal", "")
@ -522,27 +522,27 @@ func (adm *AdminClient) HealObject(bucket, object string, dryrun bool) (HealObje
defer closeResponse(resp)
if err != nil {
return HealObjectResult{}, err
return HealResult{}, err
}
if resp.StatusCode != http.StatusOK {
return HealObjectResult{}, httpRespToErrorResponse(resp)
return HealResult{}, httpRespToErrorResponse(resp)
}
// Healing is not performed so heal object result is empty.
if dryrun {
return HealObjectResult{}, nil
return HealResult{}, nil
}
jsonBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return HealObjectResult{}, err
return HealResult{}, err
}
healResult := HealObjectResult{}
healResult := HealResult{}
err = json.Unmarshal(jsonBytes, &healResult)
if err != nil {
return HealObjectResult{}, err
return HealResult{}, err
}
return healResult, nil

Loading…
Cancel
Save