From 96c46c15e787715e066ee387f3cdbf8f66d1e796 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Mon, 3 Apr 2017 20:55:32 +0530 Subject: [PATCH] madmin: Rename HealObjectResult to HealResult (#4035) madmin.HealObjectResult is used in HealObject and HealUpload. It only makes sense to rename it to HealResult. --- pkg/madmin/API.md | 4 ++-- pkg/madmin/heal-commands.go | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/madmin/API.md b/pkg/madmin/API.md index bddd755a4..0698c97aa 100644 --- a/pkg/madmin/API.md +++ b/pkg/madmin/API.md @@ -242,7 +242,7 @@ __Example__ ``` -### 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__ ``` -### 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 diff --git a/pkg/madmin/heal-commands.go b/pkg/madmin/heal-commands.go index ad3054762..8b69236f5 100644 --- a/pkg/madmin/heal-commands.go +++ b/pkg/madmin/heal-commands.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