Improve output readability for mc stat command (#4597)

This commit is contained in:
r-sc
2023-06-14 07:44:46 -07:00
committed by GitHub
parent 916e05bc24
commit 2c67a3aaa7
4 changed files with 15 additions and 11 deletions
+2 -1
View File
@@ -12,4 +12,5 @@ mc
.run*
.idea/
mc.RELEASE*
mc.gz
mc.gz
.DS_Store
+1 -1
View File
@@ -35,7 +35,7 @@ var (
)
// IsGetEvent checks if the event return is a get event.
func IsGetEvent(event notify.Event) bool {
func IsGetEvent(_ notify.Event) bool {
return false
}
+1 -1
View File
@@ -21,7 +21,7 @@ package cmd
import "os"
func increasePipeBufferSize(f *os.File, desiredPipeSize int) error {
func increasePipeBufferSize(_ *os.File, _ int) error {
// this is not supported on non-Linux platforms.
return nil
}
+11 -8
View File
@@ -107,6 +107,17 @@ func (stat statMessage) String() (msg string) {
}
}
}
if maxKeyEncrypted > 0 {
if keyID, ok := stat.Metadata["X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id"]; ok {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s (%s)\n", "Encryption", "KMS", keyID))
} else if _, ok := stat.Metadata["X-Amz-Server-Side-Encryption-Customer-Key-Md5"]; ok {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s\n", "Encryption", "C"))
} else {
msgBuilder.WriteString(fmt.Sprintf("%-10s: SSE-%s\n", "Encryption", "S3"))
}
}
if maxKeyMetadata > 0 {
msgBuilder.WriteString(fmt.Sprintf("%-10s:", "Metadata") + "\n")
for k, v := range stat.Metadata {
@@ -117,14 +128,6 @@ func (stat statMessage) String() (msg string) {
}
}
if maxKeyEncrypted > 0 {
msgBuilder.WriteString(fmt.Sprintf("%-10s:", "Encrypted") + "\n")
for k, v := range stat.Metadata {
if strings.HasPrefix(strings.ToLower(k), serverEncryptionKeyPrefix) {
msgBuilder.WriteString(fmt.Sprintf(" %-*.*s: %s ", maxKeyEncrypted, maxKeyEncrypted, k, v) + "\n")
}
}
}
if stat.ReplicationStatus != "" {
msgBuilder.WriteString(fmt.Sprintf("%-10s: %s ", "Replication Status", stat.ReplicationStatus))
}