Add constants for commonly used values. (#3588)

This is a consolidation effort, avoiding usage
of naked strings in codebase. Whenever possible
use constants which can be repurposed elsewhere.

This also fixes `goconst ./...` reported issues.
This commit is contained in:
Harshavardhana
2017-01-18 12:24:34 -08:00
committed by GitHub
parent f803bb4b3d
commit 62f8343879
79 changed files with 461 additions and 462 deletions

View File

@@ -65,9 +65,9 @@ func printHealMsg(endpoints []*url.URL, storageDisks []StorageAPI, fn printOnceF
// for single node XL, distributed XL and when minio server is bound
// to a specific ip:port.
func getHealEndpoint(tls bool, firstEndpoint *url.URL) (cEndpoint *url.URL) {
scheme := "http"
scheme := httpScheme
if tls {
scheme = "https"
scheme = httpsScheme
}
cEndpoint = &url.URL{
Scheme: scheme,
@@ -93,6 +93,12 @@ func getHealEndpoint(tls bool, firstEndpoint *url.URL) (cEndpoint *url.URL) {
return cEndpoint
}
// Disks offline and online strings..
const (
diskOffline = "offline"
diskOnline = "online"
)
// Constructs a formatted heal message, when cluster is found to be in state where it requires healing.
// healing is optional, server continues to initialize object layer after printing this message.
// it is upto the end user to perform a heal if needed.
@@ -112,9 +118,9 @@ func getHealMsg(endpoints []*url.URL, storageDisks []StorageAPI) string {
humanize.IBytes(uint64(info.Total)),
func() string {
if info.Total > 0 {
return "online"
return diskOnline
}
return "offline"
return diskOffline
}(),
)
}
@@ -142,9 +148,9 @@ func getStorageInitMsg(titleMsg string, endpoints []*url.URL, storageDisks []Sto
humanize.IBytes(uint64(info.Total)),
func() string {
if info.Total > 0 {
return "online"
return diskOnline
}
return "offline"
return diskOffline
}(),
)
}