mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
Remove all unused variables and functions (#5823)
This commit is contained in:
parent
97a8d856b6
commit
adf9a9d300
@ -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))
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import (
|
||||
// global colors.
|
||||
var (
|
||||
colorBold = color.New(color.Bold).SprintFunc()
|
||||
colorYellow = color.New(color.FgYellow).SprintfFunc()
|
||||
colorRed = color.New(color.FgRed).SprintfFunc()
|
||||
)
|
||||
|
||||
|
@ -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 == "" {
|
||||
|
13
cmd/utils.go
13
cmd/utils.go
@ -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…
x
Reference in New Issue
Block a user