mirror of
https://github.com/minio/mc.git
synced 2025-07-30 07:23:03 +03:00
Add staticcheck to CI (#4386)
This commit is contained in:
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@ -73,3 +73,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Test 386
|
- name: Test 386
|
||||||
run: GOOS=linux GOARCH=386 go test -short ./...
|
run: GOOS=linux GOARCH=386 go test -short ./...
|
||||||
|
|
||||||
|
- name: Staticcheck
|
||||||
|
# Run with defaults, but allow errors with other formats ST1005
|
||||||
|
run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck -tests=false -checks="all,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022,-ST1023,-ST1005" ./...
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
humanize "github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
json "github.com/minio/colorjson"
|
json "github.com/minio/colorjson"
|
||||||
@ -79,18 +79,18 @@ func countDigits(num uint64) (count uint) {
|
|||||||
func (bi adminBucketInfoMessage) String() string {
|
func (bi adminBucketInfoMessage) String() string {
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
|
|
||||||
fmt.Fprintf(&b, console.Colorize("Title", "Usage:\n"))
|
fmt.Fprint(&b, console.Colorize("Title", "Usage:\n"))
|
||||||
|
|
||||||
fmt.Fprintf(&b, "%16s: %s\n", "Total size", console.Colorize("Count", humanize.IBytes(bi.UsageInfo.Size)))
|
fmt.Fprintf(&b, "%16s: %s\n", "Total size", console.Colorize("Count", humanize.IBytes(bi.UsageInfo.Size)))
|
||||||
fmt.Fprintf(&b, "%16s: %s\n", "Objects count", console.Colorize("Count", humanize.Comma(int64(bi.UsageInfo.ObjectsCount))))
|
fmt.Fprintf(&b, "%16s: %s\n", "Objects count", console.Colorize("Count", humanize.Comma(int64(bi.UsageInfo.ObjectsCount))))
|
||||||
fmt.Fprintf(&b, "%16s: %s\n", "Versions count", console.Colorize("Count", humanize.Comma(int64(bi.UsageInfo.VersionsCount))))
|
fmt.Fprintf(&b, "%16s: %s\n", "Versions count", console.Colorize("Count", humanize.Comma(int64(bi.UsageInfo.VersionsCount))))
|
||||||
fmt.Fprintf(&b, "\n")
|
fmt.Fprintf(&b, "\n")
|
||||||
|
|
||||||
fmt.Fprintf(&b, console.Colorize("Title", "Properties:\n"))
|
fmt.Fprint(&b, console.Colorize("Title", "Properties:\n"))
|
||||||
fmt.Fprintf(&b, prettyPrintBucketMetadata(bi.Props))
|
fmt.Fprint(&b, prettyPrintBucketMetadata(bi.Props))
|
||||||
|
|
||||||
fmt.Fprintf(&b, "\n")
|
fmt.Fprintf(&b, "\n")
|
||||||
fmt.Fprintf(&b, console.Colorize("Title", "Object sizes histogram:\n"))
|
fmt.Fprint(&b, console.Colorize("Title", "Object sizes histogram:\n"))
|
||||||
|
|
||||||
var maxDigits uint
|
var maxDigits uint
|
||||||
for _, val := range bi.UsageInfo.ObjectSizesHistogram {
|
for _, val := range bi.UsageInfo.ObjectSizesHistogram {
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@ -92,7 +91,7 @@ func mainClusterBucketExport(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create bucket metadata zip file
|
// Create bucket metadata zip file
|
||||||
tmpFile, e := ioutil.TempFile("", fmt.Sprintf("%s-metadata-", bucket))
|
tmpFile, e := os.CreateTemp("", fmt.Sprintf("%s-metadata-", bucket))
|
||||||
fatalIf(probe.NewError(e), "Unable to download file data.")
|
fatalIf(probe.NewError(e), "Unable to download file data.")
|
||||||
|
|
||||||
ext := "zip"
|
ext := "zip"
|
||||||
|
@ -177,7 +177,6 @@ func (i importMetaMsg) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i importMetaMsg) JSON() string {
|
func (i importMetaMsg) JSON() string {
|
||||||
i.Status = "success"
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
enc := json.NewEncoder(buf)
|
enc := json.NewEncoder(buf)
|
||||||
enc.SetIndent("", " ")
|
enc.SetIndent("", " ")
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ func mainClusterIAMExport(ctx *cli.Context) error {
|
|||||||
fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to export IAM info.")
|
fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to export IAM info.")
|
||||||
|
|
||||||
// Create iam info zip file
|
// Create iam info zip file
|
||||||
tmpFile, e := ioutil.TempFile("", fmt.Sprintf("%s-iam-info", aliasedURL))
|
tmpFile, e := os.CreateTemp("", fmt.Sprintf("%s-iam-info", aliasedURL))
|
||||||
fatalIf(probe.NewError(e), "Unable to download file data.")
|
fatalIf(probe.NewError(e), "Unable to download file data.")
|
||||||
|
|
||||||
ext := "zip"
|
ext := "zip"
|
||||||
|
@ -378,17 +378,17 @@ func (s verboseBackgroundHealStatusMessage) String() string {
|
|||||||
_, ok := offlineEndpoints[endpoint]
|
_, ok := offlineEndpoints[endpoint]
|
||||||
if ok {
|
if ok {
|
||||||
stateText := console.Colorize("NodeFailed", "OFFLINE")
|
stateText := console.Colorize("NodeFailed", "OFFLINE")
|
||||||
fmt.Fprintf(&msg, fmt.Sprintf(" %s: %s\n", endpoint, stateText))
|
fmt.Fprintf(&msg, " %s: %s\n", endpoint, stateText)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
serverStatus := serversStatus[endpoint]
|
serverStatus := serversStatus[endpoint]
|
||||||
switch {
|
switch {
|
||||||
case showTolerance:
|
case showTolerance:
|
||||||
serverHeader := " %s: (Tolerance: %d server(s))\n"
|
serverHeader := " %s: (Tolerance: %d server(s))\n"
|
||||||
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint, poolsInfo[serverStatus.pool].tolerance))
|
fmt.Fprintf(&msg, serverHeader, endpoint, poolsInfo[serverStatus.pool].tolerance)
|
||||||
default:
|
default:
|
||||||
serverHeader := " %s:\n"
|
serverHeader := " %s:\n"
|
||||||
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint))
|
fmt.Fprintf(&msg, serverHeader, endpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, d := range serverStatus.disks {
|
for _, d := range serverStatus.disks {
|
||||||
@ -439,11 +439,11 @@ func (s verboseBackgroundHealStatusMessage) String() string {
|
|||||||
|
|
||||||
summary := shortBackgroundHealStatusMessage{HealInfo: s.HealInfo}
|
summary := shortBackgroundHealStatusMessage{HealInfo: s.HealInfo}
|
||||||
|
|
||||||
fmt.Fprintf(&msg, "\n")
|
fmt.Fprint(&msg, "\n")
|
||||||
fmt.Fprintf(&msg, "Summary:\n")
|
fmt.Fprint(&msg, "Summary:\n")
|
||||||
fmt.Fprintf(&msg, "=======\n")
|
fmt.Fprint(&msg, "=======\n")
|
||||||
fmt.Fprintf(&msg, summary.String())
|
fmt.Fprint(&msg, summary.String())
|
||||||
fmt.Fprintf(&msg, "\n")
|
fmt.Fprint(&msg, "\n")
|
||||||
|
|
||||||
return msg.String()
|
return msg.String()
|
||||||
}
|
}
|
||||||
@ -540,7 +540,7 @@ func (s shortBackgroundHealStatusMessage) String() string {
|
|||||||
bytesHealedPerSec += float64(time.Second) * float64(disk.HealInfo.BytesDone) / float64(disk.HealInfo.LastUpdate.Sub(disk.HealInfo.Started))
|
bytesHealedPerSec += float64(time.Second) * float64(disk.HealInfo.BytesDone) / float64(disk.HealInfo.LastUpdate.Sub(disk.HealInfo.Started))
|
||||||
itemsHealedPerSec += float64(time.Second) * float64(disk.HealInfo.ItemsHealed+disk.HealInfo.ItemsFailed) / float64(disk.HealInfo.LastUpdate.Sub(disk.HealInfo.Started))
|
itemsHealedPerSec += float64(time.Second) * float64(disk.HealInfo.ItemsHealed+disk.HealInfo.ItemsFailed) / float64(disk.HealInfo.LastUpdate.Sub(disk.HealInfo.Started))
|
||||||
|
|
||||||
scanSpeed := float64(disk.UsedSpace) / float64(time.Now().Sub(disk.HealInfo.Started))
|
scanSpeed := float64(disk.UsedSpace) / float64(time.Since(disk.HealInfo.Started))
|
||||||
remainingTime := time.Duration(float64(setsStatus[diskSet].maxUsedSpace-disk.UsedSpace) / scanSpeed)
|
remainingTime := time.Duration(float64(setsStatus[diskSet].maxUsedSpace-disk.UsedSpace) / scanSpeed)
|
||||||
if remainingTime > healingRemaining {
|
if remainingTime > healingRemaining {
|
||||||
healingRemaining = remainingTime
|
healingRemaining = remainingTime
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
humanize "github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/dustin/go-humanize/english"
|
"github.com/dustin/go-humanize/english"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
@ -269,7 +269,7 @@ func (u clusterStruct) String() (msg string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if backendType == madmin.Erasure {
|
if backendType == madmin.Erasure {
|
||||||
msg += fmt.Sprintf("Pools:\n")
|
msg += "Pools:\n"
|
||||||
for pool, summary := range clusterSummary {
|
for pool, summary := range clusterSummary {
|
||||||
msg += fmt.Sprintf(" %s, Erasure sets: %d, Drives per erasure set: %d\n",
|
msg += fmt.Sprintf(" %s, Erasure sets: %d, Drives per erasure set: %d\n",
|
||||||
console.Colorize("Info", humanize.Ordinal(pool+1)), summary.setsCount, summary.drivesPerSet)
|
console.Colorize("Info", humanize.Ordinal(pool+1)), summary.setsCount, summary.drivesPerSet)
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/pkg/console"
|
"github.com/minio/pkg/console"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
var adminKMSCreateKeyCmd = cli.Command{
|
var adminKMSCreateKeyCmd = cli.Command{
|
||||||
@ -63,7 +63,7 @@ func mainAdminKMSCreateKey(ctx *cli.Context) error {
|
|||||||
e := client.CreateKey(globalContext, keyID)
|
e := client.CreateKey(globalContext, keyID)
|
||||||
fatalIf(probe.NewError(e), "Failed to create master key")
|
fatalIf(probe.NewError(e), "Failed to create master key")
|
||||||
|
|
||||||
if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
if term.IsTerminal(int(os.Stdout.Fd())) {
|
||||||
console.Println(color.GreenString(fmt.Sprintf("Created master key `%s` successfully", keyID)))
|
console.Println(color.GreenString(fmt.Sprintf("Created master key `%s` successfully", keyID)))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -19,7 +19,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
@ -126,7 +126,7 @@ func mainAdminPolicyAdd(ctx *cli.Context) error {
|
|||||||
args := ctx.Args()
|
args := ctx.Args()
|
||||||
aliasedURL := args.Get(0)
|
aliasedURL := args.Get(0)
|
||||||
|
|
||||||
policy, e := ioutil.ReadFile(args.Get(2))
|
policy, e := os.ReadFile(args.Get(2))
|
||||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get policy")
|
fatalIf(probe.NewError(e).Trace(args...), "Unable to get policy")
|
||||||
|
|
||||||
// Create a new MinIO Admin Client
|
// Create a new MinIO Admin Client
|
||||||
|
@ -19,7 +19,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ import (
|
|||||||
json "github.com/minio/colorjson"
|
json "github.com/minio/colorjson"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
prom2json "github.com/prometheus/prom2json"
|
"github.com/prometheus/prom2json"
|
||||||
)
|
)
|
||||||
|
|
||||||
var adminPrometheusMetricsCmd = cli.Command{
|
var adminPrometheusMetricsCmd = cli.Command{
|
||||||
@ -119,7 +118,7 @@ func (pm prometheusMetricsReader) JSON() string {
|
|||||||
|
|
||||||
// String - returns the string representation of the prometheus metrics
|
// String - returns the string representation of the prometheus metrics
|
||||||
func (pm prometheusMetricsReader) String() string {
|
func (pm prometheusMetricsReader) String() string {
|
||||||
respBytes, e := ioutil.ReadAll(pm.Reader)
|
respBytes, e := io.ReadAll(pm.Reader)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
fatalIf(probe.NewError(e), "error reading metrics:")
|
fatalIf(probe.NewError(e), "error reading metrics:")
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func (i srRemoveStatus) JSON() string {
|
|||||||
|
|
||||||
func (i srRemoveStatus) String() string {
|
func (i srRemoveStatus) String() string {
|
||||||
if i.RemoveAll {
|
if i.RemoveAll {
|
||||||
return console.Colorize("UserMessage", fmt.Sprintf("All site(s) were removed successfully"))
|
return console.Colorize("UserMessage", "All site(s) were removed successfully")
|
||||||
}
|
}
|
||||||
return console.Colorize("UserMessage", fmt.Sprintf("Following site(s) %s were removed successfully", strings.Join(i.sites, ", ")))
|
return console.Colorize("UserMessage", fmt.Sprintf("Following site(s) %s were removed successfully", strings.Join(i.sites, ", ")))
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ func (i srStatus) String() string {
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
case !ss.HasUser:
|
case !ss.HasUser:
|
||||||
details = append(details, fmt.Sprintf("%s", blankCell))
|
details = append(details, blankCell)
|
||||||
case !ok, ss.UserInfoMismatch:
|
case !ok, ss.UserInfoMismatch:
|
||||||
details = append(details, fmt.Sprintf("%s in-sync", crossTickCell))
|
details = append(details, fmt.Sprintf("%s in-sync", crossTickCell))
|
||||||
default:
|
default:
|
||||||
@ -292,7 +292,7 @@ func (i srStatus) String() string {
|
|||||||
ss := ssMap[dID]
|
ss := ssMap[dID]
|
||||||
switch {
|
switch {
|
||||||
case !ss.HasGroup:
|
case !ss.HasGroup:
|
||||||
details = append(details, fmt.Sprintf("%s", blankCell))
|
details = append(details, blankCell)
|
||||||
case ss.GroupDescMismatch:
|
case ss.GroupDescMismatch:
|
||||||
details = append(details, fmt.Sprintf("%s in-sync", crossTickCell))
|
details = append(details, fmt.Sprintf("%s in-sync", crossTickCell))
|
||||||
default:
|
default:
|
||||||
@ -713,11 +713,11 @@ func mainAdminReplicationStatus(ctx *cli.Context) error {
|
|||||||
|
|
||||||
func syncStatus(mismatch, set bool) (string, string) {
|
func syncStatus(mismatch, set bool) (string, string) {
|
||||||
if !set {
|
if !set {
|
||||||
return "Entity", fmt.Sprintf("%s", blankCell)
|
return "Entity", blankCell
|
||||||
}
|
}
|
||||||
if mismatch {
|
if mismatch {
|
||||||
return "Entity", fmt.Sprintf("%s", crossTickCell)
|
return "Entity", crossTickCell
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Entity", fmt.Sprintf("%s", tickCell)
|
return "Entity", tickCell
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
json "github.com/minio/colorjson"
|
json "github.com/minio/colorjson"
|
||||||
madmin "github.com/minio/madmin-go/v2"
|
"github.com/minio/madmin-go/v2"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/pkg/console"
|
"github.com/minio/pkg/console"
|
||||||
)
|
)
|
||||||
@ -285,7 +285,7 @@ func fetchTierConfig(ctx *cli.Context, tierName string, tierType madmin.TierType
|
|||||||
}
|
}
|
||||||
|
|
||||||
credsPath := ctx.String("credentials-file")
|
credsPath := ctx.String("credentials-file")
|
||||||
credsBytes, err := ioutil.ReadFile(credsPath)
|
credsBytes, err := os.ReadFile(credsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalIf(probe.NewError(err), "Failed to read credentials file")
|
fatalIf(probe.NewError(err), "Failed to read credentials file")
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
madmin "github.com/minio/madmin-go/v2"
|
"github.com/minio/madmin-go/v2"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/pkg/console"
|
"github.com/minio/pkg/console"
|
||||||
)
|
)
|
||||||
@ -126,7 +126,7 @@ func mainAdminTierEdit(ctx *cli.Context) error {
|
|||||||
case accountKey != "": // Azure tier
|
case accountKey != "": // Azure tier
|
||||||
creds.SecretKey = accountKey
|
creds.SecretKey = accountKey
|
||||||
case credsPath != "": // GCS tier
|
case credsPath != "": // GCS tier
|
||||||
credsBytes, err := ioutil.ReadFile(credsPath)
|
credsBytes, err := os.ReadFile(credsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalIf(probe.NewError(err), "Failed to read credentials file")
|
fatalIf(probe.NewError(err), "Failed to read credentials file")
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
humanize "github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/minio/madmin-go/v2"
|
"github.com/minio/madmin-go/v2"
|
||||||
"github.com/navidys/tvxwidgets"
|
"github.com/navidys/tvxwidgets"
|
||||||
@ -46,7 +46,7 @@ func quitOnKeys(app *tview.Application) func(event *tcell.EventKey) *tcell.Event
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts tierInfos) TableUI() *tview.Table {
|
func (t tierInfos) TableUI() *tview.Table {
|
||||||
table := tview.NewTable().
|
table := tview.NewTable().
|
||||||
SetBorders(true)
|
SetBorders(true)
|
||||||
columnHdrs := []string{"Name", "API", "Type", "Usage", "Objects", "Versions"}
|
columnHdrs := []string{"Name", "API", "Type", "Usage", "Objects", "Versions"}
|
||||||
@ -63,7 +63,7 @@ func (ts tierInfos) TableUI() *tview.Table {
|
|||||||
}
|
}
|
||||||
return "warm"
|
return "warm"
|
||||||
}
|
}
|
||||||
for i, tInfo := range ts {
|
for i, tInfo := range t {
|
||||||
table.SetCell(i+1, 0,
|
table.SetCell(i+1, 0,
|
||||||
tview.NewTableCell(tInfo.Name).
|
tview.NewTableCell(tInfo.Name).
|
||||||
SetTextColor(tcell.ColorWhite).
|
SetTextColor(tcell.ColorWhite).
|
||||||
@ -93,10 +93,10 @@ func (ts tierInfos) TableUI() *tview.Table {
|
|||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts tierInfos) Barcharts(tier string) (objects *tvxwidgets.BarChart, versions *tvxwidgets.BarChart) {
|
func (t tierInfos) Barcharts(tier string) (objects *tvxwidgets.BarChart, versions *tvxwidgets.BarChart) {
|
||||||
var maxObj int
|
var maxObj int
|
||||||
var maxVer int
|
var maxVer int
|
||||||
for _, t := range ts {
|
for _, t := range t {
|
||||||
if maxObj < t.Stats.NumObjects {
|
if maxObj < t.Stats.NumObjects {
|
||||||
maxObj = t.Stats.NumObjects
|
maxObj = t.Stats.NumObjects
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ func (ts tierInfos) Barcharts(tier string) (objects *tvxwidgets.BarChart, versio
|
|||||||
versions.SetMaxValue(maxVer)
|
versions.SetMaxValue(maxVer)
|
||||||
|
|
||||||
var tInfo madmin.TierInfo
|
var tInfo madmin.TierInfo
|
||||||
for _, t := range ts {
|
for _, t := range t {
|
||||||
if t.Name == tier {
|
if t.Name == tier {
|
||||||
tInfo = t
|
tInfo = t
|
||||||
break
|
break
|
||||||
@ -131,9 +131,8 @@ func (ts tierInfos) Barcharts(tier string) (objects *tvxwidgets.BarChart, versio
|
|||||||
hrs := 23
|
hrs := 23
|
||||||
for i := 1; i <= 24; i++ {
|
for i := 1; i <= 24; i++ {
|
||||||
if hrs == 0 {
|
if hrs == 0 {
|
||||||
objects.AddBar(fmt.Sprintf("now"), dailyStats.Bins[(lastIdx+i)%24].NumObjects, tcell.ColorRed)
|
objects.AddBar("now", dailyStats.Bins[(lastIdx+i)%24].NumObjects, tcell.ColorRed)
|
||||||
versions.AddBar(fmt.Sprintf("now"), dailyStats.Bins[(lastIdx+i)%24].NumVersions, tcell.ColorBlue)
|
versions.AddBar("now", dailyStats.Bins[(lastIdx+i)%24].NumVersions, tcell.ColorBlue)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
objects.AddBar(fmt.Sprintf("-%d", hrs), dailyStats.Bins[(lastIdx+i)%24].NumObjects, tcell.ColorRed)
|
objects.AddBar(fmt.Sprintf("-%d", hrs), dailyStats.Bins[(lastIdx+i)%24].NumObjects, tcell.ColorRed)
|
||||||
versions.AddBar(fmt.Sprintf("-%d", hrs), dailyStats.Bins[(lastIdx+i)%24].NumVersions, tcell.ColorBlue)
|
versions.AddBar(fmt.Sprintf("-%d", hrs), dailyStats.Bins[(lastIdx+i)%24].NumVersions, tcell.ColorBlue)
|
||||||
|
@ -459,7 +459,7 @@ func shortTrace(ti madmin.ServiceTraceInfo) shortTraceMsg {
|
|||||||
s.StatusMsg = http.StatusText(t.HTTP.RespInfo.StatusCode)
|
s.StatusMsg = http.StatusText(t.HTTP.RespInfo.StatusCode)
|
||||||
s.Client = t.HTTP.ReqInfo.Client
|
s.Client = t.HTTP.ReqInfo.Client
|
||||||
s.CallStats = &callStats{}
|
s.CallStats = &callStats{}
|
||||||
s.CallStats.Duration = t.HTTP.CallStats.Latency
|
s.CallStats.Duration = t.Duration
|
||||||
s.CallStats.Rx = t.HTTP.CallStats.InputBytes
|
s.CallStats.Rx = t.HTTP.CallStats.InputBytes
|
||||||
s.CallStats.Tx = t.HTTP.CallStats.OutputBytes
|
s.CallStats.Tx = t.HTTP.CallStats.OutputBytes
|
||||||
}
|
}
|
||||||
@ -543,8 +543,6 @@ func colorizedNodeName(nodeName string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t traceMessage) JSON() string {
|
func (t traceMessage) JSON() string {
|
||||||
t.Status = "success"
|
|
||||||
|
|
||||||
trc := verboseTrace{
|
trc := verboseTrace{
|
||||||
trcType: t.Trace.TraceType,
|
trcType: t.Trace.TraceType,
|
||||||
Type: t.Trace.TraceType.String(),
|
Type: t.Trace.TraceType.String(),
|
||||||
@ -653,7 +651,7 @@ func (t traceMessage) String() string {
|
|||||||
fmt.Fprintf(b, "%s%s", nodeNameStr, console.Colorize("Body", fmt.Sprintf("%s\n", string(ri.Body))))
|
fmt.Fprintf(b, "%s%s", nodeNameStr, console.Colorize("Body", fmt.Sprintf("%s\n", string(ri.Body))))
|
||||||
fmt.Fprintf(b, "%s%s", nodeNameStr, console.Colorize("Response", "[RESPONSE] "))
|
fmt.Fprintf(b, "%s%s", nodeNameStr, console.Colorize("Response", "[RESPONSE] "))
|
||||||
fmt.Fprintf(b, "[%s] ", rs.Time.Local().Format(traceTimeFormat))
|
fmt.Fprintf(b, "[%s] ", rs.Time.Local().Format(traceTimeFormat))
|
||||||
fmt.Fprint(b, console.Colorize("Stat", fmt.Sprintf("[ Duration %2s ↑ %s ↓ %s ]\n", trc.HTTP.CallStats.Latency.Round(time.Microsecond), humanize.IBytes(uint64(trc.HTTP.CallStats.InputBytes)), humanize.IBytes(uint64(trc.HTTP.CallStats.OutputBytes)))))
|
fmt.Fprint(b, console.Colorize("Stat", fmt.Sprintf("[ Duration %2s ↑ %s ↓ %s ]\n", trc.Duration.Round(time.Microsecond), humanize.IBytes(uint64(trc.HTTP.CallStats.InputBytes)), humanize.IBytes(uint64(trc.HTTP.CallStats.OutputBytes)))))
|
||||||
|
|
||||||
statusStr := console.Colorize("RespStatus", fmt.Sprintf("%d %s", rs.StatusCode, http.StatusText(rs.StatusCode)))
|
statusStr := console.Colorize("RespStatus", fmt.Sprintf("%d %s", rs.StatusCode, http.StatusText(rs.StatusCode)))
|
||||||
if rs.StatusCode != http.StatusOK {
|
if rs.StatusCode != http.StatusOK {
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
json "github.com/minio/colorjson"
|
json "github.com/minio/colorjson"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/pkg/console"
|
"github.com/minio/pkg/console"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
var adminUserAddCmd = cli.Command{
|
var adminUserAddCmd = cli.Command{
|
||||||
@ -136,7 +136,7 @@ func fetchUserKeys(args cli.Args) (string, string) {
|
|||||||
accessKey := ""
|
accessKey := ""
|
||||||
secretKey := ""
|
secretKey := ""
|
||||||
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
||||||
isTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
|
isTerminal := term.IsTerminal(int(os.Stdin.Fd()))
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
argCount := len(args)
|
argCount := len(args)
|
||||||
@ -154,7 +154,7 @@ func fetchUserKeys(args cli.Args) (string, string) {
|
|||||||
if argCount == 1 || argCount == 2 {
|
if argCount == 1 || argCount == 2 {
|
||||||
if isTerminal {
|
if isTerminal {
|
||||||
fmt.Printf("%s", console.Colorize(cred, "Enter Secret Key: "))
|
fmt.Printf("%s", console.Colorize(cred, "Enter Secret Key: "))
|
||||||
bytePassword, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
bytePassword, _ := term.ReadPassword(int(os.Stdin.Fd()))
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
secretKey = string(bytePassword)
|
secretKey = string(bytePassword)
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
@ -163,7 +163,7 @@ func mainAdminUserSvcAcctAdd(ctx *cli.Context) error {
|
|||||||
if policyPath != "" {
|
if policyPath != "" {
|
||||||
// Validate the policy document and ensure it has at least when statement
|
// Validate the policy document and ensure it has at least when statement
|
||||||
var e error
|
var e error
|
||||||
policyBytes, e = ioutil.ReadFile(policyPath)
|
policyBytes, e = os.ReadFile(policyPath)
|
||||||
fatalIf(probe.NewError(e), "Unable to open the policy document.")
|
fatalIf(probe.NewError(e), "Unable to open the policy document.")
|
||||||
p, e := iampolicy.ParseConfig(bytes.NewReader(policyBytes))
|
p, e := iampolicy.ParseConfig(bytes.NewReader(policyBytes))
|
||||||
fatalIf(probe.NewError(e), "Unable to parse the policy document.")
|
fatalIf(probe.NewError(e), "Unable to parse the policy document.")
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/madmin-go/v2"
|
"github.com/minio/madmin-go/v2"
|
||||||
@ -85,7 +85,7 @@ func mainAdminUserSvcAcctSet(ctx *cli.Context) error {
|
|||||||
var buf []byte
|
var buf []byte
|
||||||
if policyPath != "" {
|
if policyPath != "" {
|
||||||
var e error
|
var e error
|
||||||
buf, e = ioutil.ReadFile(policyPath)
|
buf, e = os.ReadFile(policyPath)
|
||||||
fatalIf(probe.NewError(e), "Unable to open the policy document.")
|
fatalIf(probe.NewError(e), "Unable to open the policy document.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import (
|
|||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
"github.com/minio/pkg/console"
|
"github.com/minio/pkg/console"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -268,7 +267,7 @@ func fetchAliasKeys(args cli.Args) (string, string) {
|
|||||||
accessKey := ""
|
accessKey := ""
|
||||||
secretKey := ""
|
secretKey := ""
|
||||||
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
||||||
isTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
|
isTerminal := term.IsTerminal(int(os.Stdin.Fd()))
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
argsNr := len(args)
|
argsNr := len(args)
|
||||||
@ -286,7 +285,7 @@ func fetchAliasKeys(args cli.Args) (string, string) {
|
|||||||
if argsNr == 2 || argsNr == 3 {
|
if argsNr == 2 || argsNr == 3 {
|
||||||
if isTerminal {
|
if isTerminal {
|
||||||
fmt.Printf("%s", console.Colorize(cred, "Enter Secret Key: "))
|
fmt.Printf("%s", console.Colorize(cred, "Enter Secret Key: "))
|
||||||
bytePassword, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
bytePassword, _ := term.ReadPassword(int(os.Stdin.Fd()))
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
secretKey = string(bytePassword)
|
secretKey = string(bytePassword)
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
@ -93,7 +93,7 @@ func mainBatchStart(ctx *cli.Context) error {
|
|||||||
adminClient, err := newAdminClient(aliasedURL)
|
adminClient, err := newAdminClient(aliasedURL)
|
||||||
fatalIf(err, "Unable to initialize admin connection.")
|
fatalIf(err, "Unable to initialize admin connection.")
|
||||||
|
|
||||||
buf, e := ioutil.ReadFile(args.Get(1))
|
buf, e := os.ReadFile(args.Get(1))
|
||||||
fatalIf(probe.NewError(e), "Unable to read %s", args.Get(1))
|
fatalIf(probe.NewError(e), "Unable to read %s", args.Get(1))
|
||||||
|
|
||||||
ctxt, cancel := context.WithCancel(globalContext)
|
ctxt, cancel := context.WithCancel(globalContext)
|
||||||
|
@ -203,8 +203,8 @@ func (m *batchJobMetricsUI) View() string {
|
|||||||
addLine("Throughput: ", fmt.Sprintf("%s/s", humanize.IBytes(uint64(bytesTransferredPerSec))))
|
addLine("Throughput: ", fmt.Sprintf("%s/s", humanize.IBytes(uint64(bytesTransferredPerSec))))
|
||||||
addLine("IOPs: ", fmt.Sprintf("%.2f objs/s", objectsPerSec))
|
addLine("IOPs: ", fmt.Sprintf("%.2f objs/s", objectsPerSec))
|
||||||
}
|
}
|
||||||
addLine("Transferred: ", fmt.Sprintf("%s", humanize.IBytes(uint64(m.current.Replicate.BytesTransferred))))
|
addLine("Transferred: ", humanize.IBytes(uint64(m.current.Replicate.BytesTransferred)))
|
||||||
addLine("Elapsed: ", fmt.Sprintf("%s", accElapsedTime))
|
addLine("Elapsed: ", accElapsedTime.String())
|
||||||
addLine("CurrObjName: ", m.current.Replicate.Object)
|
addLine("CurrObjName: ", m.current.Replicate.Object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ func TestPrettyStdout(t *testing.T) {
|
|||||||
if int(n) != len(testCase.originText) {
|
if int(n) != len(testCase.originText) {
|
||||||
t.Fatalf("Test %d: copy error\n", i+1)
|
t.Fatalf("Test %d: copy error\n", i+1)
|
||||||
}
|
}
|
||||||
prettyText, err := ioutil.ReadAll(fakeStdout)
|
prettyText, err := io.ReadAll(fakeStdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test %d: %v", i+1, err)
|
t.Fatalf("Test %d: %v", i+1, err)
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ func fsNew(path string) (Client, *probe.Error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//lint:ignore U1000 Used on some platforms.
|
||||||
func isNotSupported(e error) bool {
|
func isNotSupported(e error) bool {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return false
|
return false
|
||||||
@ -546,7 +547,7 @@ func (f *fsClient) Get(ctx context.Context, opts GetOptions) (io.ReadCloser, *pr
|
|||||||
return nil, err.Trace(f.PathURL.Path)
|
return nil, err.Trace(f.PathURL.Path)
|
||||||
}
|
}
|
||||||
if opts.RangeStart != 0 {
|
if opts.RangeStart != 0 {
|
||||||
_, e := fileData.Seek(opts.RangeStart, os.SEEK_SET)
|
_, e := fileData.Seek(opts.RangeStart, io.SeekStart)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
err := f.toClientError(e, f.PathURL.Path)
|
err := f.toClientError(e, f.PathURL.Path)
|
||||||
return nil, err.Trace(f.PathURL.Path)
|
return nil, err.Trace(f.PathURL.Path)
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -31,7 +30,7 @@ import (
|
|||||||
|
|
||||||
// Test list files in a folder.
|
// Test list files in a folder.
|
||||||
func (s *TestSuite) TestList(c *C) {
|
func (s *TestSuite) TestList(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -197,7 +196,7 @@ func (s *TestSuite) TestList(c *C) {
|
|||||||
|
|
||||||
// Test put bucket aka 'mkdir()' operation.
|
// Test put bucket aka 'mkdir()' operation.
|
||||||
func (s *TestSuite) TestPutBucket(c *C) {
|
func (s *TestSuite) TestPutBucket(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -210,7 +209,7 @@ func (s *TestSuite) TestPutBucket(c *C) {
|
|||||||
|
|
||||||
// Test stat bucket aka 'stat()' operation.
|
// Test stat bucket aka 'stat()' operation.
|
||||||
func (s *TestSuite) TestStatBucket(c *C) {
|
func (s *TestSuite) TestStatBucket(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -226,7 +225,7 @@ func (s *TestSuite) TestStatBucket(c *C) {
|
|||||||
|
|
||||||
// Test bucket acl fails for directories.
|
// Test bucket acl fails for directories.
|
||||||
func (s *TestSuite) TestBucketACLFails(c *C) {
|
func (s *TestSuite) TestBucketACLFails(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -248,7 +247,7 @@ func (s *TestSuite) TestBucketACLFails(c *C) {
|
|||||||
|
|
||||||
// Test creating a file.
|
// Test creating a file.
|
||||||
func (s *TestSuite) TestPut(c *C) {
|
func (s *TestSuite) TestPut(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -272,7 +271,7 @@ func (s *TestSuite) TestPut(c *C) {
|
|||||||
|
|
||||||
// Test read a file.
|
// Test read a file.
|
||||||
func (s *TestSuite) TestGet(c *C) {
|
func (s *TestSuite) TestGet(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -301,7 +300,7 @@ func (s *TestSuite) TestGet(c *C) {
|
|||||||
|
|
||||||
// Test get range in a file.
|
// Test get range in a file.
|
||||||
func (s *TestSuite) TestGetRange(c *C) {
|
func (s *TestSuite) TestGetRange(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -334,7 +333,7 @@ func (s *TestSuite) TestGetRange(c *C) {
|
|||||||
|
|
||||||
// Test stat file.
|
// Test stat file.
|
||||||
func (s *TestSuite) TestStatObject(c *C) {
|
func (s *TestSuite) TestStatObject(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
@ -361,7 +360,7 @@ func (s *TestSuite) TestStatObject(c *C) {
|
|||||||
|
|
||||||
// Test copy.
|
// Test copy.
|
||||||
func (s *TestSuite) TestCopy(c *C) {
|
func (s *TestSuite) TestCopy(c *C) {
|
||||||
root, e := ioutil.TempDir(os.TempDir(), "fs-")
|
root, e := os.MkdirTemp(os.TempDir(), "fs-")
|
||||||
c.Assert(e, IsNil)
|
c.Assert(e, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
sourcePath := filepath.Join(root, "source")
|
sourcePath := filepath.Join(root, "source")
|
||||||
|
@ -1406,7 +1406,7 @@ func (c *S3Client) RemoveBucket(ctx context.Context, forceRemove bool) *probe.Er
|
|||||||
return probe.NewError(BucketInvalid{c.joinPath(bucket, object)})
|
return probe.NewError(BucketInvalid{c.joinPath(bucket, object)})
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := minio.BucketOptions{ForceDelete: forceRemove}
|
opts := minio.RemoveBucketOptions{ForceDelete: forceRemove}
|
||||||
if e := c.api.RemoveBucketWithOptions(ctx, bucket, opts); e != nil {
|
if e := c.api.RemoveBucketWithOptions(ctx, bucket, opts); e != nil {
|
||||||
return probe.NewError(e)
|
return probe.NewError(e)
|
||||||
}
|
}
|
||||||
|
@ -108,10 +108,7 @@ func fixConfigV3() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the correct hostConfig with JSON tags in it.
|
// Use the correct hostConfig with JSON tags in it.
|
||||||
cfgV3.Hosts[host] = hostConfigV3{
|
cfgV3.Hosts[host] = hostConfigV3(brokenHostCfgV3)
|
||||||
AccessKeyID: brokenHostCfgV3.AccessKeyID,
|
|
||||||
SecretAccessKey: brokenHostCfgV3.SecretAccessKey,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We blindly drop ACL and Access fields from the broken config v3.
|
// We blindly drop ACL and Access fields from the broken config v3.
|
||||||
|
@ -76,10 +76,7 @@ func migrateConfigV1ToV101() {
|
|||||||
|
|
||||||
// Copy hosts.
|
// Copy hosts.
|
||||||
for k, hostCfgV1 := range mcCfgV1.Data().(*configV1).Hosts {
|
for k, hostCfgV1 := range mcCfgV1.Data().(*configV1).Hosts {
|
||||||
cfgV101.Hosts[k] = hostConfigV101{
|
cfgV101.Hosts[k] = hostConfigV101(hostCfgV1)
|
||||||
AccessKeyID: hostCfgV1.AccessKeyID,
|
|
||||||
SecretAccessKey: hostCfgV1.SecretAccessKey,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example localhost entry.
|
// Example localhost entry.
|
||||||
@ -137,10 +134,7 @@ func migrateConfigV101ToV2() {
|
|||||||
|
|
||||||
// Copy hosts.
|
// Copy hosts.
|
||||||
for k, hostCfgV101 := range mcCfgV101.Data().(*configV101).Hosts {
|
for k, hostCfgV101 := range mcCfgV101.Data().(*configV101).Hosts {
|
||||||
cfgV2.Hosts[k] = hostConfigV2{
|
cfgV2.Hosts[k] = hostConfigV2(hostCfgV101)
|
||||||
AccessKeyID: hostCfgV101.AccessKeyID,
|
|
||||||
SecretAccessKey: hostCfgV101.SecretAccessKey,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mcCfgV2, e := quick.NewConfig(cfgV2, nil)
|
mcCfgV2, e := quick.NewConfig(cfgV2, nil)
|
||||||
@ -179,10 +173,7 @@ func migrateConfigV2ToV3() {
|
|||||||
// Copy hosts.
|
// Copy hosts.
|
||||||
for k, hostCfgV2 := range mcCfgV2.Data().(*configV2).Hosts {
|
for k, hostCfgV2 := range mcCfgV2.Data().(*configV2).Hosts {
|
||||||
// New hostConfV3 uses struct json tags.
|
// New hostConfV3 uses struct json tags.
|
||||||
cfgV3.Hosts[k] = hostConfigV3{
|
cfgV3.Hosts[k] = hostConfigV3(hostCfgV2)
|
||||||
AccessKeyID: hostCfgV2.AccessKeyID,
|
|
||||||
SecretAccessKey: hostCfgV2.SecretAccessKey,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mcNewCfgV3, e := quick.NewConfig(cfgV3, nil)
|
mcNewCfgV3, e := quick.NewConfig(cfgV3, nil)
|
||||||
@ -326,11 +317,7 @@ func migrateConfigV5ToV6() {
|
|||||||
host = "*s3*amazonaws.com" // Use this glob entry.
|
host = "*s3*amazonaws.com" // Use this glob entry.
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgV6.Hosts[host] = hostConfigV6{
|
cfgV6.Hosts[host] = hostConfigV6(hostCfgV5)
|
||||||
AccessKeyID: hostCfgV5.AccessKeyID,
|
|
||||||
SecretAccessKey: hostCfgV5.SecretAccessKey,
|
|
||||||
API: hostCfgV5.API,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mcNewCfgV6, e := quick.NewConfig(cfgV6, nil)
|
mcNewCfgV6, e := quick.NewConfig(cfgV6, nil)
|
||||||
|
@ -22,11 +22,12 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func normalizePath(path string) string {
|
func normalizePath(path string) string {
|
||||||
if filepath.VolumeName(path) == "" && filepath.HasPrefix(path, "\\") {
|
if filepath.VolumeName(path) == "" && strings.HasPrefix(path, "\\") {
|
||||||
var err error
|
var err error
|
||||||
path, err = syscall.FullPath(path)
|
path, err = syscall.FullPath(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -114,7 +113,7 @@ func headURL(sourceURL, sourceVersion string, timeRef time.Time, encKeyDB map[st
|
|||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
} else if strings.Contains(ctype, "bzip") {
|
} else if strings.Contains(ctype, "bzip") {
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
reader = ioutil.NopCloser(bzip2.NewReader(reader))
|
reader = io.NopCloser(bzip2.NewReader(reader))
|
||||||
} else {
|
} else {
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func (opts LifecycleOptions) ToILMRule(config *lifecycle.Configuration) (lifecyc
|
|||||||
|
|
||||||
id = opts.ID
|
id = opts.ID
|
||||||
status = func() string {
|
status = func() string {
|
||||||
if opts.Status != nil && *opts.Status == false {
|
if opts.Status != nil && !*opts.Status {
|
||||||
return "Disabled"
|
return "Disabled"
|
||||||
}
|
}
|
||||||
// Generating a new ILM rule without explicit status is enabled
|
// Generating a new ILM rule without explicit status is enabled
|
||||||
|
@ -470,7 +470,7 @@ func (mj *mirrorJob) doMirror(ctx context.Context, sURLs URLs) URLs {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
ret := uploadSourceToTargetURL(ctx, sURLs, mj.status, mj.opts.encKeyDB, mj.opts.isMetadata, false)
|
ret := uploadSourceToTargetURL(ctx, sURLs, mj.status, mj.opts.encKeyDB, mj.opts.isMetadata, false)
|
||||||
if ret.Error == nil {
|
if ret.Error == nil {
|
||||||
durationMs := time.Since(now) / time.Millisecond
|
durationMs := time.Since(now).Milliseconds()
|
||||||
mirrorReplicationDurations.With(prometheus.Labels{"object_size": convertSizeToTag(sURLs.SourceContent.Size)}).Observe(float64(durationMs))
|
mirrorReplicationDurations.With(prometheus.Labels{"object_size": convertSizeToTag(sURLs.SourceContent.Size)}).Observe(float64(durationMs))
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@ -26,7 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
mem "github.com/shirou/gopsutil/v3/mem"
|
"github.com/shirou/gopsutil/v3/mem"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -225,7 +225,7 @@ func (p *ParallelManager) stopAndWait() {
|
|||||||
const cgroupLimitFile = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
|
const cgroupLimitFile = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
|
||||||
|
|
||||||
func cgroupLimit(limitFile string) (limit uint64) {
|
func cgroupLimit(limitFile string) (limit uint64) {
|
||||||
buf, err := ioutil.ReadFile(limitFile)
|
buf, err := os.ReadFile(limitFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 9223372036854771712
|
return 9223372036854771712
|
||||||
}
|
}
|
||||||
|
@ -217,9 +217,9 @@ func (m retentionInfoMessageRecord) String() string {
|
|||||||
|
|
||||||
fmt.Fprintf(&msg, "Mode : ")
|
fmt.Fprintf(&msg, "Mode : ")
|
||||||
if m.Mode == "" {
|
if m.Mode == "" {
|
||||||
fmt.Fprintf(&msg, console.Colorize("RetentionNotFound", "NO RETENTION"))
|
fmt.Fprint(&msg, console.Colorize("RetentionNotFound", "NO RETENTION"))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(&msg, console.Colorize("RetentionSuccess", m.Mode))
|
fmt.Fprint(&msg, console.Colorize("RetentionSuccess", m.Mode))
|
||||||
if !m.Until.IsZero() {
|
if !m.Until.IsZero() {
|
||||||
msg.WriteString(", ")
|
msg.WriteString(", ")
|
||||||
exp := ""
|
exp := ""
|
||||||
@ -231,10 +231,10 @@ func (m retentionInfoMessageRecord) String() string {
|
|||||||
prettyDuration := timeDurationToHumanizedDuration(m.Until.Sub(now)).StringShort()
|
prettyDuration := timeDurationToHumanizedDuration(m.Until.Sub(now)).StringShort()
|
||||||
exp = console.Colorize("RetentionSuccess", "expiring in "+prettyDuration)
|
exp = console.Colorize("RetentionSuccess", "expiring in "+prettyDuration)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&msg, exp)
|
fmt.Fprint(&msg, exp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&msg, "\n")
|
fmt.Fprint(&msg, "\n")
|
||||||
return msg.String()
|
return msg.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,25 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||||
|
|
||||||
|
// newRandomID generates a random id of regular lower case and uppercase english characters.
|
||||||
|
func newRandomID(n int) string {
|
||||||
|
rand.Seed(UTCNow().UnixNano())
|
||||||
|
sid := make([]rune, n)
|
||||||
|
for i := range sid {
|
||||||
|
sid[i] = letters[rand.Intn(len(letters))]
|
||||||
|
}
|
||||||
|
return string(sid)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *TestSuite) TestValidSessionID(c *C) {
|
func (s *TestSuite) TestValidSessionID(c *C) {
|
||||||
validSid := regexp.MustCompile("^[a-zA-Z]+$")
|
validSid := regexp.MustCompile("^[a-zA-Z]+$")
|
||||||
sid := newRandomID(8)
|
sid := newRandomID(8)
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -323,7 +322,7 @@ func getCSVHeader(sourceURL string, encKeyDB map[string][]prefixSSEPair) ([]stri
|
|||||||
defer r.Close()
|
defer r.Close()
|
||||||
} else if strings.Contains(ctype, "bzip") {
|
} else if strings.Contains(ctype, "bzip") {
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
r = ioutil.NopCloser(bzip2.NewReader(r))
|
r = io.NopCloser(bzip2.NewReader(r))
|
||||||
} else {
|
} else {
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
}
|
}
|
||||||
|
30
cmd/stat.go
30
cmd/stat.go
@ -369,57 +369,57 @@ func prettyPrintBucketMetadata(info BucketInfo) string {
|
|||||||
placeHolder := ""
|
placeHolder := ""
|
||||||
if info.Encryption.Algorithm != "" {
|
if info.Encryption.Algorithm != "" {
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Encryption: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Encryption: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Key", "\n\tAlgorithm: "))
|
fmt.Fprint(&b, console.Colorize("Key", "\n\tAlgorithm: "))
|
||||||
fmt.Fprintf(&b, console.Colorize("Value", info.Encryption.Algorithm))
|
fmt.Fprint(&b, console.Colorize("Value", info.Encryption.Algorithm))
|
||||||
fmt.Fprintf(&b, console.Colorize("Key", "\n\tKey ID: "))
|
fmt.Fprint(&b, console.Colorize("Key", "\n\tKey ID: "))
|
||||||
fmt.Fprintf(&b, console.Colorize("Value", info.Encryption.KeyID))
|
fmt.Fprint(&b, console.Colorize("Value", info.Encryption.KeyID))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Versioning: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Versioning: ")
|
||||||
if info.Versioning.Status == "" {
|
if info.Versioning.Status == "" {
|
||||||
fmt.Fprintf(&b, console.Colorize("Unset", "Un-versioned"))
|
fmt.Fprint(&b, console.Colorize("Unset", "Un-versioned"))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(&b, console.Colorize("Set", info.Versioning.Status))
|
fmt.Fprint(&b, console.Colorize("Set", info.Versioning.Status))
|
||||||
}
|
}
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
|
|
||||||
if info.Locking.Mode != "" {
|
if info.Locking.Mode != "" {
|
||||||
fmt.Fprintf(&b, "%2s%s\n", placeHolder, "LockConfiguration: ")
|
fmt.Fprintf(&b, "%2s%s\n", placeHolder, "LockConfiguration: ")
|
||||||
fmt.Fprintf(&b, "%4s%s", placeHolder, "RetentionMode: ")
|
fmt.Fprintf(&b, "%4s%s", placeHolder, "RetentionMode: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Value", info.Locking.Mode))
|
fmt.Fprint(&b, console.Colorize("Value", info.Locking.Mode))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
fmt.Fprintf(&b, "%4s%s", placeHolder, "Retention Until Date: ")
|
fmt.Fprintf(&b, "%4s%s", placeHolder, "Retention Until Date: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Value", info.Locking.Validity))
|
fmt.Fprint(&b, console.Colorize("Value", info.Locking.Validity))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
}
|
}
|
||||||
if len(info.Notification.Config.TopicConfigs) > 0 {
|
if len(info.Notification.Config.TopicConfigs) > 0 {
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Notification: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Notification: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Set", "Set"))
|
fmt.Fprint(&b, console.Colorize("Set", "Set"))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
}
|
}
|
||||||
if info.Replication.Enabled {
|
if info.Replication.Enabled {
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Replication: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Replication: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Set", "Enabled"))
|
fmt.Fprint(&b, console.Colorize("Set", "Enabled"))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Location: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Location: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Generic", info.Location))
|
fmt.Fprint(&b, console.Colorize("Generic", info.Location))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Policy: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Policy: ")
|
||||||
if info.Policy.Type == "none" {
|
if info.Policy.Type == "none" {
|
||||||
fmt.Fprintf(&b, console.Colorize("UnSet", info.Policy.Type))
|
fmt.Fprint(&b, console.Colorize("UnSet", info.Policy.Type))
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(&b, console.Colorize("Set", info.Policy.Type))
|
fmt.Fprint(&b, console.Colorize("Set", info.Policy.Type))
|
||||||
}
|
}
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
if info.Tags() != "" {
|
if info.Tags() != "" {
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "Tagging: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "Tagging: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Generic", info.Tags()))
|
fmt.Fprint(&b, console.Colorize("Generic", info.Tags()))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
}
|
}
|
||||||
if info.ILM.Config != nil {
|
if info.ILM.Config != nil {
|
||||||
fmt.Fprintf(&b, "%2s%s", placeHolder, "ILM: ")
|
fmt.Fprintf(&b, "%2s%s", placeHolder, "ILM: ")
|
||||||
fmt.Fprintf(&b, console.Colorize("Set", "Set"))
|
fmt.Fprint(&b, console.Colorize("Set", "Set"))
|
||||||
fmt.Fprintln(&b)
|
fmt.Fprintln(&b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -40,7 +39,7 @@ import (
|
|||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/pkg/licverifier"
|
"github.com/minio/pkg/licverifier"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -192,7 +191,7 @@ func subnetReqDo(r *http.Request, headers map[string]string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
respBytes, e := ioutil.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit))
|
respBytes, e := io.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return "", e
|
return "", e
|
||||||
}
|
}
|
||||||
@ -435,7 +434,7 @@ func subnetLogin() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Print("Password: ")
|
fmt.Print("Password: ")
|
||||||
bytepw, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
bytepw, _ := term.ReadPassword(int(os.Stdin.Fd()))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
loginReq := map[string]string{
|
loginReq := map[string]string{
|
||||||
@ -451,7 +450,7 @@ func subnetLogin() (string, error) {
|
|||||||
if mfaRequired {
|
if mfaRequired {
|
||||||
mfaToken := gjson.Get(respStr, "mfa_token").String()
|
mfaToken := gjson.Get(respStr, "mfa_token").String()
|
||||||
fmt.Print("OTP received in email: ")
|
fmt.Print("OTP received in email: ")
|
||||||
byteotp, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
byteotp, _ := term.ReadPassword(int(os.Stdin.Fd()))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
mfaLoginReq := SubnetMFAReq{Username: username, OTP: string(byteotp), Token: mfaToken}
|
mfaLoginReq := SubnetMFAReq{Username: username, OTP: string(byteotp), Token: mfaToken}
|
||||||
|
@ -88,9 +88,9 @@ func (t inspectMessage) String() string {
|
|||||||
msg += fmt.Sprintf("Encrypted file data successfully downloaded as %s\n", console.Colorize("File", t.File))
|
msg += fmt.Sprintf("Encrypted file data successfully downloaded as %s\n", console.Colorize("File", t.File))
|
||||||
msg += fmt.Sprintf("Decryption key: %s\n\n", console.Colorize("Key", t.Key))
|
msg += fmt.Sprintf("Decryption key: %s\n\n", console.Colorize("Key", t.Key))
|
||||||
|
|
||||||
msg += fmt.Sprintf("The decryption key will ONLY be shown here. It cannot be recovered.\n")
|
msg += "The decryption key will ONLY be shown here. It cannot be recovered.\n"
|
||||||
msg += fmt.Sprintf("The encrypted file can safely be shared without the decryption key.\n")
|
msg += "The encrypted file can safely be shared without the decryption key.\n"
|
||||||
msg += fmt.Sprintf("Even with the decryption key, data stored with encryption cannot be accessed.\n")
|
msg += "Even with the decryption key, data stored with encryption cannot be accessed.\n"
|
||||||
}
|
}
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ func mainSupportInspect(ctx *cli.Context) error {
|
|||||||
var keyHex string
|
var keyHex string
|
||||||
|
|
||||||
// Choose a name and move the inspect data to its final destination
|
// Choose a name and move the inspect data to its final destination
|
||||||
downloadPath := fmt.Sprintf("inspect-data.enc")
|
downloadPath := "inspect-data.enc"
|
||||||
if key != nil {
|
if key != nil {
|
||||||
// Create an id that is also crc.
|
// Create an id that is also crc.
|
||||||
var id [4]byte
|
var id [4]byte
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
humanize "github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/madmin-go/v2"
|
"github.com/minio/madmin-go/v2"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
@ -43,7 +43,7 @@ func mainAdminSpeedTestDrive(ctx *cli.Context, aliasedURL string, outCh chan<- P
|
|||||||
fatalIf(probe.NewError(e), "Unable to parse blocksize")
|
fatalIf(probe.NewError(e), "Unable to parse blocksize")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if blocksize < 0 {
|
if blocksize <= 0 {
|
||||||
fatalIf(errInvalidArgument(), "blocksize cannot be <= 0")
|
fatalIf(errInvalidArgument(), "blocksize cannot be <= 0")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ func mainAdminSpeedTestDrive(ctx *cli.Context, aliasedURL string, outCh chan<- P
|
|||||||
fatalIf(probe.NewError(e), "Unable to parse filesize")
|
fatalIf(probe.NewError(e), "Unable to parse filesize")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if filesize < 0 {
|
if filesize <= 0 {
|
||||||
fatalIf(errInvalidArgument(), "filesize cannot be <= 0")
|
fatalIf(errInvalidArgument(), "filesize cannot be <= 0")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -62,8 +62,8 @@ func mainAdminSpeedTestDrive(ctx *cli.Context, aliasedURL string, outCh chan<- P
|
|||||||
|
|
||||||
resultCh, e := client.DriveSpeedtest(ctxt, madmin.DriveSpeedTestOpts{
|
resultCh, e := client.DriveSpeedtest(ctxt, madmin.DriveSpeedTestOpts{
|
||||||
Serial: serial,
|
Serial: serial,
|
||||||
BlockSize: uint64(blocksize),
|
BlockSize: blocksize,
|
||||||
FileSize: uint64(filesize),
|
FileSize: filesize,
|
||||||
})
|
})
|
||||||
|
|
||||||
if globalJSON {
|
if globalJSON {
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
humanize "github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/madmin-go/v2"
|
"github.com/minio/madmin-go/v2"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
@ -70,8 +70,8 @@ func mainAdminSpeedTestObject(ctx *cli.Context, aliasedURL string, outCh chan<-
|
|||||||
fatalIf(probe.NewError(e), "Unable to parse object size")
|
fatalIf(probe.NewError(e), "Unable to parse object size")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if size < 0 {
|
if size <= 0 {
|
||||||
fatalIf(errInvalidArgument(), "size is expected to be atleast 0 bytes")
|
fatalIf(errInvalidArgument(), "size is expected to be more than 0 bytes")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
concurrent := ctx.Int("concurrent")
|
concurrent := ctx.Int("concurrent")
|
||||||
|
@ -19,7 +19,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -139,7 +138,7 @@ func moveFile(sourcePath, destPath string) error {
|
|||||||
|
|
||||||
func saveProfileFile(data io.ReadCloser) {
|
func saveProfileFile(data io.ReadCloser) {
|
||||||
// Create profile zip file
|
// Create profile zip file
|
||||||
tmpFile, e := ioutil.TempFile("", "mc-profile-")
|
tmpFile, e := os.CreateTemp("", "mc-profile-")
|
||||||
fatalIf(probe.NewError(e), "Unable to download profile data.")
|
fatalIf(probe.NewError(e), "Unable to download profile data.")
|
||||||
|
|
||||||
// Copy zip content to target download file
|
// Copy zip content to target download file
|
||||||
|
@ -101,7 +101,6 @@ func (u lockMessage) String() string {
|
|||||||
|
|
||||||
// JSON jsonified top oldest locks message.
|
// JSON jsonified top oldest locks message.
|
||||||
func (u lockMessage) JSON() string {
|
func (u lockMessage) JSON() string {
|
||||||
u.Status = "success"
|
|
||||||
type lockEntry struct {
|
type lockEntry struct {
|
||||||
Timestamp time.Time `json:"time"` // When the lock was first granted
|
Timestamp time.Time `json:"time"` // When the lock was first granted
|
||||||
Elapsed string `json:"elapsed"` // Humanized duration for which lock has been held
|
Elapsed string `json:"elapsed"` // Humanized duration for which lock has been held
|
||||||
|
@ -228,7 +228,9 @@ func undoURL(ctx context.Context, aliasedURL string, last int, recursive, dryRun
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Undo the remaining versions found if any
|
// Undo the remaining versions found if any
|
||||||
exitErr = undoLastNOperations(ctx, clnt, perObjectVersions, last, dryRun)
|
if len(perObjectVersions) > 0 {
|
||||||
|
exitErr = undoLastNOperations(ctx, clnt, perObjectVersions, last, dryRun)
|
||||||
|
}
|
||||||
|
|
||||||
if !atLeastOneUndoApplied {
|
if !atLeastOneUndoApplied {
|
||||||
errorIf(errDummy().Trace(clnt.GetURL().String()), "Unable to find any object version to undo.")
|
errorIf(errDummy().Trace(clnt.GetURL().String()), "Unable to find any object version to undo.")
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -36,7 +35,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
isatty "github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
json "github.com/minio/colorjson"
|
json "github.com/minio/colorjson"
|
||||||
"github.com/minio/mc/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
@ -244,7 +243,7 @@ func downloadReleaseURL(releaseChecksumURL string, timeout time.Duration) (conte
|
|||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return content, probe.NewError(fmt.Errorf("Error downloading URL %s. Response: %v", releaseChecksumURL, resp.Status))
|
return content, probe.NewError(fmt.Errorf("Error downloading URL %s. Response: %v", releaseChecksumURL, resp.Status))
|
||||||
}
|
}
|
||||||
contentBytes, e := ioutil.ReadAll(resp.Body)
|
contentBytes, e := io.ReadAll(resp.Body)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return content, probe.NewError(fmt.Errorf("Error reading response. %s", err))
|
return content, probe.NewError(fmt.Errorf("Error reading response. %s", err))
|
||||||
}
|
}
|
||||||
|
16
cmd/utils.go
16
cmd/utils.go
@ -75,18 +75,6 @@ func UTCNow() time.Time {
|
|||||||
return time.Now().UTC()
|
return time.Now().UTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
||||||
|
|
||||||
// newRandomID generates a random id of regular lower case and uppercase english characters.
|
|
||||||
func newRandomID(n int) string {
|
|
||||||
rand.Seed(UTCNow().UnixNano())
|
|
||||||
sid := make([]rune, n)
|
|
||||||
for i := range sid {
|
|
||||||
sid[i] = letters[rand.Intn(len(letters))]
|
|
||||||
}
|
|
||||||
return string(sid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func max(a, b int) int {
|
func max(a, b int) int {
|
||||||
if a > b {
|
if a > b {
|
||||||
return a
|
return a
|
||||||
@ -460,8 +448,8 @@ func httpClient(timeout time.Duration) *http.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPrometheusToken(hostConfig *aliasConfigV10) (string, error) {
|
func getPrometheusToken(hostConfig *aliasConfigV10) (string, error) {
|
||||||
jwt := jwtgo.NewWithClaims(jwtgo.SigningMethodHS512, jwtgo.StandardClaims{
|
jwt := jwtgo.NewWithClaims(jwtgo.SigningMethodHS512, jwtgo.RegisteredClaims{
|
||||||
ExpiresAt: UTCNow().Add(defaultPrometheusJWTExpiry).Unix(),
|
ExpiresAt: jwtgo.NewNumericDate(UTCNow().Add(defaultPrometheusJWTExpiry)),
|
||||||
Subject: hostConfig.AccessKey,
|
Subject: hostConfig.AccessKey,
|
||||||
Issuer: "prometheus",
|
Issuer: "prometheus",
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user