├── .github ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── lock.yml ├── stale.yml └── workflows │ ├── go-cross.yml │ ├── go.yml │ ├── issues.yaml │ └── vulncheck.yml ├── .gitignore ├── .golangci.yml ├── .goreleaser.yml ├── .mailmap ├── CONFLICT.md ├── CONTRIBUTING.md ├── CREDITS ├── Dockerfile ├── Dockerfile.dev ├── Dockerfile.hotfix ├── Dockerfile.release ├── Dockerfile.release.old_cpu ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── README_zh_CN.md ├── _config.yml ├── buildscripts ├── build.env ├── build.sh ├── checkdeps.sh ├── cross-compile.sh └── gen-ldflags.go ├── cmd ├── access-perms.go ├── accounting-reader.go ├── admin-accesskey-create.go ├── admin-accesskey-disable.go ├── admin-accesskey-edit.go ├── admin-accesskey-enable.go ├── admin-accesskey-info.go ├── admin-accesskey-list.go ├── admin-accesskey-remove.go ├── admin-accesskey-sts-revoke.go ├── admin-accesskey.go ├── admin-bucket-info.go ├── admin-bucket-quota.go ├── admin-bucket-remote-add.go ├── admin-bucket-remote-add_test.go ├── admin-bucket-remote-edit.go ├── admin-bucket-remote-main.go ├── admin-bucket-remote-remove.go ├── admin-bucket.go ├── admin-cluster-bucket-export.go ├── admin-cluster-bucket-import.go ├── admin-cluster-bucket.go ├── admin-cluster-iam-export.go ├── admin-cluster-iam-import.go ├── admin-cluster-iam.go ├── admin-cluster.go ├── admin-config-export.go ├── admin-config-get.go ├── admin-config-help.go ├── admin-config-history.go ├── admin-config-import.go ├── admin-config-reset.go ├── admin-config-restore.go ├── admin-config-set.go ├── admin-config.go ├── admin-console.go ├── admin-decom-cancel.go ├── admin-decom-start.go ├── admin-decom-status.go ├── admin-decom.go ├── admin-group-add.go ├── admin-group-disable.go ├── admin-group-enable.go ├── admin-group-info.go ├── admin-group-list.go ├── admin-group-remove.go ├── admin-group.go ├── admin-heal-result-item.go ├── admin-heal-ui.go ├── admin-heal.go ├── admin-idp.go ├── admin-info.go ├── admin-inspect.go ├── admin-kms-key-create.go ├── admin-kms-key-list.go ├── admin-kms-key-status.go ├── admin-kms-key.go ├── admin-kms.go ├── admin-logs.go ├── admin-main.go ├── admin-policy-add.go ├── admin-policy-attach.go ├── admin-policy-create.go ├── admin-policy-detach.go ├── admin-policy-entities.go ├── admin-policy-info.go ├── admin-policy-list.go ├── admin-policy-remove.go ├── admin-policy-set.go ├── admin-policy-unset.go ├── admin-policy-update.go ├── admin-policy.go ├── admin-profile-start.go ├── admin-profile-stop.go ├── admin-profile.go ├── admin-prometheus-generate.go ├── admin-prometheus-metrics-v3.go ├── admin-prometheus-metrics.go ├── admin-prometheus.go ├── admin-rebalance-main.go ├── admin-rebalance-start.go ├── admin-rebalance-status.go ├── admin-rebalance-stop.go ├── admin-replicate-add.go ├── admin-replicate-info.go ├── admin-replicate-remove.go ├── admin-replicate-resync-cancel.go ├── admin-replicate-resync-start.go ├── admin-replicate-resync-status.go ├── admin-replicate-resync.go ├── admin-replicate-status.go ├── admin-replicate-update.go ├── admin-replicate.go ├── admin-scanner-status.go ├── admin-scanner-trace.go ├── admin-scanner.go ├── admin-service-freeze.go ├── admin-service-restart.go ├── admin-service-stop.go ├── admin-service-unfreeze.go ├── admin-service.go ├── admin-subnet-health.go ├── admin-subnet-register.go ├── admin-subnet.go ├── admin-tier-deprecated.go ├── admin-tier-main.go ├── admin-top-api.go ├── admin-top-locks.go ├── admin-top.go ├── admin-trace.go ├── admin-update.go ├── admin-user-add.go ├── admin-user-disable.go ├── admin-user-enable.go ├── admin-user-info.go ├── admin-user-list.go ├── admin-user-policy.go ├── admin-user-remove.go ├── admin-user-sts-info.go ├── admin-user-svcacct-add.go ├── admin-user-svcacct-disable.go ├── admin-user-svcacct-enable.go ├── admin-user-svcacct-info.go ├── admin-user-svcacct-list.go ├── admin-user-svcacct-remove.go ├── admin-user-svcacct-set.go ├── admin-user-svcacct.go ├── admin-user.go ├── alias-export.go ├── alias-import.go ├── alias-list.go ├── alias-main.go ├── alias-remove.go ├── alias-set.go ├── anonymous-main.go ├── arg-kvs.go ├── auto-complete.go ├── auto-complete_test.go ├── batch-cancel.go ├── batch-describe.go ├── batch-generate.go ├── batch-list.go ├── batch-main.go ├── batch-start.go ├── batch-status.go ├── build-constants.go ├── cat-main.go ├── cat_test.go ├── certs.go ├── cli_test.go ├── client-admin.go ├── client-admin_test.go ├── client-errors.go ├── client-fs.go ├── client-fs_darwin.go ├── client-fs_freebsd.go ├── client-fs_linux.go ├── client-fs_netbsd.go ├── client-fs_other.go ├── client-fs_test.go ├── client-fs_windows.go ├── client-s3-trace_v2.go ├── client-s3-trace_v4.go ├── client-s3.go ├── client-s3_test.go ├── client-sts_test.go ├── client-url.go ├── client-url_test.go ├── client.go ├── common-methods.go ├── config-fix.go ├── config-migrate.go ├── config-old.go ├── config-utils.go ├── config-utils_test.go ├── config-v10.go ├── config-validate.go ├── config.go ├── config_test.go ├── cors-get.go ├── cors-main.go ├── cors-remove.go ├── cors-set.go ├── cp-main.go ├── cp-main_contrib.go ├── cp-main_test.go ├── cp-url-syntax.go ├── cp-url.go ├── diff-main.go ├── difference.go ├── difference_test.go ├── du-main.go ├── duration.go ├── encrypt-clear.go ├── encrypt-info.go ├── encrypt-main.go ├── encrypt-set.go ├── encryption-methods.go ├── encryption-methods_test.go ├── error.go ├── event-add.go ├── event-list.go ├── event-main.go ├── event-remove.go ├── find-main.go ├── find.go ├── find_test.go ├── flags.go ├── fs-pathutils_nix.go ├── fs-pathutils_windows.go ├── get-main.go ├── get-url.go ├── globals.go ├── head-main.go ├── health.go ├── health_v1.go ├── humanized-duration.go ├── idp-ldap-accesskey-create-with-login.go ├── idp-ldap-accesskey-create.go ├── idp-ldap-accesskey-disable.go ├── idp-ldap-accesskey-edit.go ├── idp-ldap-accesskey-enable.go ├── idp-ldap-accesskey-info.go ├── idp-ldap-accesskey-list.go ├── idp-ldap-accesskey-remove.go ├── idp-ldap-accesskey-sts-revoke.go ├── idp-ldap-accesskey.go ├── idp-ldap-policy-subcommands.go ├── idp-ldap-policy.go ├── idp-ldap-subcommands.go ├── idp-ldap.go ├── idp-openid-accesskey-disable.go ├── idp-openid-accesskey-edit.go ├── idp-openid-accesskey-enable.go ├── idp-openid-accesskey-info.go ├── idp-openid-accesskey-list.go ├── idp-openid-accesskey-remove.go ├── idp-openid-accesskey.go ├── idp-openid-subcommands.go ├── idp-openid.go ├── idp.go ├── ilm-deprecated-cmds.go ├── ilm-main.go ├── ilm-remove.go ├── ilm-restore.go ├── ilm-rule-add.go ├── ilm-rule-edit.go ├── ilm-rule-export.go ├── ilm-rule-import.go ├── ilm-rule-list.go ├── ilm-rule-main.go ├── ilm-tier-add.go ├── ilm-tier-check.go ├── ilm-tier-edit.go ├── ilm-tier-info.go ├── ilm-tier-list.go ├── ilm-tier-main.go ├── ilm-tier-remove.go ├── ilm-tier-update.go ├── ilm-tier-verify.go ├── ilm │ ├── options.go │ ├── options_test.go │ ├── parse.go │ ├── table.go │ ├── utils.go │ └── utils_test.go ├── legalhold-clear.go ├── legalhold-info.go ├── legalhold-main.go ├── legalhold-set.go ├── license-info.go ├── license-register.go ├── license-unregister.go ├── license-update.go ├── license.go ├── ls-main.go ├── ls.go ├── ls_test.go ├── main.go ├── mb-main.go ├── mc_test.go ├── mirror-main.go ├── mirror-url.go ├── mv-main.go ├── od-main.go ├── od-stream.go ├── parallel-manager.go ├── parse_time_test.go ├── ping.go ├── pipe-main.go ├── pipe_supported.go ├── pipe_unsupported.go ├── pipechan.go ├── pipechan_test.go ├── policy-main.go ├── pretty-record.go ├── pretty-table.go ├── pretty-table_test.go ├── print.go ├── profiling.go ├── progress-bar.go ├── put-main.go ├── put-url.go ├── quota-clear.go ├── quota-info.go ├── quota-main.go ├── quota-set.go ├── rb-main.go ├── ready-main.go ├── replicate-add.go ├── replicate-backlog.go ├── replicate-export.go ├── replicate-import.go ├── replicate-list.go ├── replicate-main.go ├── replicate-remove.go ├── replicate-reset-main.go ├── replicate-reset-start.go ├── replicate-reset-status.go ├── replicate-status.go ├── replicate-update.go ├── retention-clear.go ├── retention-common.go ├── retention-info.go ├── retention-main.go ├── retention-set.go ├── retry.go ├── rm-main.go ├── share-db-v1.go ├── share-download-main.go ├── share-list-main.go ├── share-main.go ├── share-upload-main.go ├── share-upload_test.go ├── share.go ├── signals.go ├── speedtest-spinner.go ├── sql-main.go ├── sql-main_test.go ├── stat-main.go ├── stat.go ├── stat_test.go ├── status.go ├── subnet-file-uploader.go ├── subnet-utils.go ├── subnet-utils_test.go ├── suite_test.go ├── support-callhome.go ├── support-diag-spinner-v3.go ├── support-diag.go ├── support-inspect.go ├── support-perf-client.go ├── support-perf-drive.go ├── support-perf-net.go ├── support-perf-object.go ├── support-perf-site-replication.go ├── support-perf.go ├── support-profile.go ├── support-proxy-remove.go ├── support-proxy-set.go ├── support-proxy-show.go ├── support-proxy.go ├── support-register.go ├── support-top-api.go ├── support-top-drive.go ├── support-top-locks.go ├── support-top-net.go ├── support-top-rpc.go ├── support-top.go ├── support-upload.go ├── support.go ├── table-ui.go ├── tag-list.go ├── tag-main.go ├── tag-remove.go ├── tag-set.go ├── term-pager.go ├── tofu.go ├── top-drives-spinner.go ├── top-net-spinner.go ├── trace-stats-ui.go ├── tree-main.go ├── typed-errors.go ├── undo-main.go ├── update-main.go ├── update-notifier.go ├── update_fips.go ├── update_nofips.go ├── urls.go ├── utils.go ├── utils_test.go ├── version-enable.go ├── version-info.go ├── version-main.go ├── version-suspend.go ├── watch-main.go └── watch.go ├── code_of_conduct.md ├── contributors.sh ├── docker-buildx.sh ├── functional-tests.sh ├── go.mod ├── go.sum ├── main.go ├── pkg ├── deadlineconn │ ├── deadlineconn.go │ └── deadlineconn_test.go ├── disk │ ├── stat_darwin.go │ ├── stat_freebsd.go │ ├── stat_linux.go │ ├── stat_netbsd.go │ ├── stat_other.go │ └── stat_windows.go ├── hookreader │ ├── hookreader.go │ └── hookreader_test.go ├── httptracer │ ├── httptracer.go │ └── httptracer_test.go ├── limiter │ └── limiter.go └── probe │ ├── probe.go │ ├── probe_test.go │ └── wrapper.go ├── staticcheck.conf └── testdata ├── localhost.crt └── localhost.key /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Expected behavior 2 | 3 | ## Actual behavior 4 | 5 | ## Steps to reproduce the behavior 6 | 7 | ## mc --version 8 | - (paste output of `mc --version`) 9 | 10 | ## System information 11 | 12 | 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Bug report template 4 | title: '' 5 | labels: community, triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Expected behavior 11 | 12 | ## Actual behavior 13 | 14 | ## Steps to reproduce the behavior 15 | 16 | ## mc --version 17 | - (paste output of `mc --version`) 18 | 19 | ## System information 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: MinIO Community Support 4 | url: https://slack.min.io 5 | about: Please ask and answer questions here. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Community Contribution License 2 | All community contributions in this pull request are licensed to the project maintainers 3 | under the terms of the [Apache 2 license](https://www.apache.org/licenses/LICENSE-2.0). 4 | By creating this pull request I represent that I have the right to license the 5 | contributions to the project maintainers under the Apache 2 license. 6 | 7 | ## Description 8 | 9 | 10 | ## Motivation and Context 11 | 12 | 13 | ## How to test this PR? 14 | 15 | 16 | ## Types of changes 17 | - [ ] Bug fix (non-breaking change which fixes an issue) 18 | - [ ] New feature (non-breaking change which adds functionality) 19 | - [ ] Optimization (provides speedup with no functional changes) 20 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 21 | 22 | ## Checklist: 23 | - [ ] Fixes a regression (If yes, please add `commit-id` or `PR #` here) 24 | - [ ] Unit tests added/updated 25 | - [ ] Internal documentation updated 26 | - [ ] Create a documentation update request [here](https://github.com/minio/docs/issues/new?label=doc-change,title=Doc+Updated+Needed+For+PR+github.com%2fminio%2fmc%2fpull%2fNNNNN) 27 | -------------------------------------------------------------------------------- /.github/lock.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Lock Threads - https://github.com/dessant/lock-threads-app 2 | 3 | # Number of days of inactivity before a closed issue or pull request is locked 4 | daysUntilLock: 365 5 | 6 | # Skip issues and pull requests created before a given timestamp. Timestamp must 7 | # follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable 8 | skipCreatedBefore: false 9 | 10 | # Issues and pull requests with these labels will be ignored. Set to `[]` to disable 11 | exemptLabels: [] 12 | 13 | # Label to add before locking, such as `outdated`. Set to `false` to disable 14 | lockLabel: false 15 | 16 | # Comment to post before locking. Set to `false` to disable 17 | lockComment: >- 18 | 19 | This thread has been automatically locked since there has not been 20 | any recent activity after it was closed. Please open a new issue for 21 | related bugs. 22 | 23 | # Assign `resolved` as the reason for locking. Set to `false` to disable 24 | setLockReason: true 25 | 26 | # Limit to only `issues` or `pulls` 27 | only: issues 28 | 29 | # Optionally, specify configuration settings just for `issues` or `pulls` 30 | # issues: 31 | # exemptLabels: 32 | # - help-wanted 33 | # lockLabel: outdated 34 | 35 | # pulls: 36 | # daysUntilLock: 30 37 | 38 | # Repository to extend settings from 39 | # _extends: repo 40 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | # Number of days of inactivity before an Issue or Pull Request becomes stale 4 | daysUntilStale: 90 5 | 6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. 7 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. 8 | daysUntilClose: 30 9 | 10 | # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) 11 | onlyLabels: [] 12 | 13 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable 14 | exemptLabels: 15 | - "security" 16 | - "pending discussion" 17 | 18 | # Set to true to ignore issues in a project (defaults to false) 19 | exemptProjects: false 20 | 21 | # Set to true to ignore issues in a milestone (defaults to false) 22 | exemptMilestones: false 23 | 24 | # Set to true to ignore issues with an assignee (defaults to false) 25 | exemptAssignees: false 26 | 27 | # Label to use when marking as stale 28 | staleLabel: stale 29 | 30 | # Comment to post when marking as stale. Set to `false` to disable 31 | markComment: >- 32 | This issue has been automatically marked as stale because it has not had 33 | recent activity. It will be closed after 21 days if no further activity 34 | occurs. Thank you for your contributions. 35 | # Comment to post when removing the stale label. 36 | # unmarkComment: > 37 | # Your comment here. 38 | 39 | # Comment to post when closing a stale Issue or Pull Request. 40 | # closeComment: > 41 | # Your comment here. 42 | 43 | # Limit the number of actions per hour, from 1-30. Default is 30 44 | limitPerRun: 1 45 | 46 | # Limit to only `issues` or `pulls` 47 | # only: issues 48 | 49 | # Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': 50 | # pulls: 51 | # daysUntilStale: 30 52 | # markComment: > 53 | # This pull request has been automatically marked as stale because it has not had 54 | # recent activity. It will be closed if no further activity occurs. Thank you 55 | # for your contributions. 56 | 57 | # issues: 58 | # exemptLabels: 59 | # - confirmed 60 | -------------------------------------------------------------------------------- /.github/workflows/go-cross.yml: -------------------------------------------------------------------------------- 1 | name: Crosscompile 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | # This ensures that previous jobs for the PR are canceled when the PR is 9 | # updated. 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.head_ref }} 12 | cancel-in-progress: true 13 | 14 | permissions: 15 | contents: read 16 | 17 | jobs: 18 | build: 19 | name: Build Tests with Go ${{ matrix.go-version }} on ${{ matrix.os }} 20 | runs-on: ${{ matrix.os }} 21 | strategy: 22 | matrix: 23 | go-version: [1.23.x] 24 | os: [ubuntu-latest] 25 | steps: 26 | - uses: actions/checkout@v4 27 | - uses: actions/setup-go@v5 28 | with: 29 | go-version: ${{ matrix.go-version }} 30 | check-latest: true 31 | - name: Build on ${{ matrix.os }} 32 | if: matrix.os == 'ubuntu-latest' 33 | env: 34 | CGO_ENABLED: 0 35 | GO111MODULE: on 36 | run: | 37 | sudo sysctl net.ipv6.conf.all.disable_ipv6=0 38 | sudo sysctl net.ipv6.conf.default.disable_ipv6=0 39 | make crosscompile 40 | -------------------------------------------------------------------------------- /.github/workflows/issues.yaml: -------------------------------------------------------------------------------- 1 | # @format 2 | 3 | name: Issue Workflow 4 | 5 | on: 6 | issues: 7 | types: 8 | - opened 9 | 10 | jobs: 11 | add-to-project: 12 | name: Add issue to project 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/add-to-project@v0.5.0 16 | with: 17 | project-url: https://github.com/orgs/miniohq/projects/2 18 | github-token: ${{ secrets.BOT_PAT }} 19 | -------------------------------------------------------------------------------- /.github/workflows/vulncheck.yml: -------------------------------------------------------------------------------- 1 | name: VulnCheck 2 | on: 3 | pull_request: 4 | branches: 5 | - master 6 | push: 7 | branches: 8 | - master 9 | jobs: 10 | vulncheck: 11 | name: Analysis 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Check out code into the Go module directory 15 | uses: actions/checkout@v4 16 | - name: Set up Go 17 | uses: actions/setup-go@v5 18 | with: 19 | go-version: 1.23.6 20 | - name: Get official govulncheck 21 | run: go install golang.org/x/vuln/cmd/govulncheck@latest 22 | shell: bash 23 | - name: Run govulncheck 24 | run: govulncheck ./... 25 | shell: bash 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cover.out 2 | *~ 3 | *.test 4 | release 5 | experimental 6 | coverage.txt 7 | *.tar.bz2 8 | parts/ 9 | prime/ 10 | stage/ 11 | mc 12 | .run* 13 | .idea/ 14 | mc.RELEASE* 15 | mc.gz 16 | .DS_Store 17 | .vscode/ 18 | .bin/ 19 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | linters: 3 | default: none 4 | enable: 5 | - gomodguard 6 | - govet 7 | - ineffassign 8 | - misspell 9 | - revive 10 | - staticcheck 11 | - unused 12 | settings: 13 | misspell: 14 | locale: US 15 | exclusions: 16 | generated: lax 17 | rules: 18 | - path: (.+)\.go$ 19 | text: instead of using struct literal 20 | - path: (.+)\.go$ 21 | text: should have a package comment 22 | - path: (.+)\.go$ 23 | text: error strings should not be capitalized or end with punctuation or a newline 24 | - path: (.+)\.go$ 25 | text: error strings should not end with punctuation or newlines 26 | - path: (.+)\.go$ 27 | text: error strings should not be capitalized 28 | paths: 29 | - third_party$ 30 | - builtin$ 31 | - examples$ 32 | formatters: 33 | enable: 34 | - gofmt 35 | - gofumpt 36 | - goimports 37 | exclusions: 38 | generated: lax 39 | paths: 40 | - third_party$ 41 | - builtin$ 42 | - examples$ 43 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # Generate CONTRIBUTORS.md: contributors.sh 2 | 3 | # Tip for finding duplicates (besides scanning the output of CONTRIBUTORS.md for name 4 | # duplicates that aren't also email duplicates): scan the output of: 5 | # git log --format='%aE - %aN' | sort -uf 6 | # 7 | # For explanation on this file format: man git-shortlog 8 | 9 | Anand Babu (AB) Periasamy Anand Babu (AB) Periasamy 10 | Anand Babu (AB) Periasamy 11 | Anis Elleuch 12 | Frederick F. Kautz IV 13 | Harshavardhana 14 | Krishna Srinivas 15 | Bosky 16 | -------------------------------------------------------------------------------- /CONFLICT.md: -------------------------------------------------------------------------------- 1 | ## mc (MinIO Client) v/s Midnight Commander (mc) 2 | 3 | There has been some amount of [requests](https://github.com/minio/mc/issues?q=is%3Aissue+midnight+commander+is%3Aclosed) on renaming this project to avoid the conflict with Midnight Commander for Unix distributions. We struggled with this, it is harder to find a name sweeter and shorter than `mc` for MinIO Client. 4 | 5 | Besides `mc` is a single static binary and can reside inside your application and is fully self contained. Midnight Commander (mc) is a free software clone of Norton Commander (nc). MinIO and Midnight shares no code or ideas. Only their abbreviation matches. 6 | 7 | Package managers are free to choose a different name if they like. One such solution [pointed out](https://github.com/minio/mc/issues/873#issuecomment-267583013) by one of our community members. 8 | 9 | ``` 10 | mv ./mc ./mcli 11 | ``` -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Setup your mc Github Repository 2 | Fork [mc upstream](https://github.com/minio/mc/fork) source repository to your own personal repository. 3 | ``` 4 | $ mkdir -p $GOPATH/src/github.com/minio 5 | $ cd $GOPATH/src/github.com/minio 6 | $ git clone https://github.com/$USER_ID/mc 7 | $ cd mc 8 | $ make 9 | $ ./mc --help 10 | ``` 11 | 12 | ### Developer Guidelines 13 | 14 | ``mc`` welcomes your contribution. To make the process as seamless as possible, we ask for the following: 15 | 16 | * Go ahead and fork the project and make your changes. We encourage pull requests to discuss code changes. 17 | - Fork it 18 | - Create your feature branch (git checkout -b my-new-feature) 19 | - Commit your changes (git commit -am 'Add some feature') 20 | - Push to the branch (git push origin my-new-feature) 21 | - Create new Pull Request 22 | 23 | * If you have additional dependencies for ``mc``, ``mc`` manages its dependencies using `go mod` 24 | - Run `go get foo/bar` 25 | - Edit your code to import foo/bar 26 | - Run `GO111MODULE=on go mod tidy` from top-level folder 27 | 28 | * When you're ready to create a pull request, be sure to: 29 | - Have test cases for the new code. If you have questions about how to do it, please ask in your pull request. 30 | - Run `go fmt` 31 | - Squash your commits into a single commit. `git rebase -i`. It's okay to force update your pull request. 32 | - Make sure `make install` completes. 33 | 34 | * Read [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project 35 | - `mc` project is conformant with Golang style 36 | - if you happen to observe offending code, please feel free to send a pull request 37 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.22-alpine as build 2 | 3 | LABEL maintainer="MinIO Inc " 4 | 5 | ENV GOPATH /go 6 | ENV CGO_ENABLED 0 7 | 8 | 9 | RUN apk add -U --no-cache ca-certificates 10 | RUN apk add -U curl 11 | RUN curl -s -q https://raw.githubusercontent.com/minio/mc/master/LICENSE -o /go/LICENSE 12 | RUN curl -s -q https://raw.githubusercontent.com/minio/mc/master/CREDITS -o /go/CREDITS 13 | RUN go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" "github.com/minio/mc@latest" 14 | 15 | FROM scratch 16 | 17 | COPY --from=build /go/bin/mc /usr/bin/mc 18 | COPY --from=build /go/CREDITS /licenses/CREDITS 19 | COPY --from=build /go/LICENSE /licenses/LICENSE 20 | COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ 21 | 22 | ENTRYPOINT ["mc"] 23 | -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8 2 | 3 | LABEL maintainer="MinIO Inc " 4 | 5 | COPY mc /usr/bin/ 6 | COPY CREDITS /licenses/CREDITS 7 | COPY LICENSE /licenses/LICENSE 8 | 9 | RUN \ 10 | microdnf update --nodocs --assumeyes && \ 11 | microdnf install ca-certificates --nodocs --assumeyes && \ 12 | microdnf clean all 13 | 14 | ENTRYPOINT ["mc"] 15 | -------------------------------------------------------------------------------- /Dockerfile.hotfix: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi9/ubi-minimal:latest as build 2 | 3 | RUN microdnf update --nodocs --assumeyes && microdnf install ca-certificates --nodocs --assumeyes 4 | 5 | FROM registry.access.redhat.com/ubi9/ubi-micro:latest 6 | 7 | ARG TARGETARCH 8 | ARG RELEASE 9 | 10 | LABEL maintainer="MinIO Inc " 11 | 12 | # On RHEL the certificate bundle is located at: 13 | # - /etc/pki/tls/certs/ca-bundle.crt (RHEL 6) 14 | # - /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem (RHEL 7) 15 | COPY --from=build /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/ 16 | 17 | COPY CREDITS /licenses/CREDITS 18 | COPY LICENSE /licenses/LICENSE 19 | 20 | ADD https://dl.min.io/client/mc/hotfixes/linux-${TARGETARCH}/archive/mc.${RELEASE} /usr/bin/mc 21 | 22 | RUN chmod +x /usr/bin/mc 23 | 24 | ENTRYPOINT ["mc"] 25 | -------------------------------------------------------------------------------- /Dockerfile.release: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS build 2 | 3 | RUN microdnf update --nodocs --assumeyes && microdnf install ca-certificates --nodocs --assumeyes 4 | 5 | FROM registry.access.redhat.com/ubi9/ubi-micro:latest 6 | 7 | ARG TARGETARCH 8 | ARG RELEASE 9 | 10 | LABEL maintainer="MinIO Inc " 11 | 12 | # On RHEL the certificate bundle is located at: 13 | # - /etc/pki/tls/certs/ca-bundle.crt (RHEL 6) 14 | # - /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem (RHEL 7) 15 | COPY --from=build /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/ 16 | 17 | COPY CREDITS /licenses/CREDITS 18 | COPY LICENSE /licenses/LICENSE 19 | 20 | ADD https://dl.minio.io/client/mc/release/linux-${TARGETARCH}/archive/mc.${RELEASE} /usr/bin/mc 21 | 22 | RUN chmod +x /usr/bin/mc 23 | 24 | ENTRYPOINT ["mc"] 25 | -------------------------------------------------------------------------------- /Dockerfile.release.old_cpu: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS build 2 | 3 | RUN microdnf update --nodocs --assumeyes && microdnf install ca-certificates --nodocs --assumeyes 4 | 5 | FROM registry.access.redhat.com/ubi8/ubi-micro:latest 6 | 7 | ARG TARGETARCH 8 | ARG RELEASE 9 | 10 | LABEL maintainer="MinIO Inc " 11 | 12 | # On RHEL the certificate bundle is located at: 13 | # - /etc/pki/tls/certs/ca-bundle.crt (RHEL 6) 14 | # - /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem (RHEL 7) 15 | COPY --from=build /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/ 16 | 17 | COPY CREDITS /licenses/CREDITS 18 | COPY LICENSE /licenses/LICENSE 19 | 20 | ADD https://dl.minio.io/client/mc/release/linux-${TARGETARCH}/archive/mc.${RELEASE} /usr/bin/mc 21 | 22 | RUN chmod +x /usr/bin/mc 23 | 24 | ENTRYPOINT ["mc"] 25 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | MinIO Client (C) 2014-2020 MinIO, Inc. 2 | 3 | This product includes software developed at MinIO, Inc. 4 | (https://min.io/). 5 | 6 | The MinIO project contains unmodified/modified subcomponents too with 7 | separate copyright notices and license terms. Your use of the source 8 | code for the these subcomponents is subject to the terms and conditions 9 | of the following licenses. 10 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /buildscripts/build.env: -------------------------------------------------------------------------------- 1 | ## FIXME: 2 | ## In OSX, 'sort -V' option does not exist, hence 3 | ## we have our own version compare function. 4 | ## Once OSX has the option, below function is good enough. 5 | ## 6 | ## check_minimum_version() { 7 | ## versions=($(echo -e "$1\n$2" | sort -V)) 8 | ## return [ "$1" == "${versions[0]}" ] 9 | ## } 10 | ## 11 | check_minimum_version() { 12 | IFS='.' read -r -a varray1 <<< "$1" 13 | IFS='.' read -r -a varray2 <<< "$2" 14 | 15 | for i in "${!varray1[@]}"; do 16 | if [[ ${varray1[i]} -lt ${varray2[i]} ]]; then 17 | return 0 18 | elif [[ ${varray1[i]} -gt ${varray2[i]} ]]; then 19 | return 1 20 | fi 21 | done 22 | 23 | return 0 24 | } 25 | -------------------------------------------------------------------------------- /buildscripts/cross-compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2015-2021 MinIO, Inc. 4 | # 5 | # This file is part of MinIO Object Storage stack 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU Affero General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Affero General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | set -e 22 | 23 | # Enable tracing if set. 24 | [ -n "$BASH_XTRACEFD" ] && set -x 25 | 26 | function _init() { 27 | ## All binaries are static make sure to disable CGO. 28 | export CGO_ENABLED=0 29 | 30 | ## List of architectures and OS to test coss compilation. 31 | SUPPORTED_OSARCH="linux/ppc64le linux/s390x linux/mips64 linux/amd64 windows/amd64 darwin/amd64 darwin/arm64 linux/arm64 linux/arm" 32 | } 33 | 34 | function _build() { 35 | local osarch=$1 36 | IFS=/ read -r -a arr <<<"$osarch" 37 | os="${arr[0]}" 38 | arch="${arr[1]}" 39 | package=$(go list -f '{{.ImportPath}}') 40 | printf -- "--> %15s:%s\n" "${osarch}" "${package}" 41 | 42 | # Go build to build the binary. 43 | export GOOS=$os 44 | export GOARCH=$arch 45 | export GO111MODULE=on 46 | export CGO_ENABLED=0 47 | go build -tags kqueue -o /dev/null 48 | } 49 | 50 | function main() { 51 | echo "Testing builds for OS/Arch: ${SUPPORTED_OSARCH}" 52 | for each_osarch in ${SUPPORTED_OSARCH}; do 53 | _build "${each_osarch}" 54 | done 55 | } 56 | 57 | _init && main "$@" 58 | -------------------------------------------------------------------------------- /cmd/admin-accesskey-disable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminAccesskeyDisableCmd = cli.Command{ 25 | Name: "disable", 26 | Usage: "disable an access key", 27 | Action: mainAdminAccesskeyDisable, 28 | Before: setGlobalsFromContext, 29 | Flags: globalFlags, 30 | OnUsageError: onUsageError, 31 | CustomHelpTemplate: `NAME: 32 | {{.HelpName}} - {{.Usage}} 33 | 34 | USAGE: 35 | {{.HelpName}} [FLAGS] [TARGET] 36 | 37 | FLAGS: 38 | {{range .VisibleFlags}}{{.}} 39 | {{end}} 40 | EXAMPLES: 41 | 1. Disable access key 42 | {{.Prompt}} {{.HelpName}} myminio myaccesskey 43 | `, 44 | } 45 | 46 | func mainAdminAccesskeyDisable(ctx *cli.Context) error { 47 | return enableDisableAccesskey(ctx, false) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/admin-accesskey-enable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminAccesskeyEnableCmd = cli.Command{ 25 | Name: "enable", 26 | Usage: "enable an access key", 27 | Action: mainAdminAccesskeyEnable, 28 | Before: setGlobalsFromContext, 29 | Flags: globalFlags, 30 | OnUsageError: onUsageError, 31 | CustomHelpTemplate: `NAME: 32 | {{.HelpName}} - {{.Usage}} 33 | 34 | USAGE: 35 | {{.HelpName}} [FLAGS] [TARGET] 36 | 37 | FLAGS: 38 | {{range .VisibleFlags}}{{.}} 39 | {{end}} 40 | EXAMPLES: 41 | 1. Enable access key 42 | {{.Prompt}} {{.HelpName}} myminio myaccesskey 43 | `, 44 | } 45 | 46 | func mainAdminAccesskeyEnable(ctx *cli.Context) error { 47 | return enableDisableAccesskey(ctx, true) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/admin-accesskey-remove.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminAccesskeyRemoveCmd = cli.Command{ 25 | Name: "remove", 26 | ShortName: "rm", 27 | Usage: "delete access key pairs for builtin users", 28 | Action: mainAdminAccesskeyRemove, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | OnUsageError: onUsageError, 32 | CustomHelpTemplate: `NAME: 33 | {{.HelpName}} - {{.Usage}} 34 | 35 | USAGE: 36 | {{.HelpName}} [FLAGS] TARGET ACCESSKEY 37 | 38 | FLAGS: 39 | {{range .VisibleFlags}}{{.}} 40 | {{end}} 41 | EXAMPLES: 42 | 1. Remove the access key "testkey" from local server 43 | {{.Prompt}} {{.HelpName}} local/ testkey 44 | `, 45 | } 46 | 47 | func mainAdminAccesskeyRemove(ctx *cli.Context) error { 48 | return commonAccesskeyRemove(ctx) 49 | } 50 | -------------------------------------------------------------------------------- /cmd/admin-accesskey.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminAccesskeySubcommands = []cli.Command{ 23 | adminAccesskeyListCmd, 24 | adminAccesskeyRemoveCmd, 25 | adminAccesskeyInfoCmd, 26 | adminAccesskeyCreateCmd, 27 | adminAccesskeyEditCmd, 28 | adminAccesskeyEnableCmd, 29 | adminAccesskeyDisableCmd, 30 | adminAccesskeySTSRevokeCmd, 31 | } 32 | 33 | var adminAccesskeyCmd = cli.Command{ 34 | Name: "accesskey", 35 | Usage: "manage access keys defined in the MinIO server", 36 | Action: mainAdminAccesskey, 37 | Before: setGlobalsFromContext, 38 | Flags: globalFlags, 39 | Subcommands: adminAccesskeySubcommands, 40 | HideHelpCommand: true, 41 | } 42 | 43 | func mainAdminAccesskey(ctx *cli.Context) error { 44 | commandNotFound(ctx, adminAccesskeySubcommands) 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /cmd/admin-bucket-info.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminBucketInfoFlags = []cli.Flag{} 25 | 26 | var adminBucketInfoCmd = cli.Command{ 27 | Name: "info", 28 | Usage: "display bucket information", 29 | Action: mainAdminBucketInfo, 30 | OnUsageError: onUsageError, 31 | Before: setGlobalsFromContext, 32 | Flags: append(adminBucketInfoFlags, globalFlags...), 33 | HideHelpCommand: true, 34 | } 35 | 36 | // mainAdminBucketInfo is the handler for "mc admin bucket info" command. 37 | func mainAdminBucketInfo(_ *cli.Context) error { 38 | deprecatedError("mc stat") 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /cmd/admin-bucket-quota.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminQuotaFlags = []cli.Flag{ 25 | cli.StringFlag{ 26 | Name: "hard", 27 | Usage: "set a hard quota, disallowing writes after quota is reached", 28 | }, 29 | cli.BoolFlag{ 30 | Name: "clear", 31 | Usage: "clears bucket quota configured for bucket", 32 | }, 33 | } 34 | 35 | var adminBucketQuotaCmd = cli.Command{ 36 | Name: "quota", 37 | Usage: "manage bucket quota", 38 | Action: mainAdminBucketQuota, 39 | OnUsageError: onUsageError, 40 | Before: setGlobalsFromContext, 41 | Flags: append(adminQuotaFlags, globalFlags...), 42 | HideHelpCommand: true, 43 | } 44 | 45 | // mainAdminBucketQuota is the handler for "mc admin bucket quota" command. 46 | func mainAdminBucketQuota(_ *cli.Context) error { 47 | deprecatedError("mc quota") 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /cmd/admin-bucket-remote-add.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminBucketRemoteAddCmd = cli.Command{ 25 | Name: "add", 26 | Usage: "add a new remote target", 27 | Action: mainAdminBucketRemoteAdd, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | HideHelp: true, 32 | } 33 | 34 | // mainAdminBucketRemoteAdd is the handle for "mc admin bucket remote set" command. 35 | func mainAdminBucketRemoteAdd(_ *cli.Context) error { 36 | deprecatedError("mc replicate add") 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /cmd/admin-bucket-remote-edit.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminBucketRemoteEditCmd = cli.Command{ 25 | Name: "edit", 26 | Usage: "edit remote target", 27 | Action: mainAdminBucketRemoteEdit, 28 | Before: setGlobalsFromContext, 29 | OnUsageError: onUsageError, 30 | Flags: globalFlags, 31 | HideHelp: true, 32 | } 33 | 34 | // mainAdminBucketRemoteEdit is the handle for "mc admin bucket remote edit" command. 35 | func mainAdminBucketRemoteEdit(_ *cli.Context) error { 36 | deprecatedError("mc replicate update") 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /cmd/admin-bucket-remote-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminBucketRemoteSubcommands = []cli.Command{ 23 | adminBucketRemoteAddCmd, 24 | adminBucketRemoteEditCmd, 25 | adminBucketRemoteRmCmd, 26 | } 27 | 28 | var adminBucketRemoteCmd = cli.Command{ 29 | Name: "remote", 30 | Usage: "configure remote target buckets", 31 | Action: mainadminBucketRemote, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: adminBucketRemoteSubcommands, 35 | HideHelpCommand: true, 36 | } 37 | 38 | // mainadminBucketRemote is the handle for "mc admin bucket remote" command. 39 | func mainadminBucketRemote(ctx *cli.Context) error { 40 | commandNotFound(ctx, adminBucketRemoteSubcommands) 41 | return nil 42 | // Sub-commands like "add", "ls", "rm" have their own main. 43 | } 44 | -------------------------------------------------------------------------------- /cmd/admin-bucket-remote-remove.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminBucketRemoteRmCmd = cli.Command{ 25 | Name: "remove", 26 | ShortName: "rm", 27 | Usage: "remove configured remote target", 28 | Action: mainAdminBucketRemoteRemove, 29 | OnUsageError: onUsageError, 30 | Before: setGlobalsFromContext, 31 | Flags: globalFlags, 32 | HideHelp: true, 33 | } 34 | 35 | // mainAdminBucketRemoteRemove is the handle for "mc admin bucket remote rm" command. 36 | func mainAdminBucketRemoteRemove(_ *cli.Context) error { 37 | deprecatedError("mc replicate rm") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-bucket.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminBucketSubcommands = []cli.Command{ 23 | adminBucketRemoteCmd, 24 | adminBucketQuotaCmd, 25 | adminBucketInfoCmd, 26 | } 27 | 28 | var adminBucketCmd = cli.Command{ 29 | Name: "bucket", 30 | Usage: "manage buckets defined in the MinIO server", 31 | Action: mainAdminBucket, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: adminBucketSubcommands, 35 | HideHelpCommand: true, 36 | Hidden: true, 37 | } 38 | 39 | // mainAdminBucket is the handle for "mc admin bucket" command. 40 | func mainAdminBucket(ctx *cli.Context) error { 41 | commandNotFound(ctx, adminBucketSubcommands) 42 | return nil 43 | // Sub-commands like "quota", "remote" have their own main. 44 | } 45 | -------------------------------------------------------------------------------- /cmd/admin-cluster-bucket.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminClusterBucketSubcommands = []cli.Command{ 23 | adminClusterBucketImportCmd, 24 | adminClusterBucketExportCmd, 25 | } 26 | 27 | var adminClusterBucketCmd = cli.Command{ 28 | Name: "bucket", 29 | Usage: "manage bucket metadata on MinIO cluster", 30 | Action: mainAdminClusterBucket, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | Subcommands: adminClusterBucketSubcommands, 34 | HideHelpCommand: true, 35 | } 36 | 37 | // mainAdminClusterBucket is the handle for "mc admin cluster bucket" command. 38 | func mainAdminClusterBucket(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminClusterBucketSubcommands) 40 | return nil 41 | // Sub-commands like "export", "import" have their own main. 42 | } 43 | -------------------------------------------------------------------------------- /cmd/admin-cluster-iam.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminClusterIAMSubcommands = []cli.Command{ 23 | adminClusterIAMImportCmd, 24 | adminClusterIAMExportCmd, 25 | } 26 | 27 | var adminClusterIAMCmd = cli.Command{ 28 | Name: "iam", 29 | Usage: "manage IAM info on MinIO cluster", 30 | Action: mainadminClusterIAM, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | Subcommands: adminClusterIAMSubcommands, 34 | HideHelpCommand: true, 35 | } 36 | 37 | // mainadminClusterIAM is the handle for "mc admin cluster bucket" command. 38 | func mainadminClusterIAM(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminClusterIAMSubcommands) 40 | return nil 41 | // Sub-commands like "export", "import" have their own main. 42 | } 43 | -------------------------------------------------------------------------------- /cmd/admin-cluster.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminClusterSubcommands = []cli.Command{ 23 | adminClusterBucketCmd, 24 | adminClusterIAMCmd, 25 | } 26 | 27 | var adminClusterCmd = cli.Command{ 28 | Name: "cluster", 29 | Usage: "manage MinIO cluster metadata", 30 | Action: mainAdminCluster, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | Subcommands: adminClusterSubcommands, 34 | HideHelpCommand: true, 35 | } 36 | 37 | // mainAdminCluster is the handle for "mc admin cluster" command. 38 | func mainAdminCluster(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminClusterSubcommands) 40 | return nil 41 | // Sub-commands like "bucket", "iam" have their own main. 42 | } 43 | -------------------------------------------------------------------------------- /cmd/admin-config.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminConfigSubcommands = []cli.Command{ 23 | adminConfigGetCmd, 24 | adminConfigSetCmd, 25 | adminConfigResetCmd, 26 | adminConfigHistoryCmd, 27 | adminConfigRestoreCmd, 28 | adminConfigExportCmd, 29 | adminConfigImportCmd, 30 | } 31 | 32 | var adminConfigCmd = cli.Command{ 33 | Name: "config", 34 | Usage: "manage MinIO server configuration", 35 | Action: mainAdminConfig, 36 | Before: setGlobalsFromContext, 37 | Flags: globalFlags, 38 | Subcommands: adminConfigSubcommands, 39 | HideHelpCommand: true, 40 | } 41 | 42 | // mainAdminConfig is the handle for "mc admin config" command. 43 | func mainAdminConfig(ctx *cli.Context) error { 44 | commandNotFound(ctx, adminConfigSubcommands) 45 | return nil 46 | // Sub-commands like "get", "set" have their own main. 47 | } 48 | -------------------------------------------------------------------------------- /cmd/admin-console.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | 24 | "github.com/minio/cli" 25 | ) 26 | 27 | var adminConsoleFlags = []cli.Flag{ 28 | cli.IntFlag{ 29 | Name: "limit, l", 30 | Usage: "show last n log entries", 31 | Value: 10, 32 | }, 33 | cli.StringFlag{ 34 | Name: "type, t", 35 | Usage: "list error logs by type. Valid options are '[minio, application, all]'", 36 | Value: "all", 37 | }, 38 | } 39 | 40 | var adminConsoleCmd = cli.Command{ 41 | Name: "console", 42 | Usage: "show MinIO logs", 43 | Action: mainAdminConsole, 44 | OnUsageError: onUsageError, 45 | Before: setGlobalsFromContext, 46 | Flags: append(adminConsoleFlags, globalFlags...), 47 | Hidden: true, 48 | HideHelpCommand: true, 49 | CustomHelpTemplate: "This command is not supported now and replaced by 'admin logs' command. Please use 'mc admin logs'.\n", 50 | } 51 | 52 | // mainAdminConsole - the entry function of console command 53 | func mainAdminConsole(ctx *cli.Context) error { 54 | newCmd := []string{"mc admin logs"} 55 | 56 | var flgStr string 57 | 58 | if ctx.IsSet("limit") { 59 | flgStr = fmt.Sprintf("%s %d", "--last", ctx.Int("limit")) 60 | newCmd = append(newCmd, flgStr) 61 | } 62 | 63 | if ctx.IsSet("type") { 64 | flgStr = fmt.Sprintf("%s %s", "--type", strings.ToLower(ctx.String("type"))) 65 | newCmd = append(newCmd, flgStr) 66 | } 67 | newCmd = append(newCmd, ctx.Args()...) 68 | 69 | deprecatedError(strings.Join(newCmd, " ")) 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /cmd/admin-decom.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminDecommissionSubcommands = []cli.Command{ 25 | adminDecommissionStartCmd, 26 | adminDecommissionStatusCmd, 27 | adminDecommissionCancelCmd, 28 | } 29 | 30 | var adminDecommissionCmd = cli.Command{ 31 | Name: "decommission", 32 | Aliases: []string{"decom"}, 33 | Usage: "manage MinIO server pool decommissioning", 34 | Action: mainAdminDecommission, 35 | Before: setGlobalsFromContext, 36 | Flags: globalFlags, 37 | Subcommands: adminDecommissionSubcommands, 38 | HideHelpCommand: true, 39 | } 40 | 41 | // mainAdminDecommission is the handle for "mc admin decommission" command. 42 | func mainAdminDecommission(ctx *cli.Context) error { 43 | commandNotFound(ctx, adminDecommissionSubcommands) 44 | return nil 45 | // Sub-commands like "get", "set" have their own main. 46 | } 47 | -------------------------------------------------------------------------------- /cmd/admin-group-disable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminGroupDisableCmd = cli.Command{ 25 | Name: "disable", 26 | Usage: "disable a group", 27 | Action: mainAdminGroupEnableDisable, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | CustomHelpTemplate: `NAME: 32 | {{.HelpName}} - {{.Usage}} 33 | 34 | USAGE: 35 | {{.HelpName}} TARGET GROUPNAME 36 | 37 | FLAGS: 38 | {{range .VisibleFlags}}{{.}} 39 | {{end}} 40 | EXAMPLES: 41 | 1. Disable group 'allcents'. 42 | {{.Prompt}} {{.HelpName}} myminio allcents 43 | `, 44 | } 45 | -------------------------------------------------------------------------------- /cmd/admin-group.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminGroupSubcommands = []cli.Command{ 23 | adminGroupAddCmd, 24 | adminGroupRemoveCmd, 25 | adminGroupInfoCmd, 26 | adminGroupListCmd, 27 | adminGroupEnableCmd, 28 | adminGroupDisableCmd, 29 | } 30 | 31 | var adminGroupCmd = cli.Command{ 32 | Name: "group", 33 | Usage: "manage groups", 34 | Action: mainAdminGroup, 35 | Before: setGlobalsFromContext, 36 | Flags: globalFlags, 37 | Subcommands: adminGroupSubcommands, 38 | HideHelpCommand: true, 39 | } 40 | 41 | // mainAdminGroup is the handle for "mc admin config" command. 42 | func mainAdminGroup(ctx *cli.Context) error { 43 | commandNotFound(ctx, adminGroupSubcommands) 44 | return nil 45 | // Sub-commands like "get", "set" have their own main. 46 | } 47 | -------------------------------------------------------------------------------- /cmd/admin-idp.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminIDPCmd = cli.Command{ 23 | Name: "idp", 24 | Usage: "manage MinIO IDentity Provider server configuration", 25 | Action: mainAdminIDP, 26 | Before: setGlobalsFromContext, 27 | Flags: globalFlags, 28 | HideHelpCommand: true, 29 | Hidden: true, 30 | CustomHelpTemplate: `This command's functionality has moved and this command is DEPRECATED. 31 | 32 | Please use commands under 'mc idp ldap|openid' instead. 33 | `, 34 | } 35 | 36 | func mainAdminIDP(_ *cli.Context) error { 37 | deprecatedError("mc idp ldap|openid") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-inspect.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminInspectCmd = cli.Command{ 25 | Name: "inspect", 26 | Usage: "inspect files on MinIO server", 27 | Action: mainAdminInspect, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | HideHelpCommand: true, 31 | Hidden: true, 32 | CustomHelpTemplate: "Please use 'mc support inspect'", 33 | } 34 | 35 | // mainAdminHeal - the entry function of heal command 36 | func mainAdminInspect(_ *cli.Context) error { 37 | deprecatedError("mc support inspect") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-kms-key-create.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "fmt" 22 | "os" 23 | 24 | "github.com/fatih/color" 25 | "github.com/minio/cli" 26 | "github.com/minio/mc/pkg/probe" 27 | "github.com/minio/pkg/v3/console" 28 | "golang.org/x/term" 29 | ) 30 | 31 | var adminKMSCreateKeyCmd = cli.Command{ 32 | Name: "create", 33 | Usage: "creates a new master KMS key", 34 | Action: mainAdminKMSCreateKey, 35 | OnUsageError: onUsageError, 36 | Before: setGlobalsFromContext, 37 | Flags: globalFlags, 38 | CustomHelpTemplate: `NAME: 39 | {{.HelpName}} - {{.Usage}} 40 | 41 | USAGE: 42 | {{.HelpName}} TARGET [KEY_NAME] 43 | 44 | FLAGS: 45 | {{range .VisibleFlags}}{{.}} 46 | {{end}} 47 | EXAMPLES: 48 | 1. Create a new master key named 'my-key' default master key. 49 | $ {{.HelpName}} play my-key 50 | `, 51 | } 52 | 53 | // adminKMSCreateKeyCmd is the handler for the "mc admin kms key create" command. 54 | func mainAdminKMSCreateKey(ctx *cli.Context) error { 55 | if len(ctx.Args()) != 2 { 56 | showCommandHelpAndExit(ctx, 1) // last argument is exit code 57 | } 58 | 59 | client, err := newAdminClient(ctx.Args().Get(0)) 60 | fatalIf(err, "Cannot get a configured admin connection.") 61 | 62 | keyID := ctx.Args().Get(1) 63 | e := client.CreateKey(globalContext, keyID) 64 | fatalIf(probe.NewError(e), "Failed to create master key") 65 | 66 | if term.IsTerminal(int(os.Stdout.Fd())) { 67 | console.Println(color.GreenString(fmt.Sprintf("Created master key `%s` successfully", keyID))) 68 | } 69 | return nil 70 | } 71 | -------------------------------------------------------------------------------- /cmd/admin-kms-key.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminKMSKeySubcommands = []cli.Command{ 23 | adminKMSCreateKeyCmd, 24 | adminKMSKeyStatusCmd, 25 | adminKMSKeyListCmd, 26 | } 27 | 28 | var adminKMSKeyCmd = cli.Command{ 29 | Name: "key", 30 | Usage: "manage KMS master keys: Request key status information", 31 | Action: mainAdminKMSKey, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: adminKMSKeySubcommands, 35 | HideHelpCommand: true, 36 | } 37 | 38 | // mainAdminKMSKey is the handle for the "mc admin kms key" command. 39 | func mainAdminKMSKey(ctx *cli.Context) error { 40 | commandNotFound(ctx, adminKMSKeySubcommands) 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /cmd/admin-kms.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminKMSSubcommands = []cli.Command{ 23 | adminKMSKeyCmd, 24 | } 25 | 26 | var adminKMSCmd = cli.Command{ 27 | Name: "kms", 28 | Usage: "perform KMS management operations", 29 | Action: mainAdminKMS, 30 | Before: setGlobalsFromContext, 31 | Flags: globalFlags, 32 | Subcommands: adminKMSSubcommands, 33 | HideHelpCommand: true, 34 | } 35 | 36 | // mainAdminKMS is the handle for the "mc admin kms" command. 37 | func mainAdminKMS(ctx *cli.Context) error { 38 | commandNotFound(ctx, adminKMSSubcommands) 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /cmd/admin-policy-add.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminPolicyAddCmd = cli.Command{ 25 | Name: "add", 26 | Usage: "add an IAM policy", 27 | Action: mainAdminPolicyAdd, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | HideHelpCommand: true, 32 | Hidden: true, 33 | CustomHelpTemplate: `Please use 'mc admin policy create'`, 34 | } 35 | 36 | func mainAdminPolicyAdd(_ *cli.Context) error { 37 | deprecatedError("mc admin policy create") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-policy-detach.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminDetachPolicyFlags = []cli.Flag{ 25 | cli.StringFlag{ 26 | Name: "user, u", 27 | Usage: "detach policy from user", 28 | }, 29 | cli.StringFlag{ 30 | Name: "group, g", 31 | Usage: "detach policy from group", 32 | }, 33 | } 34 | 35 | var adminPolicyDetachCmd = cli.Command{ 36 | Name: "detach", 37 | Usage: "detach an IAM policy from a user or group", 38 | Action: mainAdminPolicyDetach, 39 | OnUsageError: onUsageError, 40 | Before: setGlobalsFromContext, 41 | Flags: append(adminDetachPolicyFlags, globalFlags...), 42 | CustomHelpTemplate: `NAME: 43 | {{.HelpName}} - {{.Usage}} 44 | 45 | USAGE: 46 | {{.HelpName}} [FLAGS] TARGET POLICY [POLICY...] [--user USER | --group GROUP] 47 | 48 | Exactly one of --user or --group is required. 49 | 50 | POLICY: 51 | Name of the policy on the MinIO server. 52 | 53 | FLAGS: 54 | {{range .VisibleFlags}}{{.}} 55 | {{end}} 56 | EXAMPLES: 57 | 1. Detach the "readonly" policy from user "james". 58 | {{.Prompt}} {{.HelpName}} myminio readonly --user james 59 | 2. Detach the "audit-policy" and "acct-policy" policies from group "legal". 60 | {{.Prompt}} {{.HelpName}} myminio audit-policy acct-policy --group legal 61 | `, 62 | } 63 | 64 | // mainAdmihPolicyDetach is the handler for "mc admin policy detach" command. 65 | func mainAdminPolicyDetach(ctx *cli.Context) error { 66 | return userAttachOrDetachPolicy(ctx, false) 67 | } 68 | -------------------------------------------------------------------------------- /cmd/admin-policy-set.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminPolicySetCmd = cli.Command{ 25 | Name: "set", 26 | Usage: "set IAM policy on a user or group", 27 | Action: mainAdminPolicySet, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | HideHelpCommand: true, 32 | Hidden: true, 33 | CustomHelpTemplate: `Please use 'mc admin policy attach'`, 34 | } 35 | 36 | func mainAdminPolicySet(_ *cli.Context) error { 37 | deprecatedError("mc admin policy attach") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-policy-unset.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminPolicyUnsetCmd = cli.Command{ 25 | Name: "unset", 26 | Usage: "unset an IAM policy for a user or group", 27 | Action: mainAdminPolicyUnsetErr, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | HideHelpCommand: true, 32 | Hidden: true, 33 | CustomHelpTemplate: `Please use 'mc admin policy detach'`, 34 | } 35 | 36 | func mainAdminPolicyUnsetErr(_ *cli.Context) error { 37 | deprecatedError("mc admin policy detach") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-policy-update.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminPolicyUpdateCmd = cli.Command{ 25 | Name: "update", 26 | Usage: "attach a new IAM policy to user or group", 27 | Action: mainAdminPolicyUpdateErr, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | HideHelpCommand: true, 32 | Hidden: true, 33 | CustomHelpTemplate: `Please use 'mc admin policy attach'`, 34 | } 35 | 36 | func mainAdminPolicyUpdateErr(_ *cli.Context) error { 37 | deprecatedError("mc admin policy attach") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-policy.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminPolicySubcommands = []cli.Command{ 23 | adminPolicyCreateCmd, 24 | adminPolicyRemoveCmd, 25 | adminPolicyListCmd, 26 | adminPolicyInfoCmd, 27 | adminPolicyAttachCmd, 28 | adminPolicyDetachCmd, 29 | adminPolicyEntitiesCmd, 30 | adminPolicyAddCmd, 31 | adminPolicySetCmd, 32 | adminPolicyUnsetCmd, 33 | adminPolicyUpdateCmd, 34 | } 35 | 36 | var adminPolicyCmd = cli.Command{ 37 | Name: "policy", 38 | Usage: "manage policies defined in the MinIO server", 39 | Action: mainAdminPolicy, 40 | Before: setGlobalsFromContext, 41 | Flags: globalFlags, 42 | Subcommands: adminPolicySubcommands, 43 | HideHelpCommand: true, 44 | } 45 | 46 | // mainAdminPolicy is the handle for "mc admin policy" command. 47 | func mainAdminPolicy(ctx *cli.Context) error { 48 | commandNotFound(ctx, adminPolicySubcommands) 49 | return nil 50 | // Sub-commands like "get", "set" have their own main. 51 | } 52 | -------------------------------------------------------------------------------- /cmd/admin-profile-start.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminProfileStartCmd = cli.Command{ 25 | Name: "start", 26 | Usage: "start recording profile data", 27 | Action: mainAdminProfileStart, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | HideHelpCommand: true, 31 | Hidden: true, 32 | CustomHelpTemplate: "Please use 'mc support profile start'", 33 | } 34 | 35 | // mainAdminProfileStart - the entry function of profile command 36 | func mainAdminProfileStart(_ *cli.Context) error { 37 | deprecatedError("mc support profile start") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-profile-stop.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminProfileStopCmd = cli.Command{ 25 | Name: "stop", 26 | Usage: "stop and download profile data", 27 | Action: mainAdminProfileStop, 28 | OnUsageError: onUsageError, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | HideHelpCommand: true, 32 | Hidden: true, 33 | CustomHelpTemplate: "Please use 'mc support profile stop'", 34 | } 35 | 36 | // mainAdminProfileStop - the entry function of profile stop command 37 | func mainAdminProfileStop(_ *cli.Context) error { 38 | deprecatedError("mc support profile stop") 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /cmd/admin-profile.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminProfileSubcommands = []cli.Command{ 25 | adminProfileStartCmd, 26 | adminProfileStopCmd, 27 | } 28 | 29 | var adminProfileCmd = cli.Command{ 30 | Name: "profile", 31 | Usage: "generate profile data for debugging purposes", 32 | Action: mainAdminProfile, 33 | OnUsageError: onUsageError, 34 | Before: setGlobalsFromContext, 35 | Flags: globalFlags, 36 | Subcommands: adminProfileSubcommands, 37 | HideHelpCommand: true, 38 | Hidden: true, 39 | } 40 | 41 | // mainAdminProfile is the handle for "mc admin profile" command. 42 | func mainAdminProfile(_ *cli.Context) error { 43 | deprecatedError("mc support profile") 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /cmd/admin-prometheus.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminPrometheusSubcommands = []cli.Command{ 23 | adminPrometheusGenerateCmd, 24 | adminPrometheusMetricsCmd, 25 | } 26 | 27 | var adminPrometheusCmd = cli.Command{ 28 | Name: "prometheus", 29 | Usage: "manages prometheus config", 30 | Action: mainAdminPrometheus, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | HideHelpCommand: true, 34 | Subcommands: adminPrometheusSubcommands, 35 | CustomHelpTemplate: `NAME: 36 | {{.HelpName}} - {{.Usage}} 37 | 38 | USAGE: 39 | {{.HelpName}} TARGET 40 | 41 | FLAGS: 42 | {{range .VisibleFlags}}{{.}} 43 | {{end}} 44 | `, 45 | } 46 | 47 | // mainAdminPrometheus is the handle for "mc admin prometheus" command. 48 | func mainAdminPrometheus(ctx *cli.Context) error { 49 | commandNotFound(ctx, adminPrometheusSubcommands) 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /cmd/admin-rebalance-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminRebalanceSubcommands = []cli.Command{ 23 | adminRebalanceStartCmd, 24 | adminRebalanceStatusCmd, 25 | adminRebalanceStopCmd, 26 | } 27 | 28 | var adminRebalanceCmd = cli.Command{ 29 | Name: "rebalance", 30 | Usage: "Manage MinIO rebalance", 31 | Action: mainAdminRebalance, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: adminRebalanceSubcommands, 35 | HideHelpCommand: true, 36 | } 37 | 38 | func mainAdminRebalance(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminRebalanceSubcommands) 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /cmd/admin-replicate-resync.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminReplicateResyncSubcommands = []cli.Command{ 23 | adminReplicateResyncStartCmd, 24 | adminReplicateResyncStatusCmd, 25 | adminReplicateResyncCancelCmd, 26 | } 27 | 28 | var adminReplicateResyncCmd = cli.Command{ 29 | Name: "resync", 30 | Usage: "resync content to site", 31 | Action: mainAdminReplicateResync, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: adminReplicateResyncSubcommands, 35 | HideHelpCommand: true, 36 | } 37 | 38 | func mainAdminReplicateResync(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminReplicateResyncSubcommands) 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /cmd/admin-replicate.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminReplicateSubcommands = []cli.Command{ 23 | adminReplicateAddCmd, 24 | adminReplicateUpdateCmd, 25 | adminReplicateRemoveCmd, 26 | adminReplicateInfoCmd, 27 | adminReplicateStatusCmd, 28 | adminReplicateResyncCmd, 29 | } 30 | 31 | var adminReplicateCmd = cli.Command{ 32 | Name: "replicate", 33 | Usage: "manage MinIO site replication", 34 | Action: mainAdminReplicate, 35 | Before: setGlobalsFromContext, 36 | Flags: globalFlags, 37 | Subcommands: adminReplicateSubcommands, 38 | HideHelpCommand: true, 39 | } 40 | 41 | func mainAdminReplicate(ctx *cli.Context) error { 42 | commandNotFound(ctx, adminReplicateSubcommands) 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /cmd/admin-scanner.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminScannerSubcommands = []cli.Command{ 23 | adminScannerInfo, 24 | adminScannerTraceCmd, 25 | } 26 | 27 | var adminScannerCmd = cli.Command{ 28 | Name: "scanner", 29 | Usage: "provide MinIO scanner info", 30 | Action: mainAdminScanner, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | Subcommands: adminScannerSubcommands, 34 | HideHelpCommand: true, 35 | } 36 | 37 | // mainAdminScanner is the handle for "mc admin scanner" command. 38 | func mainAdminScanner(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminScannerSubcommands) 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /cmd/admin-service.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminServiceSubcommands = []cli.Command{ 23 | adminServiceRestartCmd, 24 | adminServiceStopCmd, 25 | adminServiceUnfreezeCmd, 26 | adminServiceFreezeCmd, 27 | } 28 | 29 | var adminServiceCmd = cli.Command{ 30 | Name: "service", 31 | Usage: "restart or unfreeze a MinIO cluster", 32 | Action: mainAdminService, 33 | Before: setGlobalsFromContext, 34 | Flags: globalFlags, 35 | HideHelpCommand: true, 36 | Subcommands: adminServiceSubcommands, 37 | } 38 | 39 | // mainAdmin is the handle for "mc admin service" command. 40 | func mainAdminService(ctx *cli.Context) error { 41 | commandNotFound(ctx, adminServiceSubcommands) 42 | return nil 43 | // Sub-commands like "status", "restart" have their own main. 44 | } 45 | -------------------------------------------------------------------------------- /cmd/admin-subnet-health.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "fmt" 22 | "strings" 23 | 24 | "github.com/minio/cli" 25 | "github.com/minio/minio-go/v7/pkg/set" 26 | ) 27 | 28 | var adminSubnetHealthCmd = cli.Command{ 29 | Name: "health", 30 | Usage: "generate MinIO health report for SUBNET", 31 | OnUsageError: onUsageError, 32 | Action: mainSubnetHealth, 33 | Before: setGlobalsFromContext, 34 | Hidden: true, 35 | Flags: supportDiagFlags, // No need to append globalFlags as top level command would add them 36 | CustomHelpTemplate: "This command is deprecated and will be removed in a future release. Use 'mc support diag' instead.\n", 37 | } 38 | 39 | func mainSubnetHealth(ctx *cli.Context) error { 40 | boolValSet := set.CreateStringSet("true", "false") 41 | newCmd := []string{"mc support diag"} 42 | newCmd = append(newCmd, ctx.Args()...) 43 | for _, flg := range ctx.Command.Flags { 44 | flgName := flg.GetName() 45 | if !ctx.IsSet(flgName) { 46 | continue 47 | } 48 | 49 | // replace the deprecated --offline with --airgap 50 | if flgName == "offline" { 51 | flgName = "airgap" 52 | } 53 | 54 | flgStr := "--" + flgName 55 | flgVal := ctx.String(flgName) 56 | if !boolValSet.Contains(flgVal) { 57 | flgStr = fmt.Sprintf("%s \"%s\"", flgStr, flgVal) 58 | } 59 | newCmd = append(newCmd, flgStr) 60 | } 61 | 62 | deprecatedError(strings.Join(newCmd, " ")) 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /cmd/admin-subnet-register.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminSubnetRegisterCmd = cli.Command{ 25 | Name: "register", 26 | Usage: "Register the MinIO Cluster with SUBNET", 27 | OnUsageError: onUsageError, 28 | Action: mainAdminRegister, 29 | Before: setGlobalsFromContext, 30 | Hidden: true, 31 | CustomHelpTemplate: "Please use 'mc support register'", 32 | } 33 | 34 | func mainAdminRegister(_ *cli.Context) error { 35 | deprecatedError("mc support register") 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /cmd/admin-subnet.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var subnetHealthSubcommands = []cli.Command{ 25 | adminSubnetHealthCmd, 26 | adminSubnetRegisterCmd, 27 | } 28 | 29 | var adminSubnetCmd = cli.Command{ 30 | Name: "subnet", 31 | Usage: "Subnet related commands", 32 | Action: mainAdminSubnet, 33 | Before: setGlobalsFromContext, 34 | Flags: globalFlags, 35 | Subcommands: subnetHealthSubcommands, 36 | Hidden: true, 37 | } 38 | 39 | // mainAdminSubnet is the handle for "mc admin subnet" command. 40 | func mainAdminSubnet(_ *cli.Context) error { 41 | deprecatedError("mc support") 42 | return nil 43 | // Sub-commands like "health", "register" have their own main. 44 | } 45 | 46 | func adminHealthCmd() cli.Command { 47 | cmd := adminSubnetHealthCmd 48 | cmd.Hidden = true 49 | return cmd 50 | } 51 | -------------------------------------------------------------------------------- /cmd/admin-tier-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminTierCmd = cli.Command{ 25 | Name: "tier", 26 | Usage: "manage remote tier targets for ILM transition", 27 | Action: mainAdminTier, 28 | Before: setGlobalsFromContext, 29 | Flags: globalFlags, 30 | Hidden: true, 31 | HideHelpCommand: true, 32 | Subcommands: adminTierDepCmds, 33 | } 34 | 35 | // mainAdminTier is the handle for "mc admin tier" command. 36 | func mainAdminTier(_ *cli.Context) error { 37 | deprecatedError("mc ilm tier") 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/admin-top-api.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var adminTopAPIFlags = []cli.Flag{ 25 | cli.StringSliceFlag{ 26 | Name: "name", 27 | Usage: "summarize current calls for matching API name", 28 | }, 29 | cli.StringSliceFlag{ 30 | Name: "path", 31 | Usage: "summarize current API calls only on matching path", 32 | }, 33 | cli.StringSliceFlag{ 34 | Name: "node", 35 | Usage: "summarize current API calls only on matching servers", 36 | }, 37 | cli.BoolFlag{ 38 | Name: "errors, e", 39 | Usage: "summarize current API calls throwing only errors", 40 | }, 41 | } 42 | 43 | var adminTopAPICmd = cli.Command{ 44 | Name: "api", 45 | Usage: "summarize API events on MinIO server in real-time", 46 | Action: mainAdminTopAPI, 47 | OnUsageError: onUsageError, 48 | Before: setGlobalsFromContext, 49 | Flags: append(adminTopAPIFlags, globalFlags...), 50 | Hidden: true, 51 | HideHelpCommand: true, 52 | CustomHelpTemplate: `Please use 'mc support top api' 53 | `, 54 | } 55 | 56 | func mainAdminTopAPI(_ *cli.Context) error { 57 | deprecatedError("mc support top api") 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /cmd/admin-top-locks.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var topLocksFlag = []cli.Flag{ 25 | cli.BoolFlag{ 26 | Name: "stale", 27 | Usage: "list stale locks", 28 | }, 29 | cli.IntFlag{ 30 | Name: "count", 31 | Usage: "number of top locks", 32 | Hidden: true, 33 | Value: 10, 34 | }, 35 | } 36 | 37 | var adminTopLocksCmd = cli.Command{ 38 | Name: "locks", 39 | Usage: "get a list of the 10 oldest locks on a MinIO cluster.", 40 | Before: setGlobalsFromContext, 41 | Action: mainAdminTopLocks, 42 | OnUsageError: onUsageError, 43 | Flags: append(globalFlags, topLocksFlag...), 44 | CustomHelpTemplate: `Please use 'mc support top locks' 45 | `, 46 | } 47 | 48 | func mainAdminTopLocks(_ *cli.Context) error { 49 | deprecatedError("mc support top locks") 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /cmd/admin-top.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminTopSubcommands = []cli.Command{ 23 | adminTopAPICmd, 24 | adminTopLocksCmd, 25 | } 26 | 27 | var adminTopCmd = cli.Command{ 28 | Name: "top", 29 | Usage: "provide top like statistics for MinIO", 30 | Action: mainAdminTop, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | Subcommands: adminTopSubcommands, 34 | HideHelpCommand: true, 35 | } 36 | 37 | // mainAdminTop is the handle for "mc admin top" command. 38 | func mainAdminTop(ctx *cli.Context) error { 39 | commandNotFound(ctx, adminTopSubcommands) 40 | return nil 41 | // Sub-commands like "locks" have their own main. 42 | } 43 | -------------------------------------------------------------------------------- /cmd/admin-user-svcacct.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminUserSvcAcctSubcommands = []cli.Command{ 23 | adminUserSvcAcctAddCmd, 24 | adminUserSvcAcctListCmd, 25 | adminUserSvcAcctRemoveCmd, 26 | adminUserSvcAcctInfoCmd, 27 | adminUserSvcAcctSetCmd, 28 | adminUserSvcAcctEnableCmd, 29 | adminUserSvcAcctDisableCmd, 30 | } 31 | 32 | var adminUserSvcAcctCmd = cli.Command{ 33 | Name: "svcacct", 34 | Usage: "manage service accounts", 35 | Action: mainAdminUserSvcAcct, 36 | Before: setGlobalsFromContext, 37 | Flags: globalFlags, 38 | Subcommands: adminUserSvcAcctSubcommands, 39 | HideHelpCommand: true, 40 | } 41 | 42 | // mainAdminUserSvcAcct is the handle for "mc admin user svcacct" command. 43 | func mainAdminUserSvcAcct(ctx *cli.Context) error { 44 | commandNotFound(ctx, adminUserSvcAcctSubcommands) 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /cmd/admin-user.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var adminUserSubcommands = []cli.Command{ 23 | adminUserAddCmd, 24 | adminUserDisableCmd, 25 | adminUserEnableCmd, 26 | adminUserRemoveCmd, 27 | adminUserListCmd, 28 | adminUserInfoCmd, 29 | adminUserPolicyCmd, 30 | adminUserSvcAcctCmd, 31 | adminUserSTSAcctCmd, 32 | } 33 | 34 | var adminUserCmd = cli.Command{ 35 | Name: "user", 36 | Usage: "manage users", 37 | Action: mainAdminUser, 38 | Before: setGlobalsFromContext, 39 | Flags: globalFlags, 40 | Subcommands: adminUserSubcommands, 41 | HideHelpCommand: true, 42 | } 43 | 44 | // mainAdminUser is the handle for "mc admin config" command. 45 | func mainAdminUser(ctx *cli.Context) error { 46 | commandNotFound(ctx, adminUserSubcommands) 47 | return nil 48 | // Sub-commands like "get", "set" have their own main. 49 | } 50 | -------------------------------------------------------------------------------- /cmd/arg-kvs.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | // argKV - is a shorthand of each key value. 21 | type argKV struct { 22 | Key string `json:"key"` 23 | Value string `json:"value"` 24 | } 25 | 26 | // argKVS - is a shorthand for some wrapper functions 27 | // to operate on list of key values. 28 | type argKVS []argKV 29 | 30 | // Empty - return if kv is empty 31 | func (kvs argKVS) Empty() bool { 32 | return len(kvs) == 0 33 | } 34 | 35 | // Set sets a value, if not sets a default value. 36 | func (kvs *argKVS) Set(key, value string) { 37 | for i, kv := range *kvs { 38 | if kv.Key == key { 39 | (*kvs)[i] = argKV{ 40 | Key: key, 41 | Value: value, 42 | } 43 | return 44 | } 45 | } 46 | *kvs = append(*kvs, argKV{ 47 | Key: key, 48 | Value: value, 49 | }) 50 | } 51 | 52 | // Get - returns the value of a key, if not found returns empty. 53 | func (kvs argKVS) Get(key string) string { 54 | v, ok := kvs.Lookup(key) 55 | if ok { 56 | return v 57 | } 58 | return "" 59 | } 60 | 61 | // Lookup - lookup a key in a list of argKVS 62 | func (kvs argKVS) Lookup(key string) (string, bool) { 63 | for _, kv := range kvs { 64 | if kv.Key == key { 65 | return kv.Value, true 66 | } 67 | } 68 | return "", false 69 | } 70 | -------------------------------------------------------------------------------- /cmd/auto-complete_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "fmt" 22 | "testing" 23 | 24 | "github.com/minio/cli" 25 | ) 26 | 27 | func TestAutoCompletionCompletness(t *testing.T) { 28 | var checkCompletion func(cmd cli.Command, cmdPath string) error 29 | 30 | checkCompletion = func(cmd cli.Command, cmdPath string) error { 31 | if cmd.Subcommands != nil { 32 | for _, subCmd := range cmd.Subcommands { 33 | if cmd.Hidden { 34 | continue 35 | } 36 | err := checkCompletion(subCmd, cmdPath+"/"+subCmd.Name) 37 | if err != nil { 38 | return err 39 | } 40 | } 41 | return nil 42 | } 43 | _, ok := completeCmds[cmdPath] 44 | if !ok && !cmd.Hidden { 45 | return fmt.Errorf("Completion for `%s` not found", cmdPath) 46 | } 47 | return nil 48 | } 49 | 50 | for _, cmd := range appCmds { 51 | if cmd.Hidden { 52 | continue 53 | } 54 | err := checkCompletion(cmd, "/"+cmd.Name) 55 | if err != nil { 56 | t.Fatalf("Missing completion function: %v", err) 57 | } 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /cmd/batch-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var batchSubcommands = []cli.Command{ 23 | batchGenerateCmd, 24 | batchStartCmd, 25 | batchListCmd, 26 | batchStatusCmd, 27 | batchDescribeCmd, 28 | // batchSuspendResumeCmd, 29 | batchCancelCmd, 30 | } 31 | 32 | var batchCmd = cli.Command{ 33 | Name: "batch", 34 | Usage: "manage batch jobs", 35 | Action: mainBatch, 36 | Before: setGlobalsFromContext, 37 | Flags: globalFlags, 38 | Subcommands: batchSubcommands, 39 | HideHelpCommand: true, 40 | } 41 | 42 | // mainBatch is the handle for "mc batch" command. 43 | func mainBatch(ctx *cli.Context) error { 44 | commandNotFound(ctx, batchSubcommands) 45 | return nil 46 | // Sub-commands like "generate", "list", "info" have their own main. 47 | } 48 | -------------------------------------------------------------------------------- /cmd/build-constants.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | var ( 21 | // Version - version time.RFC3339. 22 | Version = "DEVELOPMENT.GOGET" 23 | // ReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ. 24 | ReleaseTag = "DEVELOPMENT.GOGET" 25 | // CommitID - latest commit id. 26 | CommitID = "DEVELOPMENT.GOGET" 27 | // ShortCommitID - first 12 characters from CommitID. 28 | ShortCommitID = CommitID[:12] 29 | // CopyrightYear - dynamic value of the copyright end year 30 | CopyrightYear = "0000" 31 | ) 32 | -------------------------------------------------------------------------------- /cmd/cat_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "bytes" 22 | "io" 23 | "testing" 24 | ) 25 | 26 | func TestPrettyStdout(t *testing.T) { 27 | testCases := []struct { 28 | originText string 29 | prettyText string 30 | }{ 31 | {"", ""}, 32 | {"text", "text"}, 33 | // Check with new lines 34 | {"text\r\n", "text\r\n"}, 35 | {"\ttext\n", "\ttext\n"}, 36 | // Print some unicode characters and check if it is not altered 37 | {"добро пожаловать.", "добро пожаловать."}, 38 | // Print colored text 39 | {"\x1b\x5b\x33\x31\x6d\x66\x61\x69\x6c", "^?[31mfail"}, 40 | // Print clear screen 41 | {"\x1b\x63", "^?c"}, 42 | // Random data 43 | {"\x3d\xef\xd2\xb5", "=�ҵ"}, 44 | } 45 | 46 | for i, testCase := range testCases { 47 | reader := bytes.NewReader([]byte(testCase.originText)) 48 | fakeStdout := bytes.NewBuffer([]byte("")) 49 | n, err := io.Copy(newPrettyStdout(fakeStdout), reader) 50 | if err != nil { 51 | t.Fatalf("Test %d: %v\n", i+1, err) 52 | } 53 | if int(n) != len(testCase.originText) { 54 | t.Fatalf("Test %d: copy error\n", i+1) 55 | } 56 | prettyText, err := io.ReadAll(fakeStdout) 57 | if err != nil { 58 | t.Fatalf("Test %d: %v", i+1, err) 59 | } 60 | if string(prettyText) != testCase.prettyText { 61 | t.Fatalf("Test %d: expected output `%s`, found output `%s`", i+1, testCase.prettyText, string(prettyText)) 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /cmd/cli_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/minio/cli" 24 | ) 25 | 26 | func TestCLIOnUsageError(t *testing.T) { 27 | var checkOnUsageError func(cli.Command, string) 28 | checkOnUsageError = func(cmd cli.Command, parentCmd string) { 29 | if cmd.Subcommands != nil { 30 | for _, subCmd := range cmd.Subcommands { 31 | if cmd.Hidden { 32 | continue 33 | } 34 | checkOnUsageError(subCmd, parentCmd+" "+cmd.Name) 35 | } 36 | return 37 | } 38 | if !cmd.Hidden && cmd.OnUsageError == nil { 39 | t.Errorf("On usage error for `%s` not found", parentCmd+" "+cmd.Name) 40 | } 41 | } 42 | 43 | for _, cmd := range appCmds { 44 | if cmd.Hidden { 45 | continue 46 | } 47 | checkOnUsageError(cmd, "") 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /cmd/client-admin_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // # This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "bytes" 22 | "io" 23 | "net/http" 24 | "strconv" 25 | ) 26 | 27 | type adminPolicyHandler struct { 28 | endpoint string 29 | name string 30 | policy []byte 31 | } 32 | 33 | func (h adminPolicyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { 34 | if ak := r.Header.Get("Authorization"); len(ak) == 0 { 35 | w.WriteHeader(http.StatusForbidden) 36 | return 37 | } 38 | switch r.Method { 39 | case "PUT": 40 | length, e := strconv.Atoi(r.Header.Get("Content-Length")) 41 | if e != nil { 42 | w.WriteHeader(http.StatusBadRequest) 43 | return 44 | } 45 | 46 | var buffer bytes.Buffer 47 | if _, e = io.CopyN(&buffer, r.Body, int64(length)); e != nil { 48 | w.WriteHeader(http.StatusInternalServerError) 49 | return 50 | } 51 | 52 | if len(h.policy) != buffer.Len() { 53 | w.WriteHeader(http.StatusBadRequest) 54 | return 55 | } 56 | 57 | w.Header().Set("Content-Length", "0") 58 | w.WriteHeader(http.StatusOK) 59 | 60 | default: 61 | w.WriteHeader(http.StatusForbidden) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /cmd/client-fs_other.go: -------------------------------------------------------------------------------- 1 | //go:build solaris || openbsd 2 | // +build solaris openbsd 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package cmd 22 | 23 | import "github.com/rjeczalik/notify" 24 | 25 | var ( 26 | // EventTypePut contains the notify events that will cause a put (writer) 27 | EventTypePut = []notify.Event{notify.Create, notify.Write, notify.Rename} 28 | // EventTypeDelete contains the notify events that will cause a delete (remove) 29 | EventTypeDelete = []notify.Event{notify.Remove} 30 | // EventTypeGet contains the notify events that will cause a get (read) 31 | EventTypeGet = []notify.Event{} // On macOS, FreeBSD, Solaris this is not available. 32 | ) 33 | 34 | // IsGetEvent checks if the event return is a get event. 35 | func IsGetEvent(event notify.Event) bool { 36 | return false 37 | } 38 | 39 | // IsPutEvent checks if the event returned is a put event 40 | func IsPutEvent(event notify.Event) bool { 41 | for _, ev := range EventTypePut { 42 | if event&ev != 0 { 43 | return true 44 | } 45 | } 46 | return false 47 | } 48 | 49 | // IsDeleteEvent checks if the event returned is a delete event 50 | func IsDeleteEvent(event notify.Event) bool { 51 | return event¬ify.Remove != 0 52 | } 53 | 54 | // getAtllXAttrs returns the extended attributes for a file if supported 55 | // by the OS 56 | func getAllXattrs(path string) (map[string]string, error) { 57 | return nil, nil 58 | } 59 | -------------------------------------------------------------------------------- /cmd/client-fs_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package cmd 22 | 23 | import "github.com/rjeczalik/notify" 24 | 25 | var ( 26 | // EventTypePut contains the notify events that will cause a put (writer) 27 | EventTypePut = []notify.Event{notify.Create, notify.Write, notify.Rename, notify.FileNotifyChangeFileName, notify.FileNotifyChangeDirName} 28 | // EventTypeDelete contains the notify events that will cause a delete (remove) 29 | EventTypeDelete = []notify.Event{notify.Remove} 30 | // EventTypeGet contains the notify events that will cause a get (read) 31 | EventTypeGet = []notify.Event{notify.FileNotifyChangeLastAccess} 32 | ) 33 | 34 | // IsGetEvent checks if the event return is a get event. 35 | func IsGetEvent(event notify.Event) bool { 36 | return event¬ify.FileNotifyChangeLastAccess != 0 37 | } 38 | 39 | // IsPutEvent checks if the event returned is a put event 40 | func IsPutEvent(event notify.Event) bool { 41 | if event¬ify.FileActionRenamedOldName != 0 { 42 | return false 43 | } 44 | for _, ev := range EventTypePut { 45 | if event&ev != 0 { 46 | return true 47 | } 48 | } 49 | return false 50 | } 51 | 52 | // IsDeleteEvent checks if the event returned is a delete event 53 | func IsDeleteEvent(event notify.Event) bool { 54 | return event¬ify.Remove != 0 || event¬ify.FileActionRenamedOldName != 0 55 | } 56 | 57 | // getAllXattrs returns the extended attributes for a file if supported 58 | // by the OS 59 | func getAllXattrs(_ string) (map[string]string, error) { 60 | return nil, nil 61 | } 62 | -------------------------------------------------------------------------------- /cmd/cors-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var corsSubcommands = []cli.Command{ 23 | corsSetCmd, 24 | corsGetCmd, 25 | corsRemoveCmd, 26 | } 27 | 28 | var corsCmd = cli.Command{ 29 | Name: "cors", 30 | Usage: "manage bucket CORS configuration", 31 | Action: mainCors, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: corsSubcommands, 35 | } 36 | 37 | func mainCors(ctx *cli.Context) error { 38 | commandNotFound(ctx, corsSubcommands) 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /cmd/encrypt-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var encryptSubcommands = []cli.Command{ 23 | encryptSetCmd, 24 | encryptClearCmd, 25 | encryptInfoCmd, 26 | } 27 | 28 | var encryptCmd = cli.Command{ 29 | Name: "encrypt", 30 | Usage: "manage bucket encryption config", 31 | HideHelpCommand: true, 32 | Action: mainEncrypt, 33 | Before: setGlobalsFromContext, 34 | Flags: globalFlags, 35 | Subcommands: encryptSubcommands, 36 | } 37 | 38 | // mainEncrypt is the handle for "mc encrypt" command. 39 | func mainEncrypt(ctx *cli.Context) error { 40 | commandNotFound(ctx, encryptSubcommands) 41 | return nil 42 | // Sub-commands like "info", "set", "clear" have their own main. 43 | } 44 | -------------------------------------------------------------------------------- /cmd/event-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var eventFlags = []cli.Flag{} 23 | 24 | var eventSubcommands = []cli.Command{ 25 | eventAddCmd, 26 | eventRemoveCmd, 27 | eventListCmd, 28 | } 29 | 30 | var eventCmd = cli.Command{ 31 | Name: "event", 32 | Usage: "manage object notifications", 33 | HideHelpCommand: true, 34 | Action: mainEvent, 35 | Before: setGlobalsFromContext, 36 | Flags: append(eventFlags, globalFlags...), 37 | Subcommands: eventSubcommands, 38 | } 39 | 40 | // mainEvent is the handle for "mc event" command. 41 | func mainEvent(ctx *cli.Context) error { 42 | commandNotFound(ctx, eventSubcommands) 43 | return nil 44 | // Sub-commands like "add", "remove", "list" have their own main. 45 | } 46 | -------------------------------------------------------------------------------- /cmd/fs-pathutils_nix.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | // +build !windows 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package cmd 22 | 23 | func normalizePath(path string) string { 24 | return path 25 | } 26 | -------------------------------------------------------------------------------- /cmd/fs-pathutils_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package cmd 22 | 23 | import ( 24 | "path/filepath" 25 | "strings" 26 | "syscall" 27 | ) 28 | 29 | func normalizePath(path string) string { 30 | if filepath.VolumeName(path) == "" && strings.HasPrefix(path, "\\") { 31 | var err error 32 | path, err = syscall.FullPath(path) 33 | if err != nil { 34 | panic(err) 35 | } 36 | } 37 | return path 38 | } 39 | -------------------------------------------------------------------------------- /cmd/health.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "time" 21 | 22 | // HealthReportInfo - interface to be implemented by health report schema struct 23 | type HealthReportInfo interface { 24 | GetTimestamp() time.Time 25 | GetStatus() string 26 | GetError() string 27 | message 28 | } 29 | 30 | // HealthReportHeader - Header of the subnet health report 31 | // expected to generate JSON output of the form 32 | // {"subnet":{"health":{"version":"v1"}}} 33 | type HealthReportHeader struct { 34 | Subnet Health `json:"subnet"` 35 | } 36 | 37 | // Health - intermediate struct for subnet health header 38 | // Just used to achieve the JSON structure we want 39 | type Health struct { 40 | Health SchemaVersion `json:"health"` 41 | } 42 | 43 | // SchemaVersion - version of the health report schema 44 | type SchemaVersion struct { 45 | Version string `json:"version"` 46 | } 47 | -------------------------------------------------------------------------------- /cmd/idp-ldap-accesskey-disable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var idpLdapAccesskeyDisableCmd = cli.Command{ 25 | Name: "disable", 26 | Usage: "disable an access key", 27 | Action: mainIDPLdapAccesskeyDisable, 28 | Before: setGlobalsFromContext, 29 | Flags: globalFlags, 30 | OnUsageError: onUsageError, 31 | CustomHelpTemplate: `NAME: 32 | {{.HelpName}} - {{.Usage}} 33 | 34 | USAGE: 35 | {{.HelpName}} [FLAGS] [TARGET] 36 | 37 | FLAGS: 38 | {{range .VisibleFlags}}{{.}} 39 | {{end}} 40 | EXAMPLES: 41 | 1. Disable LDAP access key 42 | {{.Prompt}} {{.HelpName}} myminio myaccesskey 43 | `, 44 | } 45 | 46 | func mainIDPLdapAccesskeyDisable(ctx *cli.Context) error { 47 | return enableDisableAccesskey(ctx, false) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/idp-ldap-accesskey-info.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "strings" 22 | 23 | "github.com/charmbracelet/lipgloss" 24 | "github.com/minio/cli" 25 | ) 26 | 27 | var idpLdapAccesskeyInfoCmd = cli.Command{ 28 | Name: "info", 29 | Usage: "info about given access key pairs for LDAP", 30 | Action: mainIDPLdapAccesskeyInfo, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | OnUsageError: onUsageError, 34 | CustomHelpTemplate: `NAME: 35 | {{.HelpName}} - {{.Usage}} 36 | 37 | USAGE: 38 | {{.HelpName}} [FLAGS] TARGET ACCESSKEY [ACCESSKEY...] 39 | 40 | FLAGS: 41 | {{range .VisibleFlags}}{{.}} 42 | {{end}} 43 | EXAMPLES: 44 | 1. Get info for the access key "testkey" 45 | {{.Prompt}} {{.HelpName}} local/ testkey 46 | 2. Get info for the access keys "testkey" and "testkey2" 47 | {{.Prompt}} {{.HelpName}} local/ testkey testkey2 48 | `, 49 | } 50 | 51 | type ldapAccessKeyInfo struct { 52 | Username string `json:"username,omitempty"` 53 | } 54 | 55 | func (l ldapAccessKeyInfo) String() string { 56 | labelStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#04B575")) // green 57 | o := strings.Builder{} 58 | o.WriteString(labelStyle.Render("Username: ")) 59 | o.WriteString(l.Username) 60 | return o.String() 61 | } 62 | 63 | func mainIDPLdapAccesskeyInfo(ctx *cli.Context) error { 64 | return commonAccesskeyInfo(ctx) 65 | } 66 | -------------------------------------------------------------------------------- /cmd/idp-ldap-accesskey.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var idpLdapAccesskeySubcommands = []cli.Command{ 23 | idpLdapAccesskeyListCmd, 24 | idpLdapAccesskeyRemoveCmd, 25 | idpLdapAccesskeyInfoCmd, 26 | idpLdapAccesskeyCreateCmd, 27 | idpLdapAccesskeyCreateWithLoginCmd, 28 | idpLdapAccesskeyEditCmd, 29 | idpLdapAccesskeyEnableCmd, 30 | idpLdapAccesskeyDisableCmd, 31 | idpLdapAccesskeySTSRevokeCmd, 32 | } 33 | 34 | var idpLdapAccesskeyCmd = cli.Command{ 35 | Name: "accesskey", 36 | Usage: "manage LDAP access key pairs", 37 | Action: mainIDPLDAPAccesskey, 38 | Before: setGlobalsFromContext, 39 | Flags: globalFlags, 40 | Subcommands: idpLdapAccesskeySubcommands, 41 | HideHelpCommand: true, 42 | } 43 | 44 | func mainIDPLDAPAccesskey(ctx *cli.Context) error { 45 | commandNotFound(ctx, idpLdapAccesskeySubcommands) 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /cmd/idp-ldap-policy.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var idpLdapPolicySubcommands = []cli.Command{ 23 | idpLdapPolicyAttachCmd, 24 | idpLdapPolicyDetachCmd, 25 | idpLdapPolicyEntitiesCmd, 26 | } 27 | 28 | var idpLdapPolicyCmd = cli.Command{ 29 | Name: "policy", 30 | Usage: "manage policy assignments for LDAP", 31 | Action: mainIDPLDAPPolicy, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: idpLdapPolicySubcommands, 35 | HideHelpCommand: true, 36 | } 37 | 38 | func mainIDPLDAPPolicy(ctx *cli.Context) error { 39 | commandNotFound(ctx, idpLdapPolicySubcommands) 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /cmd/idp-ldap.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var ( 23 | idpLdapSubcommands = []cli.Command{ 24 | idpLdapAddCmd, 25 | idpLdapUpdateCmd, 26 | idpLdapRemoveCmd, 27 | idpLdapListCmd, 28 | idpLdapInfoCmd, 29 | idpLdapEnableCmd, 30 | idpLdapDisableCmd, 31 | idpLdapPolicyCmd, 32 | idpLdapAccesskeyCmd, 33 | } 34 | idpLdapCmd = cli.Command{ 35 | Name: "ldap", 36 | Usage: "manage Ldap IDP server configuration", 37 | Action: mainIDPLdap, 38 | Before: setGlobalsFromContext, 39 | Flags: globalFlags, 40 | Subcommands: idpLdapSubcommands, 41 | HideHelpCommand: true, 42 | } 43 | ) 44 | 45 | func mainIDPLdap(ctx *cli.Context) error { 46 | commandNotFound(ctx, idpLdapSubcommands) 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /cmd/idp-openid-accesskey-disable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var idpOpenidAccesskeyDisableCmd = cli.Command{ 25 | Name: "disable", 26 | Usage: "disable an access key", 27 | Action: mainIDPOpenIDAccesskeyDisable, 28 | Before: setGlobalsFromContext, 29 | Flags: globalFlags, 30 | OnUsageError: onUsageError, 31 | CustomHelpTemplate: `NAME: 32 | {{.HelpName}} - {{.Usage}} 33 | 34 | USAGE: 35 | {{.HelpName}} [FLAGS] [TARGET] 36 | 37 | FLAGS: 38 | {{range .VisibleFlags}}{{.}} 39 | {{end}} 40 | EXAMPLES: 41 | 1. Disable LDAP access key 42 | {{.Prompt}} {{.HelpName}} myminio myaccesskey 43 | `, 44 | } 45 | 46 | func mainIDPOpenIDAccesskeyDisable(ctx *cli.Context) error { 47 | return enableDisableAccesskey(ctx, false) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/idp-openid-accesskey-enable.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2024 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var idpOpenidAccesskeyEnableCmd = cli.Command{ 25 | Name: "enable", 26 | Usage: "enable an access key", 27 | Action: mainIDPOpenIDAccesskeyEnable, 28 | Before: setGlobalsFromContext, 29 | Flags: globalFlags, 30 | OnUsageError: onUsageError, 31 | CustomHelpTemplate: `NAME: 32 | {{.HelpName}} - {{.Usage}} 33 | 34 | USAGE: 35 | {{.HelpName}} [FLAGS] [TARGET] 36 | 37 | FLAGS: 38 | {{range .VisibleFlags}}{{.}} 39 | {{end}} 40 | EXAMPLES: 41 | 1. Enable LDAP access key 42 | {{.Prompt}} {{.HelpName}} myminio myaccesskey 43 | `, 44 | } 45 | 46 | func mainIDPOpenIDAccesskeyEnable(ctx *cli.Context) error { 47 | return enableDisableAccesskey(ctx, true) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/idp-openid-accesskey-remove.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var idpOpenidAccesskeyRemoveCmd = cli.Command{ 25 | Name: "remove", 26 | ShortName: "rm", 27 | Usage: "delete access key pairs for OpenID", 28 | Action: mainIDPOpenIDAccesskeyRemove, 29 | Before: setGlobalsFromContext, 30 | Flags: globalFlags, 31 | OnUsageError: onUsageError, 32 | CustomHelpTemplate: `NAME: 33 | {{.HelpName}} - {{.Usage}} 34 | 35 | USAGE: 36 | {{.HelpName}} [FLAGS] TARGET ACCESSKEY 37 | 38 | FLAGS: 39 | {{range .VisibleFlags}}{{.}} 40 | {{end}} 41 | EXAMPLES: 42 | 1. Remove the access key "testkey" from local server 43 | {{.Prompt}} {{.HelpName}} local/ testkey 44 | `, 45 | } 46 | 47 | func mainIDPOpenIDAccesskeyRemove(ctx *cli.Context) error { 48 | return commonAccesskeyRemove(ctx) 49 | } 50 | -------------------------------------------------------------------------------- /cmd/idp-openid-accesskey.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var idpOpenidAccesskeySubcommands = []cli.Command{ 23 | idpOpenidAccesskeyListCmd, 24 | idpOpenidAccesskeyRemoveCmd, 25 | idpOpenidAccesskeyInfoCmd, 26 | idpOpenidAccesskeyEditCmd, 27 | idpOpenidAccesskeyEnableCmd, 28 | idpOpenidAccesskeyDisableCmd, 29 | } 30 | 31 | var idpOpenIDAccesskeyCmd = cli.Command{ 32 | Name: "accesskey", 33 | Usage: "manage OpenID access key pairs", 34 | Action: mainIDPOpenIDAccesskey, 35 | Before: setGlobalsFromContext, 36 | Flags: globalFlags, 37 | Subcommands: idpOpenidAccesskeySubcommands, 38 | HideHelpCommand: true, 39 | } 40 | 41 | func mainIDPOpenIDAccesskey(ctx *cli.Context) error { 42 | commandNotFound(ctx, idpOpenidAccesskeySubcommands) 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /cmd/idp-openid.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var ( 23 | idpOpenidSubcommands = []cli.Command{ 24 | idpOpenidAddCmd, 25 | idpOpenidUpdateCmd, 26 | idpOpenidRemoveCmd, 27 | idpOpenidListCmd, 28 | idpOpenidInfoCmd, 29 | idpOpenidEnableCmd, 30 | idpOpenidDisableCmd, 31 | idpOpenIDAccesskeyCmd, 32 | // TODO: idpOpenidPolicyCmd, 33 | } 34 | idpOpenidCmd = cli.Command{ 35 | Name: "openid", 36 | Usage: "manage OpenID IDP server configuration", 37 | Action: mainIDPOpenID, 38 | Before: setGlobalsFromContext, 39 | Flags: globalFlags, 40 | Subcommands: idpOpenidSubcommands, 41 | HideHelpCommand: true, 42 | } 43 | ) 44 | 45 | func mainIDPOpenID(ctx *cli.Context) error { 46 | commandNotFound(ctx, idpOpenidSubcommands) 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /cmd/idp.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var idpSubcommands = []cli.Command{ 23 | idpOpenidCmd, 24 | idpLdapCmd, 25 | } 26 | 27 | var idpCmd = cli.Command{ 28 | Name: "idp", 29 | Usage: "manage MinIO IDentity Provider server configuration", 30 | Action: mainIDP, 31 | Before: setGlobalsFromContext, 32 | Flags: globalFlags, 33 | Subcommands: idpSubcommands, 34 | HideHelpCommand: true, 35 | } 36 | 37 | func mainIDP(ctx *cli.Context) error { 38 | commandNotFound(ctx, idpSubcommands) 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /cmd/ilm-rule-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var ilmRuleSubcommands = []cli.Command{ 23 | ilmAddCmd, 24 | ilmEditCmd, 25 | ilmLsCmd, 26 | ilmRmCmd, 27 | ilmExportCmd, 28 | ilmImportCmd, 29 | } 30 | 31 | var ilmRuleCmd = cli.Command{ 32 | Name: "rule", 33 | Usage: "manage bucket lifecycle rules", 34 | Before: setGlobalsFromContext, 35 | Action: mainILMRule, 36 | Subcommands: ilmRuleSubcommands, 37 | Flags: globalFlags, 38 | HideHelpCommand: true, 39 | } 40 | 41 | func mainILMRule(ctx *cli.Context) error { 42 | commandNotFound(ctx, ilmRuleSubcommands) 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /cmd/ilm-tier-check.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var ilmTierCheckCmd = cli.Command{ 23 | Name: "check", 24 | Usage: "validate remote tier configuration", 25 | Action: mainAdminTierVerify, 26 | OnUsageError: onUsageError, 27 | Before: setGlobalsFromContext, 28 | Flags: globalFlags, 29 | CustomHelpTemplate: `NAME: 30 | {{.HelpName}} - {{.Usage}} 31 | 32 | USAGE: 33 | {{.HelpName}} TARGET NAME 34 | 35 | NAME: 36 | Name of remote tier target. e.g WARM-TIER 37 | 38 | FLAGS: 39 | {{range .VisibleFlags}}{{.}} 40 | {{end}} 41 | EXAMPLES: 42 | 1. Validate a tier config given by name. 43 | {{.Prompt}} {{.HelpName}} myminio WARM-TIER 44 | `, 45 | } 46 | -------------------------------------------------------------------------------- /cmd/ilm-tier-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var ilmTierSubcommands = []cli.Command{ 23 | adminTierInfoCmd, 24 | adminTierListCmd, 25 | adminTierAddCmd, 26 | adminTierEditCmd, 27 | ilmTierUpdateCmd, 28 | adminTierVerifyCmd, 29 | ilmTierCheckCmd, 30 | adminTierRmCmd, 31 | } 32 | 33 | var ilmTierCmd = cli.Command{ 34 | Name: "tier", 35 | Usage: "manage remote tiers", 36 | Action: mainILMTier, 37 | Before: setGlobalsFromContext, 38 | Flags: globalFlags, 39 | Subcommands: ilmTierSubcommands, 40 | HideHelpCommand: true, 41 | } 42 | 43 | func mainILMTier(ctx *cli.Context) error { 44 | commandNotFound(ctx, ilmTierSubcommands) 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /cmd/ilm-tier-update.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var ilmTierUpdateCmd = cli.Command{ 23 | Name: "update", 24 | Usage: "update an existing remote tier configuration", 25 | Action: mainAdminTierEdit, 26 | OnUsageError: onUsageError, 27 | Before: setGlobalsFromContext, 28 | Flags: append(globalFlags, adminTierEditFlags...), 29 | CustomHelpTemplate: `NAME: 30 | {{.HelpName}} - {{.Usage}} 31 | 32 | USAGE: 33 | {{.HelpName}} ALIAS NAME 34 | 35 | NAME: 36 | Name of remote tier. e.g WARM-TIER 37 | 38 | FLAGS: 39 | {{range .VisibleFlags}}{{.}} 40 | {{end}} 41 | EXAMPLES: 42 | 1. Update credentials for an existing Azure Blob Storage remote tier: 43 | {{.Prompt}} {{.HelpName}} myminio AZTIER --account-key ACCOUNT-KEY 44 | 45 | 2. Update credentials for an existing AWS S3 compatible remote tier: 46 | {{.Prompt}} {{.HelpName}} myminio S3TIER --access-key ACCESS-KEY --secret-key SECRET-KEY 47 | 48 | 3. Update credentials for an existing Google Cloud Storage remote tier: 49 | {{.Prompt}} {{.HelpName}} myminio GCSTIER --credentials-file /path/to/credentials.json 50 | `, 51 | } 52 | -------------------------------------------------------------------------------- /cmd/ilm/utils_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package ilm 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/minio/minio-go/v7/pkg/lifecycle" 24 | ) 25 | 26 | func TestILMTags(t *testing.T) { 27 | tests := []struct { 28 | rule lifecycle.Rule 29 | expected string 30 | }{ 31 | { 32 | rule: lifecycle.Rule{ 33 | ID: "one-tag", 34 | RuleFilter: lifecycle.Filter{ 35 | Tag: lifecycle.Tag{ 36 | Key: "key1", 37 | Value: "val1", 38 | }, 39 | }, 40 | }, 41 | expected: "key1=val1", 42 | }, 43 | { 44 | rule: lifecycle.Rule{ 45 | ID: "many-tags", 46 | RuleFilter: lifecycle.Filter{ 47 | And: lifecycle.And{ 48 | Tags: []lifecycle.Tag{ 49 | { 50 | Key: "key1", 51 | Value: "val1", 52 | }, 53 | { 54 | Key: "key2", 55 | Value: "val2", 56 | }, 57 | { 58 | Key: "key3", 59 | Value: "val3", 60 | }, 61 | }, 62 | }, 63 | }, 64 | }, 65 | expected: "key1=val1&key2=val2&key3=val3", 66 | }, 67 | } 68 | for i, test := range tests { 69 | if got := getTags(test.rule); got != test.expected { 70 | t.Fatalf("%d: Expected %s but got %s", i+1, test.expected, got) 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /cmd/license.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var licenseSubcommands = []cli.Command{ 25 | licenseRegisterCmd, 26 | licenseInfoCmd, 27 | licenseUpdateCmd, 28 | licenseUnregisterCmd, 29 | } 30 | 31 | var licenseCmd = cli.Command{ 32 | Name: "license", 33 | Usage: "license related commands", 34 | Action: mainlicense, 35 | Before: setGlobalsFromContext, 36 | Flags: globalFlags, 37 | Subcommands: licenseSubcommands, 38 | HideHelpCommand: true, 39 | } 40 | 41 | // mainlicense is the handle for "mc license" command. 42 | func mainlicense(ctx *cli.Context) error { 43 | commandNotFound(ctx, licenseSubcommands) 44 | return nil 45 | // Sub-commands like "register", "info" have their own main. 46 | } 47 | -------------------------------------------------------------------------------- /cmd/ls_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | -------------------------------------------------------------------------------- /cmd/pipe_supported.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | 3 | // Copyright (c) 2015-2023 MinIO, Inc. 4 | // 5 | // This file is part of MinIO Object Storage stack 6 | // 7 | // This program is free software: you can redistribute it and/or modify 8 | // it under the terms of the GNU Affero General Public License as published by 9 | // the Free Software Foundation, either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU Affero General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU Affero General Public License 18 | // along with this program. If not, see . 19 | 20 | package cmd 21 | 22 | import ( 23 | "fmt" 24 | "os" 25 | "strconv" 26 | "strings" 27 | 28 | "golang.org/x/sys/unix" 29 | ) 30 | 31 | const pipeMaxSizeProcFile = "/proc/sys/fs/pipe-max-size" 32 | 33 | func setPipeSize(fd uintptr, size int) error { 34 | _, err := unix.FcntlInt(fd, unix.F_SETPIPE_SZ, size) 35 | return err 36 | } 37 | 38 | func getConfiguredMaxPipeSize() (int, error) { 39 | b, err := os.ReadFile(pipeMaxSizeProcFile) 40 | if err != nil { 41 | return 0, err 42 | } 43 | maxSize, err := strconv.ParseInt(strings.TrimSpace(string(b)), 10, 64) 44 | if err != nil { 45 | return 0, fmt.Errorf("error parsing %s content: %v", pipeMaxSizeProcFile, err) 46 | } 47 | return int(maxSize), nil 48 | } 49 | 50 | // increasePipeBufferSize attempts to increase the pipe size to the the input value 51 | // or system-max, if the provided size is 0 or less. 52 | func increasePipeBufferSize(f *os.File, desiredPipeSize int) error { 53 | fd := f.Fd() 54 | 55 | if desiredPipeSize <= 0 { 56 | maxSize, err := getConfiguredMaxPipeSize() 57 | if err == nil { 58 | setPipeSize(fd, maxSize) 59 | return nil 60 | } 61 | } 62 | 63 | return setPipeSize(fd, desiredPipeSize) 64 | } 65 | -------------------------------------------------------------------------------- /cmd/pipe_unsupported.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // Copyright (c) 2015-2023 MinIO, Inc. 4 | // 5 | // This file is part of MinIO Object Storage stack 6 | // 7 | // This program is free software: you can redistribute it and/or modify 8 | // it under the terms of the GNU Affero General Public License as published by 9 | // the Free Software Foundation, either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU Affero General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU Affero General Public License 18 | // along with this program. If not, see . 19 | 20 | package cmd 21 | 22 | import "os" 23 | 24 | func increasePipeBufferSize(_ *os.File, _ int) error { 25 | // this is not supported on non-Linux platforms. 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /cmd/policy-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | "github.com/minio/pkg/v3/console" 23 | ) 24 | 25 | var policyFlags = []cli.Flag{ 26 | cli.BoolFlag{ 27 | Name: "recursive, r", 28 | Usage: "list recursively", 29 | }, 30 | } 31 | 32 | // Manage anonymous access to buckets and objects. 33 | var policyCmd = cli.Command{ 34 | Name: "policy", 35 | Usage: "manage anonymous access to buckets and objects", 36 | Action: mainPolicy, 37 | Hidden: true, 38 | OnUsageError: onUsageError, 39 | Before: setGlobalsFromContext, 40 | Flags: append(policyFlags, globalFlags...), 41 | CustomHelpTemplate: `Please use 'mc anonymous' 42 | `, 43 | } 44 | 45 | func mainPolicy(_ *cli.Context) error { 46 | console.Infoln("Please use 'mc anonymous'") 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /cmd/pretty-table_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "testing" 21 | 22 | // TestPrettyTable - testing the behavior of the pretty table module 23 | func TestPrettyTable(t *testing.T) { 24 | testCases := []struct { 25 | sep string 26 | tf []Field 27 | contents []string 28 | expectedRow string 29 | }{ 30 | // Test 1: empty parameter, empty table 31 | {"", []Field{}, []string{}, ""}, 32 | // Test 2: one field, without any specific customization 33 | {"", []Field{{"", -1}}, []string{"abcd"}, "abcd"}, 34 | // Test 3: one field, without 5 chars len 35 | {"", []Field{{"", 5}}, []string{"my-long-field"}, "my..."}, 36 | // Test 4: one separator, one content 37 | {" | ", []Field{{"", -1}}, []string{"abcd"}, "abcd"}, 38 | // Test 5: one separtor, multiple contents 39 | {" | ", []Field{{"", -1}, {"", -1}, {"", -1}}, []string{"column1", "column2", "column3"}, "column1 | column2 | column3"}, 40 | // Test 6: multiple fields 41 | {" | ", []Field{{"", 5}, {"", -1}}, []string{"144550032", "my long content that should not be cut"}, "14... | my long content that should not be cut"}, 42 | } 43 | 44 | for idx, testCase := range testCases { 45 | tb := newPrettyTable(testCase.sep, testCase.tf...) 46 | row := tb.buildRow(testCase.contents...) 47 | if row != testCase.expectedRow { 48 | t.Fatalf("Test %d: generated row not matching, expected = `%s`, found = `%s`", idx+1, testCase.expectedRow, row) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /cmd/print.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "bytes" 22 | "encoding/json" 23 | "strings" 24 | 25 | "github.com/minio/pkg/v3/console" 26 | ) 27 | 28 | // message interface for all structured messages implementing JSON(), String() methods. 29 | type message interface { 30 | JSON() string 31 | String() string 32 | } 33 | 34 | // printMsg prints message string or JSON structure depending on the type of output console. 35 | func printMsg(msg message) { 36 | var msgStr string 37 | if !globalJSON { 38 | msgStr = msg.String() 39 | } else { 40 | msgStr = msg.JSON() 41 | if globalJSONLine && strings.ContainsRune(msgStr, '\n') { 42 | // Reformat. 43 | var dst bytes.Buffer 44 | if err := json.Compact(&dst, []byte(msgStr)); err == nil { 45 | msgStr = dst.String() 46 | } 47 | } 48 | } 49 | msgStr = strings.TrimSuffix(msgStr, "\n") 50 | console.Println(msgStr) 51 | } 52 | -------------------------------------------------------------------------------- /cmd/quota-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var quotaSubcommands = []cli.Command{ 23 | quotaSetCmd, 24 | quotaInfoCmd, 25 | quotaClearCmd, 26 | } 27 | 28 | var quotaCmd = cli.Command{ 29 | Name: "quota", 30 | Usage: "manage bucket quota", 31 | Action: mainQuota, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: quotaSubcommands, 35 | HideHelpCommand: true, 36 | } 37 | 38 | // mainQuota is the handle for "mc quota" command. 39 | func mainQuota(ctx *cli.Context) error { 40 | commandNotFound(ctx, quotaSubcommands) 41 | return nil 42 | // Sub-commands like "set", "clear", "info" have their own main. 43 | } 44 | -------------------------------------------------------------------------------- /cmd/replicate-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var replicateSubcommands = []cli.Command{ 23 | replicateAddCmd, 24 | replicateUpdateCmd, 25 | replicateListCmd, 26 | replicateStatusCmd, 27 | replicateResyncCmd, 28 | replicateExportCmd, 29 | replicateImportCmd, 30 | replicateRemoveCmd, 31 | replicateBacklogCmd, 32 | } 33 | 34 | var replicateCmd = cli.Command{ 35 | Name: "replicate", 36 | Usage: "configure server side bucket replication", 37 | HideHelpCommand: true, 38 | Action: mainReplicate, 39 | Before: setGlobalsFromContext, 40 | Flags: globalFlags, 41 | Subcommands: replicateSubcommands, 42 | } 43 | 44 | // mainReplicate is the handle for "mc replicate" command. 45 | func mainReplicate(ctx *cli.Context) error { 46 | commandNotFound(ctx, replicateSubcommands) 47 | return nil 48 | // Sub-commands like "list", "clear", "add" have their own main. 49 | } 50 | -------------------------------------------------------------------------------- /cmd/replicate-reset-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var replicateResyncSubcommands = []cli.Command{ 23 | replicateResyncStartCmd, 24 | replicateResyncStatusCmd, 25 | } 26 | 27 | var replicateResyncCmd = cli.Command{ 28 | Name: "resync", 29 | Usage: "re-replicate all previously replicated objects", 30 | HideHelpCommand: true, 31 | Action: mainReplicateResync, 32 | Before: setGlobalsFromContext, 33 | Flags: globalFlags, 34 | Subcommands: replicateResyncSubcommands, 35 | Aliases: []string{"reset"}, 36 | HiddenAliases: true, 37 | } 38 | 39 | // mainReplicateResync is the handle for "mc replicate resync" command. 40 | func mainReplicateResync(ctx *cli.Context) error { 41 | commandNotFound(ctx, replicateResyncSubcommands) 42 | return nil 43 | // Sub-commands like "status", "start", have their own main. 44 | } 45 | -------------------------------------------------------------------------------- /cmd/retention-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var retentionSubcommands = []cli.Command{ 25 | retentionSetCmd, 26 | retentionClearCmd, 27 | retentionInfoCmd, 28 | } 29 | 30 | var retentionCmd = cli.Command{ 31 | Name: "retention", 32 | Usage: "set retention for object(s)", 33 | Action: mainRetention, 34 | Before: setGlobalsFromContext, 35 | Flags: globalFlags, 36 | Subcommands: retentionSubcommands, 37 | } 38 | 39 | // main for retention command. 40 | func mainRetention(ctx *cli.Context) error { 41 | commandNotFound(ctx, retentionSubcommands) 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /cmd/retry.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "math/rand" 7 | "time" 8 | 9 | json "github.com/minio/colorjson" 10 | "github.com/minio/mc/pkg/probe" 11 | ) 12 | 13 | type retryManager struct { 14 | retries int 15 | maxRetries int 16 | retryInterval time.Duration 17 | commandCtx context.Context 18 | retryCtx context.Context 19 | cancelRetry context.CancelFunc 20 | } 21 | 22 | func newRetryManager(ctx context.Context, retryInterval time.Duration, maxRetries int) *retryManager { 23 | retryCtx, cancelFunc := context.WithCancel(context.Background()) 24 | return &retryManager{ 25 | retryInterval: retryInterval, 26 | maxRetries: maxRetries, 27 | commandCtx: ctx, 28 | retryCtx: retryCtx, 29 | cancelRetry: cancelFunc, 30 | } 31 | } 32 | 33 | type retryMessage struct { 34 | SourceURL string `json:"sourceURL"` 35 | TargetURL string `json:"targetURL"` 36 | Retries int `json:"retries"` 37 | } 38 | 39 | func (r retryMessage) String() string { 40 | return fmt.Sprintf(" Retries %d: source `%s` >> target `%s`", r.Retries, r.SourceURL, r.TargetURL) 41 | } 42 | 43 | func (r retryMessage) JSON() string { 44 | jsonMessageBytes, e := json.MarshalIndent(r, "", " ") 45 | fatalIf(probe.NewError(e), "Unable to marshal into JSON.") 46 | return string(jsonMessageBytes) 47 | } 48 | 49 | func (r *retryManager) retry(action func(rm *retryManager) *probe.Error) { 50 | defer r.cancelRetry() 51 | for r.retries <= r.maxRetries { 52 | 53 | err := action(r) 54 | if err == nil { 55 | return 56 | } 57 | 58 | select { 59 | case <-r.retryCtx.Done(): 60 | return 61 | case <-r.commandCtx.Done(): 62 | return 63 | case <-time.After(r.retryInterval/2 + time.Duration(rand.Int63n(int64(r.retryInterval)))): 64 | r.retries++ 65 | } 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /cmd/share-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "os" 22 | "path/filepath" 23 | 24 | "github.com/minio/cli" 25 | "github.com/minio/mc/pkg/probe" 26 | "github.com/minio/pkg/v3/console" 27 | ) 28 | 29 | var shareFlags = []cli.Flag{} 30 | 31 | var shareSubcommands = []cli.Command{ 32 | shareDownload, 33 | shareUpload, 34 | shareList, 35 | } 36 | 37 | // Share documents via URL. 38 | var shareCmd = cli.Command{ 39 | Name: "share", 40 | Usage: "generate URL for temporary access to an object", 41 | Action: mainShare, 42 | Before: setGlobalsFromContext, 43 | Flags: append(shareFlags, globalFlags...), 44 | HideHelpCommand: true, 45 | Subcommands: shareSubcommands, 46 | } 47 | 48 | // migrateShare migrate to newest version sequentially. 49 | func migrateShare() { 50 | if !isShareDirExists() { 51 | return 52 | } 53 | 54 | // Shared URLs are now managed by sub-commands. So delete any old URLs file if found. 55 | oldShareFile := filepath.Join(mustGetShareDir(), "urls.json") 56 | if _, e := os.Stat(oldShareFile); e == nil { 57 | // Old file exits. 58 | e := os.Remove(oldShareFile) 59 | fatalIf(probe.NewError(e), "Unable to delete old `"+oldShareFile+"`.") 60 | console.Infof("Removed older version of share `%s` file.\n", oldShareFile) 61 | } 62 | } 63 | 64 | // mainShare - main handler for mc share command. 65 | func mainShare(ctx *cli.Context) error { 66 | commandNotFound(ctx, shareSubcommands) 67 | return nil 68 | // Sub-commands like "upload" and "download" have their own main. 69 | } 70 | -------------------------------------------------------------------------------- /cmd/share-upload_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "strings" 22 | "testing" 23 | ) 24 | 25 | func TestMakeCurlCmdEscapesSpecialChars(t *testing.T) { 26 | testCases := []struct { 27 | key string 28 | expectedKey string 29 | }{ 30 | { 31 | key: "Robert O'Neil.png", 32 | expectedKey: "Robert\\ O\\'Neil.png", 33 | }, 34 | { 35 | key: "A&B-Design|2014.pdf", 36 | expectedKey: "A\\&B-Design\\\\|2014.pdf", 37 | }, 38 | { 39 | key: "A&B-Design(Revision 1).pdf", 40 | expectedKey: "A\\&B-Design\\(Revision\\ 1\\).pdf", 41 | }, 42 | { 43 | key: "Matt`s\tResume.pdf", 44 | expectedKey: "Matt\\`s\\\tResume.pdf", 45 | }, 46 | { 47 | key: "out.pdf;rm -rf $HOME #", 48 | expectedKey: "out.pdf\\;rm\\ -rf\\ \\$HOME\\ \\#", 49 | }, 50 | } 51 | 52 | for _, testCase := range testCases { 53 | cmd, _ := makeCurlCmd(testCase.key, "http://example.com", false, map[string]string{}) 54 | if !strings.Contains(cmd, " key="+testCase.expectedKey+" ") { 55 | t.Errorf("Did not find key=%s in command %s", testCase.expectedKey, cmd) 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /cmd/signals.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "os" 22 | "os/signal" 23 | ) 24 | 25 | // trapSignals traps the registered signals and cancel the global context. 26 | func trapSignals(sig ...os.Signal) { 27 | // channel to receive signals. 28 | sigCh := make(chan os.Signal, 1) 29 | defer close(sigCh) 30 | 31 | // `signal.Notify` registers the given channel to 32 | // receive notifications of the specified signals. 33 | signal.Notify(sigCh, sig...) 34 | 35 | // Wait for the signal. 36 | s := <-sigCh 37 | 38 | // Once signal has been received stop signal Notify handler. 39 | signal.Stop(sigCh) 40 | 41 | // Stop profiling if enabled, this needs to be before canceling the 42 | // global context to check for any unusual cpu/mem/goroutines usage 43 | stopProfiling() 44 | 45 | // Cancel the global context 46 | globalCancel() 47 | 48 | var exitCode int 49 | switch s.String() { 50 | case "interrupt": 51 | exitCode = globalCancelExitStatus 52 | case "killed": 53 | exitCode = globalKillExitStatus 54 | case "terminated": 55 | exitCode = globalTerminatExitStatus 56 | default: 57 | exitCode = globalErrorExitStatus 58 | } 59 | os.Exit(exitCode) 60 | } 61 | -------------------------------------------------------------------------------- /cmd/subnet-utils_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "net/url" 22 | "testing" 23 | ) 24 | 25 | func TestSubnetBaseURL(t *testing.T) { 26 | sbu := SubnetBaseURL() 27 | u, err := url.ParseRequestURI(sbu) 28 | if err != nil { 29 | t.Fatal(err) 30 | } 31 | if u.Scheme != "https" { 32 | t.Fatalf("Expected TestSubnetBaseURL() to return an https url, received %s", u.Scheme) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cmd/support-proxy.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var supportProxySubcommands = []cli.Command{ 25 | supportProxySetCmd, 26 | supportProxyRemoveCmd, 27 | supportProxyShowCmd, 28 | } 29 | 30 | var supportProxyCmd = cli.Command{ 31 | Name: "proxy", 32 | Usage: "configure proxy", 33 | Action: mainSupportProxy, 34 | OnUsageError: onUsageError, 35 | Before: setGlobalsFromContext, 36 | Flags: supportGlobalFlags, 37 | Subcommands: supportProxySubcommands, 38 | HideHelpCommand: true, 39 | } 40 | 41 | // mainSupportProxy is the handler for "mc support proxy" command. 42 | func mainSupportProxy(ctx *cli.Context) error { 43 | commandNotFound(ctx, supportProxySubcommands) 44 | return nil 45 | // Sub-commands like "set", "remove", "show" have their own main. 46 | // Check for command syntax 47 | } 48 | -------------------------------------------------------------------------------- /cmd/support-register.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var supportRegisterFlags = append([]cli.Flag{ 25 | cli.StringFlag{ 26 | Name: "name", 27 | Usage: "Specify the name to associate to this MinIO cluster in SUBNET", 28 | }, 29 | }, subnetCommonFlags...) 30 | 31 | var supportRegisterCmd = cli.Command{ 32 | Name: "register", 33 | Usage: "register with MinIO subscription network", 34 | OnUsageError: onUsageError, 35 | Action: mainSupportRegister, 36 | Before: setGlobalsFromContext, 37 | Flags: supportRegisterFlags, 38 | CustomHelpTemplate: "Please use 'mc license register'", 39 | } 40 | 41 | func mainSupportRegister(_ *cli.Context) error { 42 | deprecatedError("mc license register") 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /cmd/support-top.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2023 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var supportTopSubcommands = []cli.Command{ 23 | supportTopAPICmd, 24 | supportTopDriveCmd, 25 | supportTopLocksCmd, 26 | supportTopNetCmd, 27 | supportTopRPCCmd, 28 | } 29 | 30 | var supportTopCmd = cli.Command{ 31 | Name: "top", 32 | Usage: "provide top like statistics for MinIO", 33 | Action: mainSupportTop, 34 | Before: setGlobalsFromContext, 35 | Flags: globalFlags, 36 | Subcommands: supportTopSubcommands, 37 | HideHelpCommand: true, 38 | } 39 | 40 | // mainSupportTop is the handle for "mc support top" command. 41 | func mainSupportTop(ctx *cli.Context) error { 42 | commandNotFound(ctx, supportTopSubcommands) 43 | return nil 44 | // Sub-commands like "locks" have their own main. 45 | } 46 | -------------------------------------------------------------------------------- /cmd/table-ui.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/fatih/color" 21 | 22 | // An alias of string to represent the health color code of an object 23 | type col string 24 | 25 | const ( 26 | colGrey col = "Grey" 27 | colRed col = "Red" 28 | colYellow col = "Yellow" 29 | colGreen col = "Green" 30 | ) 31 | 32 | // getPrintCol - map color code to color for printing 33 | func getPrintCol(c col) *color.Color { 34 | switch c { 35 | case colGrey: 36 | return color.New(color.FgWhite, color.Bold) 37 | case colRed: 38 | return color.New(color.FgRed, color.Bold) 39 | case colYellow: 40 | return color.New(color.FgYellow, color.Bold) 41 | case colGreen: 42 | return color.New(color.FgGreen, color.Bold) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /cmd/tag-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/cli" 22 | ) 23 | 24 | var tagSubcommands = []cli.Command{ 25 | tagListCmd, 26 | tagRemoveCmd, 27 | tagSetCmd, 28 | } 29 | 30 | var tagCmd = cli.Command{ 31 | Name: "tag", 32 | Usage: "manage tags for bucket and object(s)", 33 | Action: mainTag, 34 | Before: setGlobalsFromContext, 35 | Flags: globalFlags, 36 | HideHelpCommand: true, 37 | Subcommands: tagSubcommands, 38 | } 39 | 40 | func mainTag(ctx *cli.Context) error { 41 | commandNotFound(ctx, tagSubcommands) 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /cmd/update_fips.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | //go:build fips 19 | // +build fips 20 | 21 | package cmd 22 | 23 | // Newer official download info URLs appear earlier below. 24 | var mcReleaseInfoURL = mcReleaseURL + "mc.fips.sha256sum" 25 | -------------------------------------------------------------------------------- /cmd/update_nofips.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | //go:build !fips 19 | // +build !fips 20 | 21 | package cmd 22 | 23 | // Newer official download info URLs appear earlier below. 24 | var mcReleaseInfoURL = mcReleaseURL + "mc.sha256sum" 25 | -------------------------------------------------------------------------------- /cmd/urls.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import ( 21 | "github.com/minio/mc/pkg/probe" 22 | "github.com/minio/minio-go/v7" 23 | ) 24 | 25 | // URLs contains source and target urls 26 | type URLs struct { 27 | SourceAlias string 28 | SourceContent *ClientContent 29 | TargetAlias string 30 | TargetContent *ClientContent 31 | TotalCount int64 32 | TotalSize int64 33 | MD5 bool 34 | DisableMultipart bool 35 | checksum minio.ChecksumType 36 | encKeyDB map[string][]prefixSSEPair 37 | Error *probe.Error `json:"-"` 38 | ErrorCond differType `json:"-"` 39 | } 40 | 41 | // WithError sets the error and returns object 42 | func (m URLs) WithError(err *probe.Error) URLs { 43 | m.Error = err 44 | return m 45 | } 46 | 47 | // Equal tests if both urls are equal 48 | func (m URLs) Equal(n URLs) bool { 49 | if m.SourceContent != nil && n.SourceContent == nil { 50 | return false 51 | } else if m.SourceContent == nil && n.SourceContent != nil { 52 | return false 53 | } else if m.SourceContent != nil && n.SourceContent != nil && m.SourceContent.URL != n.SourceContent.URL { 54 | return false 55 | } 56 | 57 | if m.TargetContent != nil && n.TargetContent == nil { 58 | return false 59 | } else if m.TargetContent == nil && n.TargetContent != nil { 60 | return false 61 | } else if m.TargetContent != nil && n.TargetContent != nil && m.TargetContent.URL != n.TargetContent.URL { 62 | return false 63 | } 64 | 65 | return true 66 | } 67 | -------------------------------------------------------------------------------- /cmd/version-main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2022 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package cmd 19 | 20 | import "github.com/minio/cli" 21 | 22 | var versionSubcommands = []cli.Command{ 23 | versionEnableCmd, 24 | versionSuspendCmd, 25 | versionInfoCmd, 26 | } 27 | 28 | var versionCmd = cli.Command{ 29 | Name: "version", 30 | Usage: "manage bucket versioning", 31 | HideHelpCommand: true, 32 | Action: mainVersion, 33 | Before: setGlobalsFromContext, 34 | Flags: globalFlags, 35 | Subcommands: versionSubcommands, 36 | } 37 | 38 | // mainVersion is the handle for "mc version" command. 39 | func mainVersion(ctx *cli.Context) error { 40 | commandNotFound(ctx, versionSubcommands) 41 | return nil 42 | // Sub-commands like "info", "enable", "suspend" have their own main. 43 | } 44 | -------------------------------------------------------------------------------- /contributors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2015-2021 MinIO, Inc. 4 | # 5 | # This file is part of MinIO Object Storage stack 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU Affero General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Affero General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | set -e 22 | 23 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 24 | 25 | # see also ".mailmap" for how email addresses and names are deduplicated 26 | 27 | { 28 | cat <<-'EOH' 29 | ## Contributors 30 | 31 | EOH 32 | echo 33 | git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf | sed 's/^/- /g' 34 | } > CONTRIBUTORS.md 35 | -------------------------------------------------------------------------------- /docker-buildx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2015-2023 MinIO, Inc. 4 | # 5 | # This file is part of MinIO Object Storage stack 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU Affero General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Affero General Public License 18 | # along with this program. If not, see . 19 | # 20 | 21 | sudo sysctl net.ipv6.conf.all.disable_ipv6=1 22 | 23 | release=$(git describe --abbrev=0 --tags) 24 | 25 | docker buildx build --push --no-cache \ 26 | --build-arg RELEASE="${release}" \ 27 | -t "minio/mc:latest" \ 28 | -t "minio/mc:${release}" \ 29 | -t "quay.io/minio/mc:${release}" \ 30 | -t "quay.io/minio/mc:latest" \ 31 | --platform=linux/arm64,linux/amd64,linux/ppc64le \ 32 | -f Dockerfile.release . 33 | 34 | docker buildx prune -f 35 | 36 | docker buildx build --push --no-cache \ 37 | --build-arg RELEASE="${release}" \ 38 | -t "minio/mc:${release}-cpuv1" \ 39 | -t "quay.io/minio/mc:${release}-cpuv1" \ 40 | --platform=linux/arm64,linux/amd64,linux/ppc64le \ 41 | -f Dockerfile.release.old_cpu . 42 | 43 | docker buildx prune -f 44 | 45 | sudo sysctl net.ipv6.conf.all.disable_ipv6=0 46 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package main // import "github.com/minio/mc" 19 | 20 | import ( 21 | "os" 22 | 23 | mc "github.com/minio/mc/cmd" 24 | "github.com/minio/pkg/v3/console" 25 | ) 26 | 27 | func main() { 28 | if e := mc.Main(os.Args); e != nil { 29 | console.Fatalln(e) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pkg/disk/stat_darwin.go: -------------------------------------------------------------------------------- 1 | //go:build darwin 2 | // +build darwin 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package disk 22 | 23 | import ( 24 | "os/user" 25 | "strconv" 26 | "strings" 27 | "syscall" 28 | ) 29 | 30 | // GetFileSystemAttrs return the file system attribute as string; containing mode, 31 | // uid, gid, uname, Gname, atime, mtime, ctime and md5 32 | func GetFileSystemAttrs(file string) (string, error) { 33 | st := syscall.Stat_t{} 34 | err := syscall.Stat(file, &st) 35 | if err != nil { 36 | return "", err 37 | } 38 | 39 | var fileAttr strings.Builder 40 | fileAttr.WriteString("atime:") 41 | fileAttr.WriteString(strconv.FormatInt(st.Atimespec.Sec, 10) + "#" + strconv.FormatInt(st.Atimespec.Nsec, 10)) 42 | fileAttr.WriteString("/gid:") 43 | fileAttr.WriteString(strconv.Itoa(int(st.Gid))) 44 | 45 | g, err := user.LookupGroupId(strconv.FormatUint(uint64(st.Gid), 10)) 46 | if err == nil { 47 | fileAttr.WriteString("/gname:") 48 | fileAttr.WriteString(g.Name) 49 | } 50 | 51 | fileAttr.WriteString("/mode:") 52 | fileAttr.WriteString(strconv.Itoa(int(st.Mode))) 53 | fileAttr.WriteString("/mtime:") 54 | fileAttr.WriteString(strconv.FormatInt(st.Mtimespec.Sec, 10) + "#" + strconv.FormatInt(st.Mtimespec.Nsec, 10)) 55 | fileAttr.WriteString("/uid:") 56 | fileAttr.WriteString(strconv.Itoa(int(st.Uid))) 57 | 58 | u, err := user.LookupId(strconv.FormatUint(uint64(st.Uid), 10)) 59 | if err == nil { 60 | fileAttr.WriteString("/uname:") 61 | fileAttr.WriteString(u.Username) 62 | } 63 | 64 | return fileAttr.String(), nil 65 | } 66 | -------------------------------------------------------------------------------- /pkg/disk/stat_linux.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | // +build linux 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | // Package disk fetches file system information for various OS 22 | package disk 23 | 24 | import ( 25 | "os" 26 | "os/user" 27 | "strconv" 28 | "strings" 29 | "syscall" 30 | ) 31 | 32 | // GetFileSystemAttrs return the file system attribute as string; containing mode, 33 | // uid, gid, uname, Gname, atime, mtime, ctime and md5 34 | func GetFileSystemAttrs(file string) (string, error) { 35 | fi, err := os.Stat(file) 36 | if err != nil { 37 | return "", err 38 | } 39 | st := fi.Sys().(*syscall.Stat_t) 40 | 41 | var fileAttr strings.Builder 42 | fileAttr.WriteString("atime:") 43 | fileAttr.WriteString(strconv.FormatInt(int64(st.Atim.Sec), 10) + "#" + strconv.FormatInt(int64(st.Atim.Nsec), 10)) 44 | fileAttr.WriteString("/gid:") 45 | fileAttr.WriteString(strconv.Itoa(int(st.Gid))) 46 | 47 | g, err := user.LookupGroupId(strconv.FormatUint(uint64(st.Gid), 10)) 48 | if err == nil { 49 | fileAttr.WriteString("/gname:") 50 | fileAttr.WriteString(g.Name) 51 | } 52 | 53 | fileAttr.WriteString("/mode:") 54 | fileAttr.WriteString(strconv.Itoa(int(st.Mode))) 55 | fileAttr.WriteString("/mtime:") 56 | fileAttr.WriteString(strconv.FormatInt(int64(st.Mtim.Sec), 10) + "#" + strconv.FormatInt(int64(st.Mtim.Nsec), 10)) 57 | fileAttr.WriteString("/uid:") 58 | fileAttr.WriteString(strconv.Itoa(int(st.Uid))) 59 | 60 | u, err := user.LookupId(strconv.FormatUint(uint64(st.Uid), 10)) 61 | if err == nil { 62 | fileAttr.WriteString("/uname:") 63 | fileAttr.WriteString(u.Username) 64 | } 65 | 66 | return fileAttr.String(), nil 67 | } 68 | -------------------------------------------------------------------------------- /pkg/disk/stat_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package disk 19 | 20 | import ( 21 | "os/user" 22 | "strconv" 23 | "strings" 24 | "syscall" 25 | ) 26 | 27 | // GetFileSystemAttrs return the file system attribute as string; containing mode, 28 | // uid, gid, uname, Gname, atime, mtime, ctime and md5 29 | func GetFileSystemAttrs(file string) (string, error) { 30 | st := syscall.Stat_t{} 31 | err := syscall.Stat(file, &st) 32 | if err != nil { 33 | return "", err 34 | } 35 | 36 | var fileAttr strings.Builder 37 | fileAttr.WriteString("atime:") 38 | fileAttr.WriteString(strconv.FormatInt(st.Atimespec.Sec, 10) + "#" + strconv.FormatInt(st.Atimespec.Nsec, 10)) 39 | fileAttr.WriteString("/gid:") 40 | fileAttr.WriteString(strconv.Itoa(int(st.Gid))) 41 | 42 | g, err := user.LookupGroupId(strconv.FormatUint(uint64(st.Gid), 10)) 43 | if err == nil { 44 | fileAttr.WriteString("/gname:") 45 | fileAttr.WriteString(g.Name) 46 | } 47 | 48 | fileAttr.WriteString("/mode:") 49 | fileAttr.WriteString(strconv.Itoa(int(st.Mode))) 50 | fileAttr.WriteString("/mtime:") 51 | fileAttr.WriteString(strconv.FormatInt(st.Mtimespec.Sec, 10) + "#" + strconv.FormatInt(st.Mtimespec.Nsec, 10)) 52 | fileAttr.WriteString("/uid:") 53 | fileAttr.WriteString(strconv.Itoa(int(st.Uid))) 54 | 55 | u, err := user.LookupId(strconv.FormatUint(uint64(st.Uid), 10)) 56 | if err == nil { 57 | fileAttr.WriteString("/uname:") 58 | fileAttr.WriteString(u.Username) 59 | } 60 | 61 | return fileAttr.String(), nil 62 | } 63 | -------------------------------------------------------------------------------- /pkg/disk/stat_other.go: -------------------------------------------------------------------------------- 1 | //go:build openbsd || solaris 2 | // +build openbsd solaris 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package disk 22 | 23 | import ( 24 | "os/user" 25 | "strconv" 26 | "strings" 27 | "syscall" 28 | ) 29 | 30 | // GetFileSystemAttrs return the file system attribute as string; containing mode, 31 | // uid, gid, uname, Gname, atime, mtime, ctime and md5 32 | func GetFileSystemAttrs(file string) (string, error) { 33 | st := syscall.Stat_t{} 34 | err := syscall.Stat(file, &st) 35 | if err != nil { 36 | return "", err 37 | } 38 | 39 | var fileAttr strings.Builder 40 | fileAttr.WriteString("atime:") 41 | fileAttr.WriteString(strconv.FormatInt(int64(st.Atim.Sec), 10) + "#" + strconv.FormatInt(int64(st.Atim.Nsec), 10)) 42 | fileAttr.WriteString("/gid:") 43 | fileAttr.WriteString(strconv.Itoa(int(st.Gid))) 44 | 45 | g, err := user.LookupGroupId(strconv.FormatUint(uint64(st.Gid), 10)) 46 | if err == nil { 47 | fileAttr.WriteString("/gname:") 48 | fileAttr.WriteString(g.Name) 49 | } 50 | 51 | fileAttr.WriteString("/mode:") 52 | fileAttr.WriteString(strconv.Itoa(int(st.Mode))) 53 | fileAttr.WriteString("/mtime:") 54 | fileAttr.WriteString(strconv.FormatInt(int64(st.Mtim.Sec), 10) + "#" + strconv.FormatInt(int64(st.Mtim.Nsec), 10)) 55 | fileAttr.WriteString("/uid:") 56 | fileAttr.WriteString(strconv.Itoa(int(st.Uid))) 57 | 58 | u, err := user.LookupId(strconv.FormatUint(uint64(st.Uid), 10)) 59 | if err == nil { 60 | fileAttr.WriteString("/uname:") 61 | fileAttr.WriteString(u.Username) 62 | } 63 | 64 | return fileAttr.String(), nil 65 | } 66 | -------------------------------------------------------------------------------- /pkg/disk/stat_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | // Copyright (c) 2015-2021 MinIO, Inc. 5 | // 6 | // This file is part of MinIO Object Storage stack 7 | // 8 | // This program is free software: you can redistribute it and/or modify 9 | // it under the terms of the GNU Affero General Public License as published by 10 | // the Free Software Foundation, either version 3 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU Affero General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Affero General Public License 19 | // along with this program. If not, see . 20 | 21 | package disk 22 | 23 | // GetFileSystemAttrs return the file system attribute as string; containing mode, 24 | // uid, gid, uname, Gname, atime, mtime, ctime and md5 25 | func GetFileSystemAttrs(_ string) (string, error) { 26 | return "", nil 27 | } 28 | -------------------------------------------------------------------------------- /pkg/hookreader/hookreader_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package hookreader 19 | 20 | import ( 21 | "bytes" 22 | "testing" 23 | 24 | check "gopkg.in/check.v1" 25 | ) 26 | 27 | func Test(t *testing.T) { check.TestingT(t) } 28 | 29 | type MySuite struct{} 30 | 31 | var _ = check.Suite(&MySuite{}) 32 | 33 | // customReader - implements custom progress reader. 34 | type customReader struct { 35 | readBytes int 36 | } 37 | 38 | func (c *customReader) Read(b []byte) (n int, err error) { 39 | c.readBytes += len(b) 40 | return len(b), nil 41 | } 42 | 43 | // Tests hook reader implementation. 44 | func (s *MySuite) TestHookReader(c *check.C) { 45 | var buffer bytes.Buffer 46 | writer := &buffer 47 | _, err := writer.Write([]byte("Hello")) 48 | c.Assert(err, check.IsNil) 49 | progress := &customReader{} 50 | reader := NewHook(&buffer, progress) 51 | b := make([]byte, 3) 52 | n, err := reader.Read(b) 53 | c.Assert(err, check.IsNil) 54 | c.Assert(n, check.Equals, 3) 55 | c.Assert(progress.readBytes, check.Equals, 3) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/httptracer/httptracer_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package httptracer 19 | 20 | import ( 21 | "testing" 22 | 23 | check "gopkg.in/check.v1" 24 | ) 25 | 26 | func Test(t *testing.T) { check.TestingT(t) } 27 | 28 | type MySuite struct{} 29 | 30 | var _ = check.Suite(&MySuite{}) 31 | 32 | func (s *MySuite) TestHTTPTracer(_ *check.C) { 33 | } 34 | -------------------------------------------------------------------------------- /pkg/probe/probe_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | package probe_test 19 | 20 | import ( 21 | "os" 22 | "testing" 23 | 24 | "github.com/minio/mc/pkg/probe" 25 | check "gopkg.in/check.v1" 26 | ) 27 | 28 | func Test(t *testing.T) { check.TestingT(t) } 29 | 30 | type MySuite struct{} 31 | 32 | var _ = check.Suite(&MySuite{}) 33 | 34 | func testDummy0() *probe.Error { 35 | _, e := os.Stat("this-file-cannot-exit") 36 | return probe.NewError(e) 37 | } 38 | 39 | func testDummy1() *probe.Error { 40 | return testDummy0().Trace("DummyTag1") 41 | } 42 | 43 | func testDummy2() *probe.Error { 44 | return testDummy1().Trace("DummyTag2") 45 | } 46 | 47 | func (s *MySuite) TestProbe(c *check.C) { 48 | probe.Init() // Set project's root source path. 49 | probe.SetAppInfo("Commit-ID", "7390cc957239") 50 | es := testDummy2().Trace("TopOfStack") 51 | // Uncomment the following Println to visually test probe call trace. 52 | // fmt.Println("Expecting a simulated error here.", es) 53 | c.Assert(es, check.Not(check.Equals), nil) 54 | 55 | newES := es.Trace() 56 | c.Assert(newES, check.Not(check.Equals), nil) 57 | } 58 | 59 | func (s *MySuite) TestWrappedError(c *check.C) { 60 | _, e := os.Stat("this-file-cannot-exit") 61 | es := probe.NewError(e) // *probe.Error 62 | e = probe.WrapError(es) // *probe.WrappedError 63 | _, ok := probe.UnwrapError(e) 64 | c.Assert(ok, check.Equals, true) 65 | } 66 | -------------------------------------------------------------------------------- /pkg/probe/wrapper.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2021 MinIO, Inc. 2 | // 3 | // This file is part of MinIO Object Storage stack 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU Affero General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU Affero General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU Affero General Public License 16 | // along with this program. If not, see . 17 | 18 | // Package probe implements a simple mechanism to trace and return errors in large programs. 19 | package probe 20 | 21 | // wrappedError implements a container for *probe.Error. 22 | type wrappedError struct { 23 | err *Error 24 | } 25 | 26 | // WrapError function wraps a *probe.Error into a 'error' compatible duck type. 27 | func WrapError(err *Error) error { 28 | return &wrappedError{err: err} 29 | } 30 | 31 | // UnwrapError tries to convert generic 'error' into typed *probe.Error and returns true, false otherwise. 32 | func UnwrapError(err error) (*Error, bool) { 33 | switch e := err.(type) { 34 | case *wrappedError: 35 | return e.err, true 36 | default: 37 | return nil, false 38 | } 39 | } 40 | 41 | // Error interface method. 42 | func (w *wrappedError) Error() string { 43 | return w.err.String() 44 | } 45 | -------------------------------------------------------------------------------- /staticcheck.conf: -------------------------------------------------------------------------------- 1 | checks = ["all", "-S1016"] 2 | -------------------------------------------------------------------------------- /testdata/localhost.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDojCCAoqgAwIBAgIUHE3HUt7gKVBp7wT9Hjj4wRT1xywwDQYJKoZIhvcNAQEL 3 | BQAwejELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRgwFgYDVQQHDA9jdXN0b20t 4 | bG9jYXRpb24xHDAaBgNVBAoME2N1c3RvbS1vcmdhbml6YXRpb24xEjAQBgNVBAsM 5 | CWN1c3RvbS1vdTESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTIxMDkyMDEyMTAyOFoY 6 | DzIxMjEwODI3MTIxMDI4WjB6MQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExGDAW 7 | BgNVBAcMD2N1c3RvbS1sb2NhdGlvbjEcMBoGA1UECgwTY3VzdG9tLW9yZ2FuaXph 8 | dGlvbjESMBAGA1UECwwJY3VzdG9tLW91MRIwEAYDVQQDDAlsb2NhbGhvc3QwggEi 9 | MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6mSJV5oz171+P/G1X07Y4HpTS 10 | ZR/TC5lHAYh2YxecOvuuQHBYCgjXbSBmRQXuPRZIy8mXAa6miwssGgSlMKaH6ZV/ 11 | s82ViCSf4Tj1W9on1DvD8bNgCVs0aYA2DmbOyeSyQyyH35TLIaZ2C9fURArixDce 12 | rsUjLMv/GbrL2o2Ia+x4vBSEqUEXlfs7nA1jbm0fYoKlcxjnvDmkIYBCdMqNveHD 13 | DLXzCuXKq4aMLlM+1s8h5ShVAhxpCzY3xncfOvAGA1JWVjEsMUd8PQ4+K88JKVIG 14 | H3HZmL0exjNF4Ks7ocINqQJk7RY0ZUJc10JnCgdkY5bnHuGKzj4Ddq3Ta5FrAgMB 15 | AAGjHjAcMBoGA1UdEQQTMBGHBH8AAAGCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsF 16 | AAOCAQEAREoEGX34C0+osOgCPwZ4mFXVvssJRJTc4JL/kqOGPyzS/085MzeIpOhu 17 | gkOm3zj175SKiZMWWpYhB+Q/1T6tDiVLidEY7HK/dcbjYfoTAd42cQWY4qmG68vG 18 | E6WnTQjal0uPuCwKqvqIRgkWLpaIV4TmHtpCFLLlVlnDWQBpAdiK/Vk0EeTDDaqd 19 | cROr4tm/8EBxqwUnIQF8vgbXgVT5BNdcp44LWs7A558CCRrCGifch5+kxkSSdAFG 20 | Y7BEXvnnsxU1n9AAVKJYnp1wUN2Hk4KWyPcQb9/Ee45DKDR5KNyMqClsWWXMJr40 21 | FrgI6euT50Wzo8Qqbls5Bt/0IzObnA== 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /testdata/localhost.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAupkiVeaM9e9fj/xtV9O2OB6U0mUf0wuZRwGIdmMXnDr7rkBw 3 | WAoI120gZkUF7j0WSMvJlwGuposLLBoEpTCmh+mVf7PNlYgkn+E49VvaJ9Q7w/Gz 4 | YAlbNGmANg5mzsnkskMsh9+UyyGmdgvX1EQK4sQ3Hq7FIyzL/xm6y9qNiGvseLwU 5 | hKlBF5X7O5wNY25tH2KCpXMY57w5pCGAQnTKjb3hwwy18wrlyquGjC5TPtbPIeUo 6 | VQIcaQs2N8Z3HzrwBgNSVlYxLDFHfD0OPivPCSlSBh9x2Zi9HsYzReCrO6HCDakC 7 | ZO0WNGVCXNdCZwoHZGOW5x7his4+A3at02uRawIDAQABAoIBAElz2mZCGR7+mXmO 8 | fmRiPIqezyp7ECn9mNqwqc0geLzRIx2W1CJz4MMce/KGHS2I8mq5faNp0BxTA5Ta 9 | sRVtr0A1HNpmJvlD3FbrS4aaH6gqDVS2okudoz9ggE3HIYUpSFM7yh26T1Ie7u3s 10 | /4rZNgfKAYCcf5G3Ip5KvJNedvRKC2w5UX4iYU5eMuXs0YPy2+DtTKxZKIEnI3x4 11 | VpMe652I7GhjkLSsyuW5NoDeSWmmqhitm1bibuZQBR0ogFyAU94rZk8+j4hiUl9k 12 | 7ZVi00tKNp7EcLIwbY02ZCpZ2xvat8W1SLeWRUpExPj/7nnA9Fafrl5M8aHgl8R1 13 | N0Fd+zECgYEA4GruRDPPNPEXPByes6jjcxfvdoYIDyma1V+FN5Nn+/QPL/vWp9t0 14 | +mH344iwWkEyZZHNUpNuy5dpOA9724iFFLp9Btq06OgzzDuJj1LDbDpB4zwltuQA 15 | 4s7ekTFi9rHDOeAyTREHgDu3uya/2qq53Ms6w8gXM4/kmp9/S4N5VhcCgYEA1Nuv 16 | J1khBitNiNbzHYG9DRV4HLfIB8FFDKtgnW8HvSaWUtHKI4YitwJVFfa5Epz9MDFy 17 | tkFAD9Bu0HqZQ6OQZxGo0rDUcFics9Ftw+w3p/PIocPQBK7PNQ3L9BQS9M3stL+k 18 | fW5r+kUvfZaJVE8agCQQnzkJJh9oexJjMWyxB80CgYBa5BQSPWWLjKWba//+xcUx 19 | BR2wREKZWYFjL+e1hZcU3VkVVwsuOtza17jdR6wdMdCmgHHHIv05qd4snWDNnjJA 20 | HfOrRgMFXZ409lwVVzDc8Y9j6CViOF//fEd6SKVLQt3N3/afbek6z3TvcJc9ie3y 21 | 9cCcMLrs4Dd3RGf6/omzCwKBgQChwWxCf6Xr9T5PjeFke/I5niYP1M2KryGU9itO 22 | mFCOOmOj/k8ZXdbFsl0Meti7v1dcp0cgH0fafK+peHE+CG81FCNyMPTPh1dWAwHi 23 | EIFe/ZBq9c3/sQQ/sgNasWKSbGbEGJqcwywFHUxwqNQloJNn64BCL2q3cMjKNffx 24 | WELTxQKBgQDe7adrUBtk8+YZ1/c2VsV1oBq6eI2U+1bWa/8fwXWd9ylETBMtcv20 25 | Fs8UAFWLz78aWaXWWSSEmFvUbjXPBDvzXCObb6HdhXOCF1n74hKU+z06MAUa1eFC 26 | V0GvBx4v1rc1pZ7grBZwGteeVWVgCAZ487m5TATWqxuarH6yfU0Ptg== 27 | -----END RSA PRIVATE KEY----- 28 | --------------------------------------------------------------------------------