Remove all unused variables and functions (#5823)

master
Harshavardhana 7 years ago committed by Nitish Tiwari
parent 97a8d856b6
commit adf9a9d300
  1. 10
      cmd/api-resources.go
  2. 36
      cmd/api-resources_test.go
  3. 1
      cmd/disk-cache-fs.go
  4. 9
      cmd/format-disk-cache.go
  5. 10
      cmd/format-disk-cache_test.go
  6. 8
      cmd/fs-v1-metadata.go
  7. 1
      cmd/globals.go
  8. 6
      cmd/hasher.go
  9. 5
      cmd/logger/logger.go
  10. 5
      cmd/test-utils_test.go
  11. 13
      cmd/utils.go
  12. 12
      cmd/utils_test.go
  13. 11
      cmd/xl-v1-utils.go
  14. 1
      pkg/handlers/proxy.go

@ -78,13 +78,3 @@ func getObjectResources(values url.Values) (uploadID string, partNumberMarker, m
encodingType = values.Get("encoding-type")
return
}
// Validates filter values
func validateFilterValues(values []string) (err APIErrorCode) {
for _, value := range values {
if !IsValidObjectPrefix(value) {
return ErrFilterValueInvalid
}
}
return ErrNone
}

@ -18,7 +18,6 @@ package cmd
import (
"net/url"
"strings"
"testing"
)
@ -189,38 +188,3 @@ func TestGetObjectsResources(t *testing.T) {
}
}
}
// Validates if filter values are correct
func TestValidateFilterValues(t *testing.T) {
testCases := []struct {
values []string
expectedError APIErrorCode
}{
{
values: []string{""},
expectedError: ErrNone,
},
{
values: []string{"", "prefix"},
expectedError: ErrNone,
},
{
values: []string{strings.Repeat("a", 1025)},
expectedError: ErrFilterValueInvalid,
},
{
values: []string{"a\\b"},
expectedError: ErrFilterValueInvalid,
},
{
values: []string{string([]byte{0xff, 0xfe, 0xfd})},
expectedError: ErrFilterValueInvalid,
},
}
for i, testCase := range testCases {
if actualError := validateFilterValues(testCase.values); actualError != testCase.expectedError {
t.Errorf("Test %d: Expected %d, got %d", i+1, testCase.expectedError, actualError)
}
}
}

