Compare commits

..
Author SHA1 Message Date
Anis Elleuch 7e9625733d ilm: Add doc to the complete mc guide (#3270) 2020-07-19 12:45:36 -07:00
kannappanr 1513d76ca9 Fix typos in the examples (#3289) 2020-07-10 22:17:54 -07:00
P R 87dc0bf80e mc ilm list cell alignment for text (#3291) 2020-07-10 22:17:54 -07:00
Harshavardhana 69c0d33543 support proper proxy for all transports (#3290)
fixes #3225
2020-07-10 22:17:54 -07:00
Harshavardhana 8d891755e0 move to latest released minio to fix policy (#3288)
fixes #3265
2020-07-10 22:17:54 -07:00
ebozduman a9cd7869eb Fixes copy with partial metadata failure (#3282) 2020-07-10 22:17:54 -07:00
Harshavardhana c40ab338a3 support goreleaser for mc (#3286) 2020-07-10 22:17:54 -07:00
ebozduman 0fcd10d793 Adds support to preserve X-Amz-Meta-Mc-Attrs when os -> fs (#3285) 2020-07-10 22:17:54 -07:00
Anis Elleuch b7b75c5f46 cli: Load global flags in initBeforeRunningCmd (#3283)
app.Before receives a cli.Context but without flags parsed. There is no
point calling ctx.Bool() or ctx.IsSet() at that stage.

However, flags are parsed in commands, so minio initialization and
setting global variables (globalJSON, globalQuiet, etc..) can be moved
to the Before function of all commands.

Avoid setting command.Before for non leaf commands, otherwise Before
function will be called multiples times until it reaches the leaf
command.
2020-07-10 22:17:54 -07:00
Anis Elleuch b97b7b8987 policy: Recalculate permission mode after setting a new one (#3280)
`mc policy set` can confuse users by showing that a bucket has 'none'
policy mode although issuing `mc policy get` will show it is `custom`
when the bucket already other policy statements for some sub-resources.

For better UX, mc will issue another request to get the real policy
mode.
2020-07-10 22:17:54 -07:00
poornas 8f3d514e3b Fix mc cp regression for recursive copy (#3278)
Fixes #3267. Revert commit dc430afe07
which attempted to preserve similar behavior across mc cp and mc
mirror, but introduces a regression for cp when wildcards are
specified.
2020-07-10 22:17:54 -07:00
120 changed files with 648 additions and 302 deletions
+167
View File
@@ -0,0 +1,167 @@
project_name: mc
release:
name_template: "Version {{.Version}}"
disable: true
github:
owner: minio
name: mc
env:
- CGO_ENABLED=0
- GO111MODULE=on
before:
hooks:
- make clean
- go generate ./...
- go mod tidy
- go mod download
builds:
-
goos:
- linux
- darwin
- windows
- freebsd
goarch:
- amd64
- arm64
- arm
- ppc64le
- s390x
goarm:
- 7
ignore:
- goos: darwin
goarch: arm64
- goos: darwin
goarch: arm
- goos: darwin
goarch: ppc64le
- goos: darwin
goarch: s390x
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: ppc64le
- goos: windows
goarch: s390x
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64
- goos: freebsd
goarch: ppc64le
- goos: freebsd
goarch: s390x
flags:
- -tags=kqueue
- -trimpath
ldflags:
- "-s -w -X github.com/minio/mc/cmd.Version={{.Version}} -X github.com/minio/mc/cmd.ReleaseTag={{.Tag}} -X github.com/minio/mc/cmd.CommitID={{.FullCommit}} -X github.com/minio/mc/cmd.ShortCommitID={{.ShortCommit}}"
archives:
-
format: binary
name_template: "{{ .Binary }}-release/{{ .Os }}-{{ .Arch }}/{{ .Binary }}.{{ .Version }}"
nfpms:
-
id: minio
package_name: mc
vendor: MinIO, Inc.
homepage: https://min.io/
maintainer: dev@min.io
description: MinIO Client (mc) provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff, find etc. It supports filesystems and Amazon S3 compatible cloud storage service (AWS Signature v2 and v4).
license: Apache 2.0
bindir: /usr/bin
formats:
- deb
- rpm
overrides:
deb:
file_name_template: "{{ .Binary }}-release/debs/{{ .ProjectName }}-{{ .Version }}_{{ .Arch }}"
replacements:
arm: armv7
files:
"NOTICE": "/usr/share/mc/NOTICE"
"CREDITS": "/usr/share/mc/CREDITS"
"LICENSE": "/usr/share/mc/LICENSE"
"README.md": "/usr/share/mc/README.md"
rpm:
file_name_template: "{{ .Binary }}-release/rpms/{{ .ProjectName }}-{{ .Version }}.{{ .Arch }}"
replacements:
amd64: x86_64
arm64: aarch64
arm: armv7
files:
"NOTICE": "/usr/share/mc/NOTICE"
"CREDITS": "/usr/share/mc/CREDITS"
"LICENSE": "/usr/share/mc/LICENSE"
"README.md": "/usr/share/mc/README.md"
checksum:
algorithm: sha256
signs:
-
signature: "${artifact}.asc"
cmd: "sh"
args:
- '-c'
- 'gpg --quiet --detach-sign -a ${artifact}'
artifacts: all
changelog:
sort: asc
filters:
exclude:
- '^Update yaml files'
dockers:
-
goos: linux
goarch: amd64
dockerfile: Dockerfile.release
image_templates:
- minio/mc:{{ .Tag }}
- minio/mc:latest
-
goos: linux
goarch: ppc64le
dockerfile: Dockerfile.ppc64le.release
image_templates:
- minio/mc:{{ .Tag }}-ppc64le
-
goos: linux
goarch: s390x
dockerfile: Dockerfile.s390x.release
image_templates:
- minio/mc:{{ .Tag }}-s390x
-
goos: linux
goarch: arm64
goarm: ''
dockerfile: Dockerfile.arm64.release
image_templates:
- minio/mc:{{ .Tag }}-arm64
-
goos: linux
goarch: arm
goarm: '7'
dockerfile: Dockerfile.arm.release
image_templates:
- minio/mc:{{ .Tag }}-arm
+5 -5
View File
@@ -1,4 +1,4 @@
FROM golang:1.13-alpine
FROM golang:1.13-alpine as build
LABEL maintainer="MinIO Inc <dev@min.io>"
@@ -11,12 +11,12 @@ RUN \
git clone https://github.com/minio/mc && cd mc && \
go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)"
FROM alpine:3.10
FROM alpine:3.12
COPY --from=0 /go/bin/mc /usr/bin/mc
COPY --from=build /go/bin/mc /usr/bin/mc
RUN \
apk add --no-cache ca-certificates && \
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
apk add --no-cache ca-certificates 'curl>7.61.0' && \
curl -s -q -O https://raw.githubusercontent.com/minio/minio/master/CREDITS
ENTRYPOINT ["mc"]
+12
View File
@@ -0,0 +1,12 @@
FROM multiarch/qemu-user-static:x86_64-arm as qemu
FROM arm32v7/alpine:3.12
LABEL maintainer="MinIO Inc <dev@min.io>"
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
COPY mc /usr/bin/mc
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
ENTRYPOINT ["mc"]
+12
View File
@@ -0,0 +1,12 @@
FROM multiarch/qemu-user-static:x86_64-arm as qemu
FROM arm64v8/alpine:3.12
LABEL maintainer="MinIO Inc <dev@min.io>"
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
COPY mc /usr/bin/mc
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
ENTRYPOINT ["mc"]
+3 -5
View File
@@ -1,10 +1,8 @@
FROM alpine:3.10
FROM alpine:3.12
COPY mc /usr/bin/
COPY CREDITS /
RUN \
apk add --no-cache ca-certificates && \
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf \
chmod +x /usr/bin/mc
RUN apk add --no-cache ca-certificates
ENTRYPOINT ["mc"]
+12
View File
@@ -0,0 +1,12 @@
FROM multiarch/qemu-user-static:x86_64-arm as qemu
FROM ppc64le/alpine:3.12
LABEL maintainer="MinIO Inc <dev@min.io>"
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
COPY mc /usr/bin/mc
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
ENTRYPOINT ["mc"]
+5 -6
View File
@@ -1,11 +1,10 @@
FROM alpine:3.10
FROM alpine:3.12
MAINTAINER MinIO Inc <dev@min.io>
RUN \
apk add --no-cache ca-certificates && \
apk add --no-cache --virtual .build-deps curl && \
curl https://dl.min.io/client/mc/release/linux-amd64/mc > /usr/bin/mc && \
chmod +x /usr/bin/mc && apk del .build-deps
COPY mc /usr/bin/mc
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
ENTRYPOINT ["mc"]
+12
View File
@@ -0,0 +1,12 @@
FROM multiarch/qemu-user-static:x86_64-arm as qemu
FROM s390x/alpine:3.12
LABEL maintainer="MinIO Inc <dev@min.io>"
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin
COPY mc /usr/bin/mc
RUN apk add --no-cache ca-certificates 'curl>7.61.0' && \
curl -s -q -O https://raw.githubusercontent.com/minio/minio/release/CREDITS
ENTRYPOINT ["mc"]
+1 -1
View File
@@ -1,4 +1,4 @@
MinIO Client (C) 2014, 2015 MinIO, Inc.
MinIO Client (C) 2014-2020 MinIO, Inc.
This product includes software developed at MinIO, Inc.
(https://min.io/).
+1 -1
View File
@@ -8,7 +8,7 @@ function _init() {
export CGO_ENABLED=0
## List of architectures and OS to test coss compilation.
SUPPORTED_OSARCH="linux/ppc64le linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 linux/arm linux/386"
SUPPORTED_OSARCH="linux/ppc64le linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 linux/arm linux/386 windows/amd64"
}
function _build() {
+1 -1
View File
@@ -77,7 +77,7 @@ var adminBucketQuotaCmd = cli.Command{
Name: "quota",
Usage: "Manage bucket quota",
Action: mainAdminBucketQuota,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(adminQuotaFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -22,7 +22,6 @@ var adminBucketCmd = cli.Command{
Name: "bucket",
Usage: "manage buckets defined in the MinIO server",
Action: mainAdminBucket,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminBucketQuotaCmd,
+1 -1
View File
@@ -25,7 +25,7 @@ import (
var adminConfigExportCmd = cli.Command{
Name: "export",
Usage: "export all config keys to STDOUT",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigExport,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -27,7 +27,7 @@ import (
var adminConfigGetCmd = cli.Command{
Name: "get",
Usage: "interactively retrieve a config key parameters",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigGet,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -43,7 +43,7 @@ var historyListFlags = []cli.Flag{
var adminConfigHistoryCmd = cli.Command{
Name: "history",
Usage: "show all historic configuration changes",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigHistory,
Flags: append(append([]cli.Flag{}, globalFlags...), historyListFlags...),
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -30,7 +30,7 @@ import (
var adminConfigImportCmd = cli.Command{
Name: "import",
Usage: "import multiple config keys from STDIN",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigImport,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -37,7 +37,7 @@ var adminConfigEnvFlags = []cli.Flag{
var adminConfigResetCmd = cli.Command{
Name: "reset",
Usage: "interactively reset a config key parameters",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigReset,
Flags: append(adminConfigEnvFlags, globalFlags...),
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -29,7 +29,7 @@ import (
var adminConfigRestoreCmd = cli.Command{
Name: "restore",
Usage: "rollback back changes to a specific config history",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigRestore,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -31,7 +31,7 @@ import (
var adminConfigSetCmd = cli.Command{
Name: "set",
Usage: "interactively set a config key parameters",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminConfigSet,
Flags: append(adminConfigEnvFlags, globalFlags...),
CustomHelpTemplate: `NAME:
-1
View File
@@ -22,7 +22,6 @@ var adminConfigCmd = cli.Command{
Name: "config",
Usage: "manage MinIO server configuration",
Action: mainAdminConfig,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminConfigGetCmd,
+1 -1
View File
@@ -49,7 +49,7 @@ var adminConsoleCmd = cli.Command{
Name: "console",
Usage: "show console logs for MinIO server",
Action: mainAdminConsole,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(adminConsoleFlags, globalFlags...),
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -32,7 +32,7 @@ var adminGroupAddCmd = cli.Command{
Name: "add",
Usage: "add users to a new or existing group",
Action: mainAdminGroupAdd,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -24,7 +24,7 @@ var adminGroupDisableCmd = cli.Command{
Name: "disable",
Usage: "Disable a group",
Action: mainAdminGroupEnableDisable,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -30,7 +30,7 @@ var adminGroupEnableCmd = cli.Command{
Name: "enable",
Usage: "Enable a group",
Action: mainAdminGroupEnableDisable,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminGroupInfoCmd = cli.Command{
Name: "info",
Usage: "display group info",
Action: mainAdminGroupInfo,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminGroupListCmd = cli.Command{
Name: "list",
Usage: "display list of groups",
Action: mainAdminGroupList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -28,7 +28,7 @@ var adminGroupRemoveCmd = cli.Command{
Name: "remove",
Usage: "remove group or members from a group",
Action: mainAdminGroupRemove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -22,7 +22,6 @@ var adminGroupCmd = cli.Command{
Name: "group",
Usage: "manage groups",
Action: mainAdminGroup,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminGroupAddCmd,
+1 -1
View File
@@ -67,7 +67,7 @@ var adminHealCmd = cli.Command{
Name: "heal",
Usage: "heal disks, buckets and objects on MinIO server",
Action: mainAdminHeal,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(adminHealFlags, globalFlags...),
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -38,7 +38,7 @@ var adminInfoCmd = cli.Command{
Name: "info",
Usage: "display MinIO server information",
Action: mainAdminInfo,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -28,7 +28,7 @@ var adminKMSKeyStatusCmd = cli.Command{
Name: "status",
Usage: "request status information for a KMS master key",
Action: mainAdminKMSKeyStatus,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -22,7 +22,6 @@ var adminKMSKeyCmd = cli.Command{
Name: "key",
Usage: "Manage KMS master keys: Request key status information",
Action: mainAdminKMSKey,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminKMSKeyStatusCmd,
-1
View File
@@ -22,7 +22,6 @@ var adminKMSCmd = cli.Command{
Name: "kms",
Usage: "perform KMS management operations",
Action: mainAdminKMS,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminKMSKeyCmd,
-1
View File
@@ -34,7 +34,6 @@ var adminCmd = cli.Command{
Usage: "manage MinIO servers",
Action: mainAdmin,
HideHelpCommand: true,
Before: setGlobalsFromContext,
Flags: append(adminFlags, globalFlags...),
Subcommands: []cli.Command{
adminServiceCmd,
+1 -1
View File
@@ -56,7 +56,7 @@ var adminOBDCmd = cli.Command{
Name: "obd",
Usage: "run on-board diagnostics",
Action: mainAdminOBD,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(adminOBDFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -33,7 +33,7 @@ var adminPolicyAddCmd = cli.Command{
Name: "add",
Usage: "add new policy",
Action: mainAdminPolicyAdd,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -29,7 +29,7 @@ var adminPolicyInfoCmd = cli.Command{
Name: "info",
Usage: "show info on a policy",
Action: mainAdminPolicyInfo,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminPolicyListCmd = cli.Command{
Name: "list",
Usage: "list all policies",
Action: mainAdminPolicyList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminPolicyRemoveCmd = cli.Command{
Name: "remove",
Usage: "remove policy",
Action: mainAdminPolicyRemove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -30,7 +30,7 @@ var adminPolicySetCmd = cli.Command{
Name: "set",
Usage: "set IAM policy on a user or group",
Action: mainAdminPolicySet,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -22,7 +22,6 @@ var adminPolicyCmd = cli.Command{
Name: "policy",
Usage: "manage policies defined in the MinIO server",
Action: mainAdminPolicy,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminPolicyAddCmd,
+1 -1
View File
@@ -38,7 +38,7 @@ var adminProfileStartCmd = cli.Command{
Name: "start",
Usage: "start recording profile data",
Action: mainAdminProfileStart,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(adminProfileStartFlags, globalFlags...),
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -31,7 +31,7 @@ var adminProfileStopCmd = cli.Command{
Name: "stop",
Usage: "stop and download profile data",
Action: mainAdminProfileStop,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
-1
View File
@@ -24,7 +24,6 @@ var adminProfileCmd = cli.Command{
Name: "profile",
Usage: "generate profile data for debugging purposes",
Action: mainAdminProfile,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminProfileStartCmd,
+1 -1
View File
@@ -40,7 +40,7 @@ var adminPrometheusGenerateCmd = cli.Command{
Name: "generate",
Usage: "generates prometheus config",
Action: mainAdminPrometheusGenerate,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
-1
View File
@@ -22,7 +22,6 @@ var adminPrometheusCmd = cli.Command{
Name: "prometheus",
Usage: "manages prometheus config",
Action: mainAdminPrometheus,
Before: setGlobalsFromContext,
Flags: globalFlags,
HideHelpCommand: true,
Subcommands: []cli.Command{
+1 -1
View File
@@ -30,7 +30,7 @@ var adminServiceRestartCmd = cli.Command{
Name: "restart",
Usage: "restart all MinIO servers",
Action: mainAdminServiceRestart,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -28,7 +28,7 @@ var adminServiceStopCmd = cli.Command{
Name: "stop",
Usage: "stop MinIO server",
Action: mainAdminServiceStop,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -22,7 +22,6 @@ var adminServiceCmd = cli.Command{
Name: "service",
Usage: "restart and stop all MinIO servers",
Action: mainAdminService,
Before: setGlobalsFromContext,
Flags: globalFlags,
HideHelpCommand: true,
Subcommands: []cli.Command{
+1 -1
View File
@@ -31,7 +31,7 @@ import (
var adminTopLocksCmd = cli.Command{
Name: "locks",
Usage: "Get a list of the 10 oldest locks on a MinIO cluster.",
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Action: mainAdminTopLocks,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
-1
View File
@@ -22,7 +22,6 @@ var adminTopCmd = cli.Command{
Name: "top",
Usage: "provide top like statistics for MinIO",
Action: mainAdminTop,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminTopLocksCmd,
+1 -1
View File
@@ -53,7 +53,7 @@ var adminTraceCmd = cli.Command{
Name: "trace",
Usage: "show http trace for MinIO server",
Action: mainAdminTrace,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(adminTraceFlags, globalFlags...),
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -30,7 +30,7 @@ var adminServerUpdateCmd = cli.Command{
Name: "update",
Usage: "update all MinIO servers",
Action: mainAdminServerUpdate,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -34,7 +34,7 @@ var adminUserAddCmd = cli.Command{
Name: "add",
Usage: "add a new user",
Action: mainAdminUserAdd,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -28,7 +28,7 @@ var adminUserDisableCmd = cli.Command{
Name: "disable",
Usage: "disable user",
Action: mainAdminUserDisable,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -28,7 +28,7 @@ var adminUserEnableCmd = cli.Command{
Name: "enable",
Usage: "enable user",
Action: mainAdminUserEnable,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminUserInfoCmd = cli.Command{
Name: "info",
Usage: "display info of a user",
Action: mainAdminUserInfo,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminUserListCmd = cli.Command{
Name: "list",
Usage: "list all users",
Action: mainAdminUserList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -27,7 +27,7 @@ var adminUserRemoveCmd = cli.Command{
Name: "remove",
Usage: "remove user",
Action: mainAdminUserRemove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -22,7 +22,6 @@ var adminUserCmd = cli.Command{
Name: "user",
Usage: "manage users",
Action: mainAdminUser,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
adminUserAddCmd,
+1 -1
View File
@@ -44,7 +44,7 @@ var catCmd = cli.Command{
Name: "cat",
Usage: "display object contents",
Action: mainCat,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(catFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+2 -1
View File
@@ -26,6 +26,7 @@ import (
"sync"
"time"
"github.com/mattn/go-ieproxy"
"github.com/minio/mc/pkg/httptracer"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v6/pkg/credentials"
@@ -90,7 +91,7 @@ func NewAdminFactory() func(config *Config) (*madmin.AdminClient, *probe.Error)
}
var transport http.RoundTripper = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: ieproxy.GetProxyFunc(),
DialContext: (&net.Dialer{
Timeout: 10 * time.Second,
KeepAlive: 15 * time.Second,
+65 -32
View File
@@ -223,29 +223,51 @@ func (f *fsClient) Watch(ctx context.Context, options WatchOptions) (*WatchObjec
}
func preserveAttributes(fd *os.File, attr map[string]string) *probe.Error {
mode, e := strconv.ParseUint(attr["mode"], 10, 32)
if e != nil {
return probe.NewError(e)
if val, ok := attr["mode"]; ok {
mode, e := strconv.ParseUint(val, 0, 32)
if e != nil {
return probe.NewError(e)
}
// Attempt to change the file mode.
if e := fd.Chmod(os.FileMode(mode)); e != nil {
return probe.NewError(e)
}
}
// Attempt to change the file mode.
if e := fd.Chmod(os.FileMode(mode)); e != nil {
return probe.NewError(e)
var uid, gid int
var gidExists, uidExists bool
var e error
if val, ok := attr["uid"]; ok {
uid, e = strconv.Atoi(val)
if e != nil {
return probe.NewError(e)
}
uidExists = true
}
uid, e := strconv.Atoi(attr["uid"])
if e != nil {
return probe.NewError(e)
}
gid, e := strconv.Atoi(attr["gid"])
if e != nil {
return probe.NewError(e)
if val, ok := attr["gid"]; ok {
gid, e = strconv.Atoi(val)
if e != nil {
return probe.NewError(e)
}
gidExists = true
}
// Attempt to change the owner.
if e := fd.Chown(uid, gid); e != nil {
return probe.NewError(e)
if gidExists && uidExists {
if e := fd.Chown(uid, gid); e != nil {
return probe.NewError(e)
}
} else if uidExists {
if e := fd.Chown(uid, -1); e != nil {
return probe.NewError(e)
}
} else {
if e := fd.Chown(-1, gid); e != nil {
return probe.NewError(e)
}
}
return nil
@@ -253,7 +275,7 @@ func preserveAttributes(fd *os.File, attr map[string]string) *probe.Error {
/// Object operations.
func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metadata map[string][]string, progress io.Reader) (int64, *probe.Error) {
func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metadata map[string][]string, progress io.Reader, preserve bool) (int64, *probe.Error) {
// ContentType is not handled on purpose.
// For filesystem this is a redundant information.
@@ -289,7 +311,7 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metada
}
attr := make(map[string]string)
if len(metadata[metaDataKey]) != 0 {
if len(metadata[metaDataKey]) != 0 && preserve {
attr, e = parseAttribute(metadata[metaDataKey][0])
if e != nil {
tmpFile.Close()
@@ -347,20 +369,31 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metada
return totalWritten, err.Trace(objectPartPath, objectPath)
}
if len(attr) != 0 {
atime, e := strconv.ParseInt(attr["atime"], 10, 64)
if e != nil {
return totalWritten, probe.NewError(e)
if len(attr) != 0 && preserve {
var atime, mtime int64
var e error
var atimeChanged, mtimeChanged bool
if val, ok := attr["atime"]; ok {
atime, e = strconv.ParseInt(val, 10, 64)
if e != nil {
return totalWritten, probe.NewError(e)
}
atimeChanged = true
}
mtime, e := strconv.ParseInt(attr["mtime"], 10, 64)
if e != nil {
return totalWritten, probe.NewError(e)
if val, ok := attr["mtime"]; ok {
mtime, e = strconv.ParseInt(val, 10, 64)
if e != nil {
return totalWritten, probe.NewError(e)
}
mtimeChanged = true
}
// Attempt to change the access and modify time
if e := os.Chtimes(objectPath, time.Unix(atime, 0), time.Unix(mtime, 0)); e != nil {
return totalWritten, probe.NewError(e)
if atimeChanged && mtimeChanged {
if e := os.Chtimes(objectPath, time.Unix(atime, 0), time.Unix(mtime, 0)); e != nil {
return totalWritten, probe.NewError(e)
}
}
}
@@ -368,13 +401,13 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, metada
}
// Put - create a new file with metadata.
func (f *fsClient) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (int64, *probe.Error) {
func (f *fsClient) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, preserve bool) (int64, *probe.Error) {
if metadata[metaDataKey] != "" {
meta := make(map[string][]string)
meta[metaDataKey] = append(meta[metaDataKey], metadata[metaDataKey])
return f.put(ctx, reader, size, meta, progress)
return f.put(ctx, reader, size, meta, progress, preserve)
}
return f.put(ctx, reader, size, nil, progress)
return f.put(ctx, reader, size, nil, progress, preserve)
}
// ShareDownload - share download not implemented for filesystem.
@@ -394,7 +427,7 @@ func (f *fsClient) ShareUpload(startsWith bool, expires time.Duration, contentTy
}
// Copy - copy data from source to destination
func (f *fsClient) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart bool) *probe.Error {
func (f *fsClient) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart, preserve bool) *probe.Error {
rc, e := os.Open(source)
if e != nil {
err := f.toClientError(e, source)
@@ -403,7 +436,7 @@ func (f *fsClient) Copy(ctx context.Context, source string, size int64, progress
defer rc.Close()
destination := f.PathURL.Path
if _, err := f.put(ctx, rc, size, map[string][]string{}, progress); err != nil {
if _, err := f.put(ctx, rc, size, map[string][]string{}, progress, preserve); err != nil {
return err.Trace(destination, source)
}
return nil
+10 -10
View File
@@ -45,7 +45,7 @@ func (s *TestSuite) TestList(c *C) {
var n int64
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -56,7 +56,7 @@ func (s *TestSuite) TestList(c *C) {
reader = bytes.NewReader([]byte(data))
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -84,7 +84,7 @@ func (s *TestSuite) TestList(c *C) {
reader = bytes.NewReader([]byte(data))
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -144,7 +144,7 @@ func (s *TestSuite) TestList(c *C) {
reader = bytes.NewReader([]byte(data))
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -251,7 +251,7 @@ func (s *TestSuite) TestPut(c *C) {
var n int64
n, err = fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
}
@@ -271,7 +271,7 @@ func (s *TestSuite) TestGet(c *C) {
reader = bytes.NewReader([]byte(data))
n, err := fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -299,7 +299,7 @@ func (s *TestSuite) TestGetRange(c *C) {
reader = bytes.NewReader([]byte(data))
n, err := fsClient.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -330,7 +330,7 @@ func (s *TestSuite) TestStatObject(c *C) {
reader := bytes.NewReader([]byte(data))
n, err := fsClient.Put(context.Background(), reader, int64(dataLen), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
@@ -355,10 +355,10 @@ func (s *TestSuite) TestCopy(c *C) {
reader := bytes.NewReader([]byte(data))
n, err := fsClientSource.Put(context.Background(), reader, int64(len(data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(data)))
err = fsClientTarget.Copy(context.Background(), sourcePath, int64(len(data)), nil, nil, nil, nil, false)
err = fsClientTarget.Copy(context.Background(), sourcePath, int64(len(data)), nil, nil, nil, nil, false, false)
c.Assert(err, IsNil)
}
+4 -3
View File
@@ -37,6 +37,7 @@ import (
"sync"
"time"
"github.com/mattn/go-ieproxy"
"github.com/minio/mc/cmd/ilm"
"github.com/minio/mc/pkg/httptracer"
"github.com/minio/mc/pkg/probe"
@@ -149,7 +150,7 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
}
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: ieproxy.GetProxyFunc(),
DialContext: (&net.Dialer{
Timeout: 10 * time.Second,
KeepAlive: 15 * time.Second,
@@ -839,7 +840,7 @@ func (c *S3Client) Get(ctx context.Context, sse encrypt.ServerSide) (io.ReadClos
// Copy - copy object, uses server side copy API. Also uses an abstracted API
// such that large file sizes will be copied in multipart manner on server
// side.
func (c *S3Client) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart bool) *probe.Error {
func (c *S3Client) Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart, isPreserve bool) *probe.Error {
dstBucket, dstObject := c.url2BucketAndObject()
if dstBucket == "" {
return probe.NewError(BucketNameEmpty{})
@@ -912,7 +913,7 @@ func (c *S3Client) Copy(ctx context.Context, source string, size int64, progress
}
// Put - upload an object with custom metadata.
func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (int64, *probe.Error) {
func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, isPreserve bool) (int64, *probe.Error) {
bucket, object := c.url2BucketAndObject()
if bucket == "" {
return 0, probe.NewError(BucketNameEmpty{})
+1 -1
View File
@@ -223,7 +223,7 @@ func (s *TestSuite) TestObjectOperations(c *C) {
reader = bytes.NewReader(object.data)
n, err := s3c.Put(context.Background(), reader, int64(len(object.data)), map[string]string{
"Content-Type": "application/octet-stream",
}, nil, nil, false, false)
}, nil, nil, false, false, false)
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(len(object.data)))
+2 -2
View File
@@ -62,14 +62,14 @@ type Client interface {
SetAccess(ctx context.Context, access string, isJSON bool) *probe.Error
// I/O operations
Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart bool) *probe.Error
Copy(ctx context.Context, source string, size int64, progress io.Reader, srcSSE, tgtSSE encrypt.ServerSide, metadata map[string]string, disableMultipart, isPreserve bool) *probe.Error
// Runs select expression on object storage on specific files.
Select(ctx context.Context, expression string, sse encrypt.ServerSide, opts SelectObjectOpts) (io.ReadCloser, *probe.Error)
// I/O operations with metadata.
Get(ctx context.Context, sse encrypt.ServerSide) (reader io.ReadCloser, err *probe.Error)
Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (n int64, err *probe.Error)
Put(ctx context.Context, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, isPreserve bool) (n int64, err *probe.Error)
// Object Locking related API
PutObjectRetention(ctx context.Context, mode minio.RetentionMode, retainUntilDate time.Time, bypassGovernance bool) *probe.Error
+9 -9
View File
@@ -297,7 +297,7 @@ func putTargetRetention(ctx context.Context, alias string, urlStr string, metada
}
// putTargetStream writes to URL from Reader.
func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold string, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart bool) (int64, *probe.Error) {
func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold string, reader io.Reader, size int64, metadata map[string]string, progress io.Reader, sse encrypt.ServerSide, md5, disableMultipart, preserve bool) (int64, *probe.Error) {
targetClnt, err := newClientFromAlias(alias, urlStr)
if err != nil {
return 0, err.Trace(alias, urlStr)
@@ -312,7 +312,7 @@ func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold
if legalHold != "" {
metadata[AmzObjectLockLegalHold] = legalHold
}
n, err := targetClnt.Put(ctx, reader, size, metadata, progress, sse, md5, disableMultipart)
n, err := targetClnt.Put(ctx, reader, size, metadata, progress, sse, md5, disableMultipart, preserve)
if err != nil {
return n, err.Trace(alias, urlStr)
}
@@ -320,7 +320,7 @@ func putTargetStream(ctx context.Context, alias, urlStr, mode, until, legalHold
}
// putTargetStreamWithURL writes to URL from reader. If length=-1, read until EOF.
func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, sse encrypt.ServerSide, md5, disableMultipart bool, metadata map[string]string) (int64, *probe.Error) {
func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, sse encrypt.ServerSide, md5, disableMultipart, preserve bool, metadata map[string]string) (int64, *probe.Error) {
alias, urlStrFull, _, err := expandAlias(urlStr)
if err != nil {
return 0, err.Trace(alias, urlStr)
@@ -330,7 +330,7 @@ func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, sse enc
metadata = map[string]string{}
}
metadata["Content-Type"] = contentType
return putTargetStream(context.Background(), alias, urlStrFull, "", "", "", reader, size, metadata, nil, sse, md5, disableMultipart)
return putTargetStream(context.Background(), alias, urlStrFull, "", "", "", reader, size, metadata, nil, sse, md5, disableMultipart, preserve)
}
// copySourceToTargetURL copies to targetURL from source.
@@ -344,7 +344,7 @@ func copySourceToTargetURL(ctx context.Context, alias, urlStr, source, mode, unt
metadata[AmzObjectLockMode] = mode
metadata[AmzObjectLockRetainUntilDate] = until
metadata[AmzObjectLockLegalHold] = legalHold
err = targetClnt.Copy(ctx, source, size, progress, srcSSE, tgtSSE, metadata, disableMultipart)
err = targetClnt.Copy(ctx, source, size, progress, srcSSE, tgtSSE, metadata, disableMultipart, false)
if err != nil {
return err.Trace(alias, urlStr)
@@ -455,7 +455,7 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
if sourceAlias == targetAlias {
// If no metadata populated already by the caller
// just do a Stat() to obtain the metadata.
if len(metadata) == 0 {
if len(metadata) == 0 && preserve {
metadata, err = getAllMetadata(ctx, sourceAlias, sourceURL.String(), srcSSE, urls, preserve)
if err != nil {
return urls.WithError(err.Trace(sourceURL.String()))
@@ -484,7 +484,7 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
if urls.SourceContent.RetentionEnabled {
// If no metadata populated already by the caller
// just do a Stat() to obtain the metadata.
if len(metadata) == 0 {
if len(metadata) == 0 && preserve {
metadata, err = getAllMetadata(ctx, sourceAlias, sourceURL.String(), srcSSE, urls, preserve)
if err != nil {
return urls.WithError(err.Trace(sourceURL.String()))
@@ -526,12 +526,12 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
if isReadAt(reader) {
_, err = putTargetStream(ctx, targetAlias, targetURL.String(), mode, until,
legalHold, reader, length, filterMetadata(metadata),
progress, tgtSSE, urls.MD5, urls.DisableMultipart)
progress, tgtSSE, urls.MD5, urls.DisableMultipart, preserve)
} else {
_, err = putTargetStream(ctx, targetAlias, targetURL.String(), mode, until,
legalHold, io.LimitReader(reader, length),
length, filterMetadata(metadata), progress, tgtSSE, urls.MD5,
urls.DisableMultipart)
urls.DisableMultipart, preserve)
}
}
if err != nil {
+1 -1
View File
@@ -50,7 +50,7 @@ var configHostAddCmd = cli.Command{
ShortName: "a",
Usage: "add a new host to configuration file",
Action: mainConfigHostAdd,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(hostAddFlags, globalFlags...),
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -30,7 +30,7 @@ var configHostListCmd = cli.Command{
ShortName: "ls",
Usage: "list hosts in configuration file",
Action: mainConfigHostList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
+1 -1
View File
@@ -27,7 +27,7 @@ var configHostRemoveCmd = cli.Command{
ShortName: "rm",
Usage: "remove a host from configuration file",
Action: mainConfigHostRemove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
-1
View File
@@ -27,7 +27,6 @@ var configHostCmd = cli.Command{
Name: "host",
Usage: "add, remove and list hosts in configuration file",
Action: mainConfigHost,
Before: setGlobalsFromContext,
Flags: globalFlags,
Subcommands: []cli.Command{
configHostAddCmd,
-1
View File
@@ -37,7 +37,6 @@ var configCmd = cli.Command{
Name: "config",
Usage: "configure MinIO client",
Action: mainConfig,
Before: setGlobalsFromContext,
HideHelpCommand: true,
Flags: append(configFlags, globalFlags...),
Subcommands: []cli.Command{
+1 -1
View File
@@ -104,7 +104,7 @@ var cpCmd = cli.Command{
Name: "cp",
Usage: "copy objects",
Action: mainCopy,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(cpFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-13
View File
@@ -18,7 +18,6 @@ package cmd
import (
"context"
"os"
"path/filepath"
"strings"
@@ -193,18 +192,6 @@ func makeCopyContentTypeC(sourceAlias string, sourceURL ClientURL, sourceContent
newSourceSuffix := filepath.ToSlash(newSourceURL.Path)
if pathSeparatorIndex > 1 {
sourcePrefix := filepath.ToSlash(sourceURL.Path[:pathSeparatorIndex])
// do not preserve unix cp behavior when copying a filesytem dir to
// objectstore.
if sourceAlias == "" && targetAlias != "" {
// Check if sourceURL.Path is a directory or not
fileInfo, err := os.Stat(sourceURL.Path)
if err != nil {
return URLs{Error: probe.NewError(err)}
}
if fileInfo.IsDir() {
sourcePrefix = filepath.ToSlash(sourceURL.Path)
}
}
newSourceSuffix = strings.TrimPrefix(newSourceSuffix, sourcePrefix)
}
newTargetURL := urlJoinPath(targetURL, newSourceSuffix)
+1 -1
View File
@@ -38,7 +38,7 @@ var diffCmd = cli.Command{
Name: "diff",
Usage: "list differences in object name, size, and date between two buckets",
Action: mainDiff,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(diffFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -48,7 +48,7 @@ var duCmd = cli.Command{
Name: "du",
Usage: "summarize disk usage recursively",
Action: mainDu,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(duFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -53,7 +53,7 @@ var eventAddCmd = cli.Command{
Name: "add",
Usage: "add a new bucket notification",
Action: mainEventAdd,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(eventAddFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -35,7 +35,7 @@ var eventListCmd = cli.Command{
Name: "list",
Usage: "list bucket notifications",
Action: mainEventList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(eventListFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -27,7 +27,6 @@ var eventCmd = cli.Command{
Usage: "configure object notifications",
HideHelpCommand: true,
Action: mainEvent,
Before: setGlobalsFromContext,
Flags: append(eventFlags, globalFlags...),
Subcommands: []cli.Command{
eventAddCmd,
+1 -1
View File
@@ -54,7 +54,7 @@ var eventRemoveCmd = cli.Command{
Name: "remove",
Usage: "remove a bucket notification; '--force' removes all bucket notifications",
Action: mainEventRemove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(eventRemoveFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -85,7 +85,7 @@ var findCmd = cli.Command{
Name: "find",
Usage: "search for objects",
Action: mainFind,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(findFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -46,7 +46,7 @@ var headCmd = cli.Command{
Name: "head",
Usage: "display first 'n' lines of an object",
Action: mainHead,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(headFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+2 -2
View File
@@ -30,7 +30,7 @@ var ilmAddCmd = cli.Command{
Name: "add",
Usage: "add a lifecycle configuration rule to existing (if any) rule(s) on a bucket",
Action: mainILMAdd,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(ilmAddFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
@@ -53,7 +53,7 @@ EXAMPLES:
2. Add rule for testbucket on s3. Both expiry and transition are number of days.
{{.Prompt}} {{.HelpName}} --id "Docs" --prefix "doc/" \
--expiry-days "200" --transition-days "300 days" \
--expiry-days "300" --transition-days "200" \
--storage-class "GLACIER" s3/testbucket
3. Add rule for testbucket on s3. Only expiry is given as number of days and transition is not set.
+1 -1
View File
@@ -30,7 +30,7 @@ var ilmExportCmd = cli.Command{
Name: "export",
Usage: "export lifecycle configuration in JSON format",
Action: mainILMExport,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -31,7 +31,7 @@ var ilmImportCmd = cli.Command{
Name: "import",
Usage: "import lifecycle configuration in JSON format",
Action: mainILMImport,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -49,7 +49,7 @@ var ilmListCmd = cli.Command{
Name: "list",
Usage: "pretty print bucket lifecycle configuration",
Action: mainILMList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(ilmListFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
-1
View File
@@ -26,7 +26,6 @@ var ilmCmd = cli.Command{
Name: "ilm",
Usage: "configure bucket lifecycle",
Action: mainILM,
Before: setGlobalsFromContext,
Flags: globalFlags,
HideHelpCommand: true,
Subcommands: []cli.Command{
+1 -1
View File
@@ -45,7 +45,7 @@ var ilmRemoveCmd = cli.Command{
Name: "remove",
Usage: "remove (if any) existing lifecycle configuration rule with the id",
Action: mainILMRemove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(ilmRemoveFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+5 -2
View File
@@ -22,9 +22,9 @@ import (
const (
// rule ID field column width in table output
idColumnWidth int = 12
idColumnWidth int = 16
// rule prefix field column width in table output
prefixColumnWidth int = 10
prefixColumnWidth int = 16
// StatusColumnWidth column width in table output
statusColumnWidth int = 12
// ExpiryColumnWidth column width in table output
@@ -302,7 +302,10 @@ func checkAddTableCell(rowArr *[]string, rowCheck map[string]int, cellInfo table
if colIdx, ok := rowCheck[cellInfo.labelKey]; ok {
if len(cellInfo.label)%2 != 0 && len(cellInfo.label) < cellInfo.columnWidth {
cellInfo.label += " "
} else if len(cellInfo.label) > (cellInfo.columnWidth - 2) { // 2 dots to indicate text longer than column width
cellInfo.label = cellInfo.label[:(cellInfo.columnWidth-6)] + ".."
}
(*rowArr)[colIdx] = getAlignedText(cellInfo.label, cellInfo.align, cellInfo.columnWidth)
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ var legalHoldCmd = cli.Command{
Name: "legalhold",
Usage: "set legal hold for object(s)",
Action: mainLegalHold,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(lhFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -43,7 +43,7 @@ var lockCmd = cli.Command{
Name: "lock",
Usage: "set and get object lock configuration",
Action: mainLock,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(lockFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -44,7 +44,7 @@ var lsCmd = cli.Command{
Name: "ls",
Usage: "list buckets and objects",
Action: mainList,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(lsFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+20 -20
View File
@@ -255,25 +255,6 @@ func installAutoCompletion() {
}
}
func registerBefore(ctx *cli.Context) error {
// Set the config directory.
setMcConfigDir(ctx.GlobalString("config-dir"))
// Migrate any old version of config / state files to newer format.
migrate()
// Set global flags.
setGlobalsFromContext(ctx)
// Initialize default config files.
initMC()
// Check if config can be read.
checkConfig()
return nil
}
// findClosestCommands to match a given string with commands trie tree.
func findClosestCommands(command string) []string {
var closestCommands []string
@@ -313,6 +294,26 @@ func checkUpdate(ctx *cli.Context) {
}
}
// All the routines that need to be done before running any mc command
func initBeforeRunningCmd(ctx *cli.Context) error {
// Set global variables from the context
setGlobalsFromContext(ctx)
// Set the config directory.
setMcConfigDir(ctx.GlobalString("config-dir"))
// Migrate any old version of config / state files to newer format.
migrate()
// Initialize default config files.
initMC()
// Check if config can be read.
checkConfig()
return nil
}
var appCmds = []cli.Command{
lsCmd,
mbCmd,
@@ -372,7 +373,6 @@ func registerApp(name string) *cli.App {
return exitStatus(globalErrorExitStatus)
}
app.Before = registerBefore
app.ExtraInfo = func() map[string]string {
if globalDebug {
return getSystemData()
+50
View File
@@ -0,0 +1,50 @@
/*
* MinIO Client (C) 2020 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cmd
import (
"testing"
"github.com/minio/cli"
)
// This function checks that only leaf commands have Before
// function configured to avoid calling it multiple times.
func TestBeforeCommand(t *testing.T) {
var checkCmd func(string, cli.Command)
checkCmd = func(cmdPath string, c cli.Command) {
if len(c.Subcommands) != 0 {
if c.Before != nil {
t.Fatalf("Command %s does not expect to have a Before func since it is not the leaf command", cmdPath)
}
} else {
if c.Before == nil {
t.Fatalf("Command %s expects to have a Before func since it is a leaf command", cmdPath)
}
}
// Test subcommands
for _, subCmd := range c.Subcommands {
checkCmd(cmdPath+"/"+subCmd.Name, subCmd)
}
}
for _, cmd := range appCmds {
checkCmd("", cmd)
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ var mbCmd = cli.Command{
Name: "mb",
Usage: "make a bucket",
Action: mainMakeBucket,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(mbFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -117,7 +117,7 @@ var mirrorCmd = cli.Command{
Name: "mirror",
Usage: "synchronize object(s) to a remote site",
Action: mainMirror,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(mirrorFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+1 -1
View File
@@ -77,7 +77,7 @@ var mvCmd = cli.Command{
Name: "mv",
Usage: "move objects",
Action: mainMove,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(mvFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
+2 -2
View File
@@ -42,7 +42,7 @@ var pipeCmd = cli.Command{
Name: "pipe",
Usage: "stream STDIN to an object",
Action: mainPipe,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(append(pipeFlags, ioFlags...), globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
@@ -90,7 +90,7 @@ func pipe(targetURL string, encKeyDB map[string][]prefixSSEPair, storageClass st
if storageClass != "" {
metadata = map[string]string{"X-Amz-Storage-Class": storageClass}
}
_, err := putTargetStreamWithURL(targetURL, os.Stdin, -1, sseKey, false, false, metadata)
_, err := putTargetStreamWithURL(targetURL, os.Stdin, -1, sseKey, false, false, false, metadata)
// TODO: See if this check is necessary.
switch e := err.ToGoError().(type) {
case *os.PathError:
+5 -2
View File
@@ -46,7 +46,7 @@ var policyCmd = cli.Command{
Name: "policy",
Usage: "manage anonymous access to buckets and objects",
Action: mainPolicy,
Before: setGlobalsFromContext,
Before: initBeforeRunningCmd,
Flags: append(policyFlags, globalFlags...),
CustomHelpTemplate: `Name:
{{.HelpName}} - {{.Usage}}
@@ -437,8 +437,11 @@ func runPolicyCmd(args cli.Args) {
perms := accessPerms(args.Get(1))
targetURL := args.Get(2)
if perms.isValidAccessPERM() {
probeErr = doSetAccess(ctx, targetURL, perms)
operation = "set"
probeErr = doSetAccess(ctx, targetURL, perms)
if probeErr == nil {
perms, _, probeErr = doGetAccess(ctx, targetURL)
}
} else if perms.isValidAccessFile() {
probeErr = doSetAccessJSON(ctx, targetURL, perms)
operation = "set-json"

Some files were not shown because too many files have changed in this diff Show More