@ -37,7 +37,6 @@ import (
const (
// cache.json object metadata for cached objects.
cacheMetaJSONFile = "cache.json"
cacheMetaFormat = "cache"
cacheEnvDelimiter = ";"
)

@ -87,15 +87,6 @@ func newFormatCacheV1(drives []string) []*formatCacheV1 {
return formats
}
// Returns format.Cache.Version
func formatCacheGetVersion(r io.ReadSeeker) (string, error) {
format := &formatCacheVersionDetect{}
if err := jsonLoad(r, format); err != nil {
return "", err
}
return format.Cache.Version, nil
}
// Creates a new cache format.json if unformatted.
func createFormatCache(fsFormatPath string, format *formatCacheV1) error {
// open file using READ & WRITE permission

@ -18,10 +18,20 @@ package cmd
import (
"context"
"io"
"os"
"testing"
)
// Returns format.Cache.Version
func formatCacheGetVersion(r io.ReadSeeker) (string, error) {
format := &formatCacheVersionDetect{}
if err := jsonLoad(r, format); err != nil {
return "", err
}
return format.Cache.Version, nil
}
// TestDiskCacheFormat - tests initFormatCache, formatMetaGetFormatBackendCache, formatCacheGetVersion.
func TestDiskCacheFormat(t *testing.T) {
ctx := context.Background()

@ -202,14 +202,6 @@ func parseFSVersion(fsMetaBuf []byte) string {
return gjson.GetBytes(fsMetaBuf, "version").String()
}
func parseFSFormat(fsMetaBuf []byte) string {
return gjson.GetBytes(fsMetaBuf, "format").String()
}
func parseFSRelease(fsMetaBuf []byte) string {
return gjson.GetBytes(fsMetaBuf, "minio.release").String()
}
func parseFSMetaMap(fsMetaBuf []byte) map[string]string {
// Get xlMetaV1.Meta map.
metaMapResult := gjson.GetBytes(fsMetaBuf, "meta").Map()

@ -191,7 +191,6 @@ var (
colorBold = color.New(color.Bold).SprintFunc()
colorBlue = color.New(color.FgBlue).SprintfFunc()
colorYellow = color.New(color.FgYellow).SprintfFunc()
colorRed = color.New(color.FgRed).SprintfFunc()
)
// Returns minio global information, as a key value map.

@ -18,7 +18,6 @@ package cmd
import (
"crypto/md5"
"encoding/base64"
"encoding/hex"
"github.com/minio/sha256-simd"
@ -47,8 +46,3 @@ func getMD5Sum(data []byte) []byte {
func getMD5Hash(data []byte) string {
return hex.EncodeToString(getMD5Sum(data))
}
// getMD5HashBase64 returns MD5 hash in base64 encoding of given data.
func getMD5HashBase64(data []byte) string {
return base64.StdEncoding.EncodeToString(getMD5Sum(data))
}

@ -33,9 +33,8 @@ import (
// global colors.
var (
colorBold = color.New(color.Bold).SprintFunc()
colorYellow = color.New(color.FgYellow).SprintfFunc()
colorRed = color.New(color.FgRed).SprintfFunc()
colorBold = color.New(color.Bold).SprintFunc()
colorRed = color.New(color.FgRed).SprintfFunc()
)
var trimStrings []string

@ -1157,6 +1157,11 @@ func getCredentialString(accessKeyID, location string, t time.Time) string {
return accessKeyID + "/" + getScope(t, location)
}
// getMD5HashBase64 returns MD5 hash in base64 encoding of given data.
func getMD5HashBase64(data []byte) string {
return base64.StdEncoding.EncodeToString(getMD5Sum(data))
}
// Returns new HTTP request object.
func newTestRequest(method, urlStr string, contentLength int64, body io.ReadSeeker) (*http.Request, error) {
if method == "" {

@ -23,7 +23,6 @@ import (
"encoding/base64"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"io"
"net"
@ -232,18 +231,6 @@ func isFile(path string) bool {
return false
}
// checkURL - checks if passed address correspond
func checkURL(urlStr string) (*url.URL, error) {
if urlStr == "" {
return nil, errors.New("Address cannot be empty")
}
u, err := url.Parse(urlStr)
if err != nil {
return nil, fmt.Errorf("`%s` invalid: %s", urlStr, err.Error())
}
return u, nil
}
// UTCNow - returns current UTC time.
func UTCNow() time.Time {
return time.Now().UTC()

@ -233,6 +233,18 @@ func TestStartProfiler(t *testing.T) {
}
}
// checkURL - checks if passed address correspond
func checkURL(urlStr string) (*url.URL, error) {
if urlStr == "" {
return nil, errors.New("Address cannot be empty")
}
u, err := url.Parse(urlStr)
if err != nil {
return nil, fmt.Errorf("`%s` invalid: %s", urlStr, err.Error())
}
return u, nil
}
// TestCheckURL tests valid url.
func TestCheckURL(t *testing.T) {
testCases := []struct {

@ -369,17 +369,6 @@ func shuffleDisks(disks []StorageAPI, distribution []int) (shuffledDisks []Stora
return shuffledDisks
}
// unshuffleIndex - performs reverse of the shuffleDisks operations
// for a single 0-based index.
func unshuffleIndex(n int, distribution []int) int {
for i, v := range distribution {
if v-1 == n {
return i
}
}
return -1
}
// evalDisks - returns a new slice of disks where nil is set if
// the corresponding error in errs slice is not nil
func evalDisks(disks []StorageAPI, errs []error) []StorageAPI {

@ -26,7 +26,6 @@ import (
var (
// De-facto standard header keys.
xForwardedFor = http.CanonicalHeaderKey("X-Forwarded-For")
xForwardedHost = http.CanonicalHeaderKey("X-Forwarded-Host")
xForwardedProto = http.CanonicalHeaderKey("X-Forwarded-Proto")
xForwardedScheme = http.CanonicalHeaderKey("X-Forwarded-Scheme")
xRealIP = http.CanonicalHeaderKey("X-Real-IP")

Loading…
Cancel
Save