From bccf549463fd83574a5b20512c6afc98aa396fe6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 18 Aug 2016 16:23:42 -0700 Subject: [PATCH] server: Move all the top level files into cmd folder. (#2490) This change brings a change which was done for the 'mc' package to allow for clean repo and have a cleaner github drop in experience. --- Makefile | 16 +- appveyor.yml | 2 +- buildscripts/gen-ldflags.go | 10 +- access-key.go => cmd/access-key.go | 2 +- api-datatypes.go => cmd/api-datatypes.go | 2 +- api-errors.go => cmd/api-errors.go | 2 +- api-headers.go => cmd/api-headers.go | 4 +- .../api-headers_test.go | 2 +- api-resources.go => cmd/api-resources.go | 2 +- .../api-response-multipart.go | 4 +- api-response.go => cmd/api-response.go | 2 +- api-router.go => cmd/api-router.go | 2 +- auth-handler.go => cmd/auth-handler.go | 2 +- .../auth-handler_test.go | 2 +- .../benchmark-utils_test.go | 2 +- .../bucket-handlers-listobjects.go | 2 +- bucket-handlers.go => cmd/bucket-handlers.go | 2 +- .../bucket-notification-datatypes.go | 2 +- .../bucket-notification-handlers.go | 2 +- .../bucket-notification-handlers_test.go | 2 +- .../bucket-notification-utils.go | 2 +- .../bucket-notification-utils_test.go | 2 +- .../bucket-policy-handlers.go | 2 +- .../bucket-policy-handlers_test.go | 2 +- .../bucket-policy-migrate.go | 2 +- .../bucket-policy-parser.go | 4 +- .../bucket-policy-parser_test.go | 2 +- bucket-policy.go => cmd/bucket-policy.go | 2 +- build-constants.go => cmd/build-constants.go | 24 +-- certs.go => cmd/certs.go | 2 +- certs_test.go => cmd/certs_test.go | 2 +- checkport.go => cmd/checkport.go | 2 +- checkport_test.go => cmd/checkport_test.go | 2 +- commands.go => cmd/commands.go | 2 +- config-migrate.go => cmd/config-migrate.go | 2 +- config-old.go => cmd/config-old.go | 2 +- config-v6.go => cmd/config-v6.go | 2 +- config.go => cmd/config.go | 2 +- control-main.go => cmd/control-main.go | 2 +- .../crossdomain-xml-handler.go | 2 +- .../damerau-levenshtein.go | 2 +- .../damerau-levenshtein_test.go | 2 +- .../erasure-createfile.go | 2 +- .../erasure-createfile_test.go | 2 +- .../erasure-healfile.go | 2 +- .../erasure-healfile_test.go | 2 +- .../erasure-readfile.go | 2 +- .../erasure-readfile_test.go | 2 +- erasure-utils.go => cmd/erasure-utils.go | 2 +- .../erasure-utils_test.go | 2 +- erasure_test.go => cmd/erasure_test.go | 2 +- event-notifier.go => cmd/event-notifier.go | 2 +- .../event-notifier_test.go | 2 +- .../faulty-disk_test.go | 2 +- .../format-config-v1.go | 2 +- .../format-config-v1_test.go | 2 +- fs-createfile.go => cmd/fs-createfile.go | 2 +- fs-v1-errors.go => cmd/fs-v1-errors.go | 2 +- fs-v1-metadata.go => cmd/fs-v1-metadata.go | 4 +- .../fs-v1-metadata_test.go | 2 +- .../fs-v1-multipart-common.go | 2 +- fs-v1-multipart.go => cmd/fs-v1-multipart.go | 2 +- fs-v1.go => cmd/fs-v1.go | 2 +- fs-v1_test.go => cmd/fs-v1_test.go | 2 +- .../generic-handlers.go | 2 +- globals.go => cmd/globals.go | 2 +- handler-utils.go => cmd/handler-utils.go | 2 +- .../handler-utils_test.go | 2 +- host-to-ip.go => cmd/host-to-ip.go | 2 +- host-to-ip_test.go => cmd/host-to-ip_test.go | 2 +- httprange.go => cmd/httprange.go | 2 +- httprange_test.go => cmd/httprange_test.go | 2 +- .../leak-detect_test.go | 2 +- .../logger-console-hook.go | 2 +- .../logger-file-hook.go | 2 +- .../logger-syslog-hook_nix.go | 2 +- .../logger-syslog-hook_windows.go | 2 +- logger.go => cmd/logger.go | 4 +- logger_test.go => cmd/logger_test.go | 2 +- cmd/main.go | 193 ++++++++++++++++++ main_test.go => cmd/main_test.go | 2 +- namespace-lock.go => cmd/namespace-lock.go | 2 +- .../namespace-lock_test.go | 2 +- notifiers.go => cmd/notifiers.go | 2 +- notifiers_test.go => cmd/notifiers_test.go | 2 +- notify-amqp.go => cmd/notify-amqp.go | 2 +- .../notify-elasticsearch.go | 2 +- notify-redis.go => cmd/notify-redis.go | 2 +- .../object-api-getobject_test.go | 2 +- .../object-api-getobjectinfo_test.go | 2 +- .../object-api-listobjects_test.go | 2 +- .../object-api-multipart_test.go | 2 +- .../object-api-putobject_test.go | 2 +- object-common.go => cmd/object-common.go | 2 +- .../object-datatypes.go | 2 +- object-errors.go => cmd/object-errors.go | 2 +- .../object-handlers-common.go | 2 +- object-handlers.go => cmd/object-handlers.go | 2 +- .../object-handlers_test.go | 2 +- .../object-interface.go | 2 +- .../object-multipart-common.go | 2 +- object-utils.go => cmd/object-utils.go | 2 +- .../object-utils_test.go | 2 +- .../object_api_suite_test.go | 2 +- .../posix-dirent-fileno.go | 2 +- .../posix-dirent-ino.go | 2 +- .../posix-list-dir-nix.go | 2 +- .../posix-list-dir-others.go | 2 +- .../posix-list-dir_test.go | 2 +- .../posix-prepare-path.go | 2 +- .../posix-utils_common.go | 2 +- posix-utils_nix.go => cmd/posix-utils_nix.go | 2 +- .../posix-utils_nix_test.go | 2 +- .../posix-utils_test.go | 2 +- .../posix-utils_windows.go | 2 +- .../posix-utils_windows_test.go | 2 +- posix.go => cmd/posix.go | 2 +- posix_test.go => cmd/posix_test.go | 2 +- .../rate-limit-handler.go | 2 +- routers.go => cmd/routers.go | 2 +- rpc-client.go => cmd/rpc-client.go | 2 +- rpc-control.go => cmd/rpc-control.go | 2 +- .../rpc-server-datatypes.go | 2 +- rpc-server.go => cmd/rpc-server.go | 2 +- runtime-checks.go => cmd/runtime-checks.go | 2 +- server-main.go => cmd/server-main.go | 2 +- server-mux.go => cmd/server-mux.go | 2 +- server-mux_test.go => cmd/server-mux_test.go | 2 +- .../server-rlimit-nix.go | 2 +- .../server-rlimit-win.go | 2 +- .../server-startup-msg.go | 2 +- server_test.go => cmd/server_test.go | 2 +- .../server_utils_test.go | 2 +- signals.go => cmd/signals.go | 2 +- signature-jwt.go => cmd/signature-jwt.go | 2 +- .../signature-jwt_test.go | 2 +- .../signature-v4-parser.go | 2 +- .../signature-v4-parser_test.go | 2 +- .../signature-v4-postpolicyform.go | 2 +- .../signature-v4-postpolicyform_test.go | 2 +- .../signature-v4-utils.go | 2 +- .../signature-v4-utils_test.go | 2 +- signature-v4.go => cmd/signature-v4.go | 18 +- .../signature-v4_test.go | 2 +- .../signature-verify-reader.go | 2 +- .../storage-datatypes.go | 2 +- storage-errors.go => cmd/storage-errors.go | 2 +- .../storage-interface.go | 2 +- strconv-bytes.go => cmd/strconv-bytes.go | 2 +- .../strconv-bytes_test.go | 2 +- .../streaming-signature-v4.go | 4 +- .../streaming-signature-v4_test.go | 2 +- test-utils_test.go => cmd/test-utils_test.go | 2 +- tree-walk-pool.go => cmd/tree-walk-pool.go | 2 +- .../tree-walk-pool_test.go | 2 +- tree-walk.go => cmd/tree-walk.go | 2 +- tree-walk_test.go => cmd/tree-walk_test.go | 2 +- trie.go => cmd/trie.go | 2 +- trie_test.go => cmd/trie_test.go | 2 +- typed-errors.go => cmd/typed-errors.go | 2 +- update-main.go => cmd/update-main.go | 8 +- update-notifier.go => cmd/update-notifier.go | 2 +- utils.go => cmd/utils.go | 2 +- utils_test.go => cmd/utils_test.go | 2 +- version-main.go => cmd/version-main.go | 8 +- version_test.go => cmd/version_test.go | 4 +- web-handlers.go => cmd/web-handlers.go | 4 +- .../web-handlers_test.go | 4 +- web-router.go => cmd/web-router.go | 2 +- xl-v1-bucket.go => cmd/xl-v1-bucket.go | 2 +- xl-v1-common.go => cmd/xl-v1-common.go | 2 +- xl-v1-errors.go => cmd/xl-v1-errors.go | 2 +- xl-v1-healing.go => cmd/xl-v1-healing.go | 2 +- .../xl-v1-healing_test.go | 2 +- .../xl-v1-list-objects-heal.go | 2 +- .../xl-v1-list-objects.go | 2 +- xl-v1-metadata.go => cmd/xl-v1-metadata.go | 4 +- .../xl-v1-metadata_test.go | 2 +- .../xl-v1-multipart-common.go | 2 +- xl-v1-multipart.go => cmd/xl-v1-multipart.go | 2 +- xl-v1-object.go => cmd/xl-v1-object.go | 2 +- .../xl-v1-object_test.go | 2 +- xl-v1-utils.go => cmd/xl-v1-utils.go | 2 +- .../xl-v1-utils_test.go | 2 +- xl-v1.go => cmd/xl-v1.go | 2 +- xl-v1_test.go => cmd/xl-v1_test.go | 2 +- main.go | 189 +---------------- 187 files changed, 425 insertions(+), 419 deletions(-) rename access-key.go => cmd/access-key.go (99%) rename api-datatypes.go => cmd/api-datatypes.go (99%) rename api-errors.go => cmd/api-errors.go (99%) rename api-headers.go => cmd/api-headers.go (95%) rename api-headers_test.go => cmd/api-headers_test.go (98%) rename api-resources.go => cmd/api-resources.go (99%) rename api-response-multipart.go => cmd/api-response-multipart.go (95%) rename api-response.go => cmd/api-response.go (99%) rename api-router.go => cmd/api-router.go (99%) rename auth-handler.go => cmd/auth-handler.go (99%) rename auth-handler_test.go => cmd/auth-handler_test.go (99%) rename benchmark-utils_test.go => cmd/benchmark-utils_test.go (99%) rename bucket-handlers-listobjects.go => cmd/bucket-handlers-listobjects.go (99%) rename bucket-handlers.go => cmd/bucket-handlers.go (99%) rename bucket-notification-datatypes.go => cmd/bucket-notification-datatypes.go (99%) rename bucket-notification-handlers.go => cmd/bucket-notification-handlers.go (99%) rename bucket-notification-handlers_test.go => cmd/bucket-notification-handlers_test.go (99%) rename bucket-notification-utils.go => cmd/bucket-notification-utils.go (99%) rename bucket-notification-utils_test.go => cmd/bucket-notification-utils_test.go (99%) rename bucket-policy-handlers.go => cmd/bucket-policy-handlers.go (99%) rename bucket-policy-handlers_test.go => cmd/bucket-policy-handlers_test.go (99%) rename bucket-policy-migrate.go => cmd/bucket-policy-migrate.go (99%) rename bucket-policy-parser.go => cmd/bucket-policy-parser.go (99%) rename bucket-policy-parser_test.go => cmd/bucket-policy-parser_test.go (99%) rename bucket-policy.go => cmd/bucket-policy.go (99%) rename build-constants.go => cmd/build-constants.go (58%) rename certs.go => cmd/certs.go (99%) rename certs_test.go => cmd/certs_test.go (99%) rename checkport.go => cmd/checkport.go (99%) rename checkport_test.go => cmd/checkport_test.go (99%) rename commands.go => cmd/commands.go (98%) rename config-migrate.go => cmd/config-migrate.go (99%) rename config-old.go => cmd/config-old.go (99%) rename config-v6.go => cmd/config-v6.go (99%) rename config.go => cmd/config.go (99%) rename control-main.go => cmd/control-main.go (99%) rename crossdomain-xml-handler.go => cmd/crossdomain-xml-handler.go (99%) rename damerau-levenshtein.go => cmd/damerau-levenshtein.go (99%) rename damerau-levenshtein_test.go => cmd/damerau-levenshtein_test.go (99%) rename erasure-createfile.go => cmd/erasure-createfile.go (99%) rename erasure-createfile_test.go => cmd/erasure-createfile_test.go (99%) rename erasure-healfile.go => cmd/erasure-healfile.go (99%) rename erasure-healfile_test.go => cmd/erasure-healfile_test.go (99%) rename erasure-readfile.go => cmd/erasure-readfile.go (99%) rename erasure-readfile_test.go => cmd/erasure-readfile_test.go (99%) rename erasure-utils.go => cmd/erasure-utils.go (99%) rename erasure-utils_test.go => cmd/erasure-utils_test.go (99%) rename erasure_test.go => cmd/erasure_test.go (99%) rename event-notifier.go => cmd/event-notifier.go (99%) rename event-notifier_test.go => cmd/event-notifier_test.go (99%) rename faulty-disk_test.go => cmd/faulty-disk_test.go (99%) rename format-config-v1.go => cmd/format-config-v1.go (99%) rename format-config-v1_test.go => cmd/format-config-v1_test.go (99%) rename fs-createfile.go => cmd/fs-createfile.go (98%) rename fs-v1-errors.go => cmd/fs-v1-errors.go (98%) rename fs-v1-metadata.go => cmd/fs-v1-metadata.go (98%) rename fs-v1-metadata_test.go => cmd/fs-v1-metadata_test.go (99%) rename fs-v1-multipart-common.go => cmd/fs-v1-multipart-common.go (99%) rename fs-v1-multipart.go => cmd/fs-v1-multipart.go (99%) rename fs-v1.go => cmd/fs-v1.go (99%) rename fs-v1_test.go => cmd/fs-v1_test.go (99%) rename generic-handlers.go => cmd/generic-handlers.go (99%) rename globals.go => cmd/globals.go (99%) rename handler-utils.go => cmd/handler-utils.go (99%) rename handler-utils_test.go => cmd/handler-utils_test.go (99%) rename host-to-ip.go => cmd/host-to-ip.go (99%) rename host-to-ip_test.go => cmd/host-to-ip_test.go (99%) rename httprange.go => cmd/httprange.go (99%) rename httprange_test.go => cmd/httprange_test.go (99%) rename leak-detect_test.go => cmd/leak-detect_test.go (99%) rename logger-console-hook.go => cmd/logger-console-hook.go (98%) rename logger-file-hook.go => cmd/logger-file-hook.go (99%) rename logger-syslog-hook_nix.go => cmd/logger-syslog-hook_nix.go (99%) rename logger-syslog-hook_windows.go => cmd/logger-syslog-hook_windows.go (98%) rename logger.go => cmd/logger.go (96%) rename logger_test.go => cmd/logger_test.go (98%) create mode 100644 cmd/main.go rename main_test.go => cmd/main_test.go (98%) rename namespace-lock.go => cmd/namespace-lock.go (99%) rename namespace-lock_test.go => cmd/namespace-lock_test.go (99%) rename notifiers.go => cmd/notifiers.go (99%) rename notifiers_test.go => cmd/notifiers_test.go (99%) rename notify-amqp.go => cmd/notify-amqp.go (99%) rename notify-elasticsearch.go => cmd/notify-elasticsearch.go (99%) rename notify-redis.go => cmd/notify-redis.go (99%) rename object-api-getobject_test.go => cmd/object-api-getobject_test.go (99%) rename object-api-getobjectinfo_test.go => cmd/object-api-getobjectinfo_test.go (99%) rename object-api-listobjects_test.go => cmd/object-api-listobjects_test.go (99%) rename object-api-multipart_test.go => cmd/object-api-multipart_test.go (99%) rename object-api-putobject_test.go => cmd/object-api-putobject_test.go (99%) rename object-common.go => cmd/object-common.go (99%) rename object-datatypes.go => cmd/object-datatypes.go (99%) rename object-errors.go => cmd/object-errors.go (99%) rename object-handlers-common.go => cmd/object-handlers-common.go (99%) rename object-handlers.go => cmd/object-handlers.go (99%) rename object-handlers_test.go => cmd/object-handlers_test.go (99%) rename object-interface.go => cmd/object-interface.go (99%) rename object-multipart-common.go => cmd/object-multipart-common.go (99%) rename object-utils.go => cmd/object-utils.go (99%) rename object-utils_test.go => cmd/object-utils_test.go (99%) rename object_api_suite_test.go => cmd/object_api_suite_test.go (99%) rename posix-dirent-fileno.go => cmd/posix-dirent-fileno.go (98%) rename posix-dirent-ino.go => cmd/posix-dirent-ino.go (98%) rename posix-list-dir-nix.go => cmd/posix-list-dir-nix.go (99%) rename posix-list-dir-others.go => cmd/posix-list-dir-others.go (99%) rename posix-list-dir_test.go => cmd/posix-list-dir_test.go (99%) rename posix-prepare-path.go => cmd/posix-prepare-path.go (99%) rename posix-utils_common.go => cmd/posix-utils_common.go (98%) rename posix-utils_nix.go => cmd/posix-utils_nix.go (99%) rename posix-utils_nix_test.go => cmd/posix-utils_nix_test.go (99%) rename posix-utils_test.go => cmd/posix-utils_test.go (99%) rename posix-utils_windows.go => cmd/posix-utils_windows.go (99%) rename posix-utils_windows_test.go => cmd/posix-utils_windows_test.go (99%) rename posix.go => cmd/posix.go (99%) rename posix_test.go => cmd/posix_test.go (99%) rename rate-limit-handler.go => cmd/rate-limit-handler.go (99%) rename routers.go => cmd/routers.go (99%) rename rpc-client.go => cmd/rpc-client.go (99%) rename rpc-control.go => cmd/rpc-control.go (99%) rename rpc-server-datatypes.go => cmd/rpc-server-datatypes.go (99%) rename rpc-server.go => cmd/rpc-server.go (99%) rename runtime-checks.go => cmd/runtime-checks.go (98%) rename server-main.go => cmd/server-main.go (99%) rename server-mux.go => cmd/server-mux.go (99%) rename server-mux_test.go => cmd/server-mux_test.go (99%) rename server-rlimit-nix.go => cmd/server-rlimit-nix.go (99%) rename server-rlimit-win.go => cmd/server-rlimit-win.go (98%) rename server-startup-msg.go => cmd/server-startup-msg.go (99%) rename server_test.go => cmd/server_test.go (99%) rename server_utils_test.go => cmd/server_utils_test.go (99%) rename signals.go => cmd/signals.go (98%) rename signature-jwt.go => cmd/signature-jwt.go (99%) rename signature-jwt_test.go => cmd/signature-jwt_test.go (99%) rename signature-v4-parser.go => cmd/signature-v4-parser.go (99%) rename signature-v4-parser_test.go => cmd/signature-v4-parser_test.go (99%) rename signature-v4-postpolicyform.go => cmd/signature-v4-postpolicyform.go (99%) rename signature-v4-postpolicyform_test.go => cmd/signature-v4-postpolicyform_test.go (99%) rename signature-v4-utils.go => cmd/signature-v4-utils.go (99%) rename signature-v4-utils_test.go => cmd/signature-v4-utils_test.go (99%) rename signature-v4.go => cmd/signature-v4.go (95%) rename signature-v4_test.go => cmd/signature-v4_test.go (99%) rename signature-verify-reader.go => cmd/signature-verify-reader.go (99%) rename storage-datatypes.go => cmd/storage-datatypes.go (98%) rename storage-errors.go => cmd/storage-errors.go (99%) rename storage-interface.go => cmd/storage-interface.go (99%) rename strconv-bytes.go => cmd/strconv-bytes.go (99%) rename strconv-bytes_test.go => cmd/strconv-bytes_test.go (99%) rename streaming-signature-v4.go => cmd/streaming-signature-v4.go (99%) rename streaming-signature-v4_test.go => cmd/streaming-signature-v4_test.go (99%) rename test-utils_test.go => cmd/test-utils_test.go (99%) rename tree-walk-pool.go => cmd/tree-walk-pool.go (99%) rename tree-walk-pool_test.go => cmd/tree-walk-pool_test.go (99%) rename tree-walk.go => cmd/tree-walk.go (99%) rename tree-walk_test.go => cmd/tree-walk_test.go (99%) rename trie.go => cmd/trie.go (99%) rename trie_test.go => cmd/trie_test.go (99%) rename typed-errors.go => cmd/typed-errors.go (99%) rename update-main.go => cmd/update-main.go (97%) rename update-notifier.go => cmd/update-notifier.go (99%) rename utils.go => cmd/utils.go (99%) rename utils_test.go => cmd/utils_test.go (99%) rename version-main.go => cmd/version-main.go (85%) rename version_test.go => cmd/version_test.go (92%) rename web-handlers.go => cmd/web-handlers.go (99%) rename web-handlers_test.go => cmd/web-handlers_test.go (99%) rename web-router.go => cmd/web-router.go (99%) rename xl-v1-bucket.go => cmd/xl-v1-bucket.go (99%) rename xl-v1-common.go => cmd/xl-v1-common.go (99%) rename xl-v1-errors.go => cmd/xl-v1-errors.go (99%) rename xl-v1-healing.go => cmd/xl-v1-healing.go (99%) rename xl-v1-healing_test.go => cmd/xl-v1-healing_test.go (99%) rename xl-v1-list-objects-heal.go => cmd/xl-v1-list-objects-heal.go (99%) rename xl-v1-list-objects.go => cmd/xl-v1-list-objects.go (99%) rename xl-v1-metadata.go => cmd/xl-v1-metadata.go (99%) rename xl-v1-metadata_test.go => cmd/xl-v1-metadata_test.go (99%) rename xl-v1-multipart-common.go => cmd/xl-v1-multipart-common.go (99%) rename xl-v1-multipart.go => cmd/xl-v1-multipart.go (99%) rename xl-v1-object.go => cmd/xl-v1-object.go (99%) rename xl-v1-object_test.go => cmd/xl-v1-object_test.go (99%) rename xl-v1-utils.go => cmd/xl-v1-utils.go (99%) rename xl-v1-utils_test.go => cmd/xl-v1-utils_test.go (99%) rename xl-v1.go => cmd/xl-v1.go (99%) rename xl-v1_test.go => cmd/xl-v1_test.go (99%) diff --git a/Makefile b/Makefile index eb442f4a3..596a9c082 100644 --- a/Makefile +++ b/Makefile @@ -71,19 +71,19 @@ verifiers: vet fmt lint cyclo spelling vet: @echo "Running $@:" - @GO15VENDOREXPERIMENT=1 go tool vet -all *.go + @GO15VENDOREXPERIMENT=1 go tool vet -all ./cmd @GO15VENDOREXPERIMENT=1 go tool vet -all ./pkg - @GO15VENDOREXPERIMENT=1 go tool vet -shadow=true *.go + @GO15VENDOREXPERIMENT=1 go tool vet -shadow=true ./cmd @GO15VENDOREXPERIMENT=1 go tool vet -shadow=true ./pkg fmt: @echo "Running $@:" - @GO15VENDOREXPERIMENT=1 gofmt -s -l *.go + @GO15VENDOREXPERIMENT=1 gofmt -s -l cmd @GO15VENDOREXPERIMENT=1 gofmt -s -l pkg lint: @echo "Running $@:" - @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/golint *.go + @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/golint github.com/minio/minio/cmd... @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/golint github.com/minio/minio/pkg... ineffassign: @@ -92,7 +92,7 @@ ineffassign: cyclo: @echo "Running $@:" - @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/gocyclo -over 65 *.go + @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/gocyclo -over 65 cmd @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/gocyclo -over 65 pkg build: getdeps verifiers $(UI_ASSETS) @@ -101,12 +101,12 @@ deadcode: @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/deadcode spelling: - @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell -error *.go + @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell -error cmd/**/* @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/misspell -error pkg/**/* test: build @echo "Running all minio testing:" - @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) . + @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/minio/cmd... @GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/minio/pkg... coverage: build @@ -139,8 +139,6 @@ experimental: verifiers clean: @echo "Cleaning up all the generated files:" - @rm -fv minio minio.test cover.out @find . -name '*.test' | xargs rm -fv - @rm -rf isa-l @rm -rf build @rm -rf release diff --git a/appveyor.yml b/appveyor.yml index 79c50a825..ca9ff06a1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,7 @@ install: # to run your custom scripts instead of automatic MSBuild build_script: - - go test -race . + - go test -race github.com/minio/minio/cmd... - go test -race github.com/minio/minio/pkg... - go test -coverprofile=coverage.txt -covermode=atomic - go run buildscripts/gen-ldflags.go > temp.txt diff --git a/buildscripts/gen-ldflags.go b/buildscripts/gen-ldflags.go index d07cfdebe..24a530e3b 100644 --- a/buildscripts/gen-ldflags.go +++ b/buildscripts/gen-ldflags.go @@ -28,11 +28,11 @@ import ( func genLDFlags(version string) string { var ldflagsStr string - ldflagsStr = "-X main.minioVersion=" + version - ldflagsStr += " -X main.minioReleaseTag=" + releaseTag(version) - ldflagsStr += " -X main.minioCommitID=" + commitID() - ldflagsStr += " -X main.minioShortCommitID=" + commitID()[:12] - ldflagsStr += " -X main.minioGOPATH=" + os.Getenv("GOPATH") + ldflagsStr = "-X github.com/minio/minio/cmd.Version=" + version + ldflagsStr += " -X github.com/minio/minio/cmd.ReleaseTag=" + releaseTag(version) + ldflagsStr += " -X github.com/minio/minio/cmd.CommitID=" + commitID() + ldflagsStr += " -X github.com/minio/minio/cmd.ShortCommitID=" + commitID()[:12] + ldflagsStr += " -X github.com/minio/minio/cmd.GOPATH=" + os.Getenv("GOPATH") return ldflagsStr } diff --git a/access-key.go b/cmd/access-key.go similarity index 99% rename from access-key.go rename to cmd/access-key.go index e5741b87e..1d23aec0e 100644 --- a/access-key.go +++ b/cmd/access-key.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/rand" diff --git a/api-datatypes.go b/cmd/api-datatypes.go similarity index 99% rename from api-datatypes.go rename to cmd/api-datatypes.go index 22cc4180f..a56942e61 100644 --- a/api-datatypes.go +++ b/cmd/api-datatypes.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/xml" diff --git a/api-errors.go b/cmd/api-errors.go similarity index 99% rename from api-errors.go rename to cmd/api-errors.go index 6ff94d26d..89b791935 100644 --- a/api-errors.go +++ b/cmd/api-errors.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/xml" diff --git a/api-headers.go b/cmd/api-headers.go similarity index 95% rename from api-headers.go rename to cmd/api-headers.go index e8fab555c..4bed0321d 100644 --- a/api-headers.go +++ b/cmd/api-headers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" @@ -44,7 +44,7 @@ func generateRequestID() []byte { func setCommonHeaders(w http.ResponseWriter) { // Set unique request ID for each reply. w.Header().Set("X-Amz-Request-Id", string(generateRequestID())) - w.Header().Set("Server", ("Minio/" + minioReleaseTag + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")")) + w.Header().Set("Server", ("Minio/" + ReleaseTag + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")")) w.Header().Set("Accept-Ranges", "bytes") } diff --git a/api-headers_test.go b/cmd/api-headers_test.go similarity index 98% rename from api-headers_test.go rename to cmd/api-headers_test.go index f8b13867d..150bd5ea4 100644 --- a/api-headers_test.go +++ b/cmd/api-headers_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/api-resources.go b/cmd/api-resources.go similarity index 99% rename from api-resources.go rename to cmd/api-resources.go index e4420cc67..bc1cfb316 100644 --- a/api-resources.go +++ b/cmd/api-resources.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/url" diff --git a/api-response-multipart.go b/cmd/api-response-multipart.go similarity index 95% rename from api-response-multipart.go rename to cmd/api-response-multipart.go index c039d9b97..b9baa1929 100644 --- a/api-response-multipart.go +++ b/cmd/api-response-multipart.go @@ -14,9 +14,9 @@ * limitations under the License. */ -// File carries any specific responses constructed/necessary in +// Package cmd file carries any specific responses constructed/necessary in // multipart operations. -package main +package cmd import "net/http" diff --git a/api-response.go b/cmd/api-response.go similarity index 99% rename from api-response.go rename to cmd/api-response.go index 1d12a3f51..20e4cfa4e 100644 --- a/api-response.go +++ b/cmd/api-response.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/xml" diff --git a/api-router.go b/cmd/api-router.go similarity index 99% rename from api-router.go rename to cmd/api-router.go index f868f9241..40e282e76 100644 --- a/api-router.go +++ b/cmd/api-router.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import router "github.com/gorilla/mux" diff --git a/auth-handler.go b/cmd/auth-handler.go similarity index 99% rename from auth-handler.go rename to cmd/auth-handler.go index 7731f81a9..19e63064f 100644 --- a/auth-handler.go +++ b/cmd/auth-handler.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/auth-handler_test.go b/cmd/auth-handler_test.go similarity index 99% rename from auth-handler_test.go rename to cmd/auth-handler_test.go index 34e838a55..ada9bf3c4 100644 --- a/auth-handler_test.go +++ b/cmd/auth-handler_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/benchmark-utils_test.go b/cmd/benchmark-utils_test.go similarity index 99% rename from benchmark-utils_test.go rename to cmd/benchmark-utils_test.go index 7f8dd02fa..419e84d7c 100644 --- a/benchmark-utils_test.go +++ b/cmd/benchmark-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/bucket-handlers-listobjects.go b/cmd/bucket-handlers-listobjects.go similarity index 99% rename from bucket-handlers-listobjects.go rename to cmd/bucket-handlers-listobjects.go index d1e7275ea..c4405c384 100644 --- a/bucket-handlers-listobjects.go +++ b/cmd/bucket-handlers-listobjects.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/http" diff --git a/bucket-handlers.go b/cmd/bucket-handlers.go similarity index 99% rename from bucket-handlers.go rename to cmd/bucket-handlers.go index fa24eef9f..2d1e3e936 100644 --- a/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/xml" diff --git a/bucket-notification-datatypes.go b/cmd/bucket-notification-datatypes.go similarity index 99% rename from bucket-notification-datatypes.go rename to cmd/bucket-notification-datatypes.go index d2a6b92a8..070a4d34c 100644 --- a/bucket-notification-datatypes.go +++ b/cmd/bucket-notification-datatypes.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/xml" diff --git a/bucket-notification-handlers.go b/cmd/bucket-notification-handlers.go similarity index 99% rename from bucket-notification-handlers.go rename to cmd/bucket-notification-handlers.go index 503668307..483e292e7 100644 --- a/bucket-notification-handlers.go +++ b/cmd/bucket-notification-handlers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/bucket-notification-handlers_test.go b/cmd/bucket-notification-handlers_test.go similarity index 99% rename from bucket-notification-handlers_test.go rename to cmd/bucket-notification-handlers_test.go index 90fe92901..246c83a59 100644 --- a/bucket-notification-handlers_test.go +++ b/cmd/bucket-notification-handlers_test.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "bytes" diff --git a/bucket-notification-utils.go b/cmd/bucket-notification-utils.go similarity index 99% rename from bucket-notification-utils.go rename to cmd/bucket-notification-utils.go index ce7c2a5b8..3df2d0687 100644 --- a/bucket-notification-utils.go +++ b/cmd/bucket-notification-utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "strings" diff --git a/bucket-notification-utils_test.go b/cmd/bucket-notification-utils_test.go similarity index 99% rename from bucket-notification-utils_test.go rename to cmd/bucket-notification-utils_test.go index 2c8d79092..bca6994ad 100644 --- a/bucket-notification-utils_test.go +++ b/cmd/bucket-notification-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/bucket-policy-handlers.go b/cmd/bucket-policy-handlers.go similarity index 99% rename from bucket-policy-handlers.go rename to cmd/bucket-policy-handlers.go index 944e39d0d..15be701d1 100644 --- a/bucket-policy-handlers.go +++ b/cmd/bucket-policy-handlers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/bucket-policy-handlers_test.go b/cmd/bucket-policy-handlers_test.go similarity index 99% rename from bucket-policy-handlers_test.go rename to cmd/bucket-policy-handlers_test.go index 24ebe5ccf..99b0e57a1 100644 --- a/bucket-policy-handlers_test.go +++ b/cmd/bucket-policy-handlers_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/bucket-policy-migrate.go b/cmd/bucket-policy-migrate.go similarity index 99% rename from bucket-policy-migrate.go rename to cmd/bucket-policy-migrate.go index 99bd431a3..50805cd8d 100644 --- a/bucket-policy-migrate.go +++ b/cmd/bucket-policy-migrate.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/bucket-policy-parser.go b/cmd/bucket-policy-parser.go similarity index 99% rename from bucket-policy-parser.go rename to cmd/bucket-policy-parser.go index f47d22278..acf0cb0fa 100644 --- a/bucket-policy-parser.go +++ b/cmd/bucket-policy-parser.go @@ -14,9 +14,9 @@ * limitations under the License. */ -// This file implements AWS Access Policy Language parser in +// Package cmd This file implements AWS Access Policy Language parser in // accordance with http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html -package main +package cmd import ( "encoding/json" diff --git a/bucket-policy-parser_test.go b/cmd/bucket-policy-parser_test.go similarity index 99% rename from bucket-policy-parser_test.go rename to cmd/bucket-policy-parser_test.go index 2c5670791..3fd1791ff 100644 --- a/bucket-policy-parser_test.go +++ b/cmd/bucket-policy-parser_test.go @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/bucket-policy.go b/cmd/bucket-policy.go similarity index 99% rename from bucket-policy.go rename to cmd/bucket-policy.go index 315ae2fb2..dcbfa9cf2 100644 --- a/bucket-policy.go +++ b/cmd/bucket-policy.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/build-constants.go b/cmd/build-constants.go similarity index 58% rename from build-constants.go rename to cmd/build-constants.go index 1183ebdca..0eb6c238f 100644 --- a/build-constants.go +++ b/cmd/build-constants.go @@ -1,5 +1,5 @@ /* - * Minio Cloud Storage, (C) 2015 Minio, Inc. + * Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,20 +14,20 @@ * limitations under the License. */ -package main +package cmd // DO NOT EDIT THIS FILE DIRECTLY. These are build-time constants // set through ‘buildscripts/gen-ldflags.go’. var ( - // minioGOPATH - GOPATH value at the time of build. - minioGOPATH = "" + // GOPATH - GOPATH value at the time of build. + GOPATH = "" - // minioVersion - version time.RFC3339. - minioVersion = "DEVELOPMENT.GOGET" - // minioReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ. - minioReleaseTag = "DEVELOPMENT.GOGET" - // minioCommitID - latest commit id. - minioCommitID = "DEVELOPMENT.GOGET" - // minioShortCommitID - first 12 characters from minioCommitID. - minioShortCommitID = minioCommitID[:12] + // Version - version time.RFC3339. + Version = "DEVELOPMENT.GOGET" + // ReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ. + ReleaseTag = "DEVELOPMENT.GOGET" + // CommitID - latest commit id. + CommitID = "DEVELOPMENT.GOGET" + // ShortCommitID - first 12 characters from CommitID. + ShortCommitID = CommitID[:12] ) diff --git a/certs.go b/cmd/certs.go similarity index 99% rename from certs.go rename to cmd/certs.go index f87bde0d1..a9e633bb1 100644 --- a/certs.go +++ b/cmd/certs.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/certs_test.go b/cmd/certs_test.go similarity index 99% rename from certs_test.go rename to cmd/certs_test.go index 0eb0f043a..6bf8aa540 100644 --- a/certs_test.go +++ b/cmd/certs_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/checkport.go b/cmd/checkport.go similarity index 99% rename from checkport.go rename to cmd/checkport.go index 00a5f6c33..0e354c592 100644 --- a/checkport.go +++ b/cmd/checkport.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/checkport_test.go b/cmd/checkport_test.go similarity index 99% rename from checkport_test.go rename to cmd/checkport_test.go index 41c986f1a..edd0d8925 100644 --- a/checkport_test.go +++ b/cmd/checkport_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/commands.go b/cmd/commands.go similarity index 98% rename from commands.go rename to cmd/commands.go index 135584772..f40e56553 100644 --- a/commands.go +++ b/cmd/commands.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "github.com/minio/cli" diff --git a/config-migrate.go b/cmd/config-migrate.go similarity index 99% rename from config-migrate.go rename to cmd/config-migrate.go index 6a25af5af..2731c7413 100644 --- a/config-migrate.go +++ b/cmd/config-migrate.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/config-old.go b/cmd/config-old.go similarity index 99% rename from config-old.go rename to cmd/config-old.go index dacc4f378..840019e6f 100644 --- a/config-old.go +++ b/cmd/config-old.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "os" diff --git a/config-v6.go b/cmd/config-v6.go similarity index 99% rename from config-v6.go rename to cmd/config-v6.go index b5a2fbdc4..e956f2338 100644 --- a/config-v6.go +++ b/cmd/config-v6.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/config.go b/cmd/config.go similarity index 99% rename from config.go rename to cmd/config.go index 79236cd85..84918ee95 100644 --- a/config.go +++ b/cmd/config.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/control-main.go b/cmd/control-main.go similarity index 99% rename from control-main.go rename to cmd/control-main.go index 87320b7db..b0026b3d1 100644 --- a/control-main.go +++ b/cmd/control-main.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/crossdomain-xml-handler.go b/cmd/crossdomain-xml-handler.go similarity index 99% rename from crossdomain-xml-handler.go rename to cmd/crossdomain-xml-handler.go index 1bc491671..2b1b79dc1 100644 --- a/crossdomain-xml-handler.go +++ b/cmd/crossdomain-xml-handler.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "net/http" diff --git a/damerau-levenshtein.go b/cmd/damerau-levenshtein.go similarity index 99% rename from damerau-levenshtein.go rename to cmd/damerau-levenshtein.go index a01361a5d..fcf38fe26 100644 --- a/damerau-levenshtein.go +++ b/cmd/damerau-levenshtein.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "math" diff --git a/damerau-levenshtein_test.go b/cmd/damerau-levenshtein_test.go similarity index 99% rename from damerau-levenshtein_test.go rename to cmd/damerau-levenshtein_test.go index 499ad85f7..fccec4405 100644 --- a/damerau-levenshtein_test.go +++ b/cmd/damerau-levenshtein_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "math" diff --git a/erasure-createfile.go b/cmd/erasure-createfile.go similarity index 99% rename from erasure-createfile.go rename to cmd/erasure-createfile.go index 3ecabc134..28b807108 100644 --- a/erasure-createfile.go +++ b/cmd/erasure-createfile.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/hex" diff --git a/erasure-createfile_test.go b/cmd/erasure-createfile_test.go similarity index 99% rename from erasure-createfile_test.go rename to cmd/erasure-createfile_test.go index 1e90a4bb9..5796202f2 100644 --- a/erasure-createfile_test.go +++ b/cmd/erasure-createfile_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/erasure-healfile.go b/cmd/erasure-healfile.go similarity index 99% rename from erasure-healfile.go rename to cmd/erasure-healfile.go index 943f3376e..56ae7de65 100644 --- a/erasure-healfile.go +++ b/cmd/erasure-healfile.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "encoding/hex" diff --git a/erasure-healfile_test.go b/cmd/erasure-healfile_test.go similarity index 99% rename from erasure-healfile_test.go rename to cmd/erasure-healfile_test.go index 59a00cce5..08c0bbc73 100644 --- a/erasure-healfile_test.go +++ b/cmd/erasure-healfile_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/erasure-readfile.go b/cmd/erasure-readfile.go similarity index 99% rename from erasure-readfile.go rename to cmd/erasure-readfile.go index 434475308..df20100ee 100644 --- a/erasure-readfile.go +++ b/cmd/erasure-readfile.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/hex" diff --git a/erasure-readfile_test.go b/cmd/erasure-readfile_test.go similarity index 99% rename from erasure-readfile_test.go rename to cmd/erasure-readfile_test.go index 67a56e461..3a6d5c3ca 100644 --- a/erasure-readfile_test.go +++ b/cmd/erasure-readfile_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/erasure-utils.go b/cmd/erasure-utils.go similarity index 99% rename from erasure-utils.go rename to cmd/erasure-utils.go index 008173eda..ec8a55f57 100644 --- a/erasure-utils.go +++ b/cmd/erasure-utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/erasure-utils_test.go b/cmd/erasure-utils_test.go similarity index 99% rename from erasure-utils_test.go rename to cmd/erasure-utils_test.go index c3121652b..83c7266d9 100644 --- a/erasure-utils_test.go +++ b/cmd/erasure-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/erasure_test.go b/cmd/erasure_test.go similarity index 99% rename from erasure_test.go rename to cmd/erasure_test.go index 4ca1baa2f..ceed3f449 100644 --- a/erasure_test.go +++ b/cmd/erasure_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/event-notifier.go b/cmd/event-notifier.go similarity index 99% rename from event-notifier.go rename to cmd/event-notifier.go index 27a2e46d3..3794cdb69 100644 --- a/event-notifier.go +++ b/cmd/event-notifier.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/event-notifier_test.go b/cmd/event-notifier_test.go similarity index 99% rename from event-notifier_test.go rename to cmd/event-notifier_test.go index 4fb08595b..d7b4b40b9 100644 --- a/event-notifier_test.go +++ b/cmd/event-notifier_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/faulty-disk_test.go b/cmd/faulty-disk_test.go similarity index 99% rename from faulty-disk_test.go rename to cmd/faulty-disk_test.go index cb1632cfc..3b67c53cb 100644 --- a/faulty-disk_test.go +++ b/cmd/faulty-disk_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd // Simulates disk returning errFaultyDisk on all methods of StorageAPI // interface after successCount number of successes. diff --git a/format-config-v1.go b/cmd/format-config-v1.go similarity index 99% rename from format-config-v1.go rename to cmd/format-config-v1.go index 11f789fdf..1036b21e4 100644 --- a/format-config-v1.go +++ b/cmd/format-config-v1.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" diff --git a/format-config-v1_test.go b/cmd/format-config-v1_test.go similarity index 99% rename from format-config-v1_test.go rename to cmd/format-config-v1_test.go index 10f83fbf4..92f1c63d6 100644 --- a/format-config-v1_test.go +++ b/cmd/format-config-v1_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/fs-createfile.go b/cmd/fs-createfile.go similarity index 98% rename from fs-createfile.go rename to cmd/fs-createfile.go index baac70375..2e32c6fbb 100644 --- a/fs-createfile.go +++ b/cmd/fs-createfile.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "io" diff --git a/fs-v1-errors.go b/cmd/fs-v1-errors.go similarity index 98% rename from fs-v1-errors.go rename to cmd/fs-v1-errors.go index f2f3f3100..19ff0a4f1 100644 --- a/fs-v1-errors.go +++ b/cmd/fs-v1-errors.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "errors" diff --git a/fs-v1-metadata.go b/cmd/fs-v1-metadata.go similarity index 98% rename from fs-v1-metadata.go rename to cmd/fs-v1-metadata.go index 79b07f7b8..2e133fc2b 100644 --- a/fs-v1-metadata.go +++ b/cmd/fs-v1-metadata.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" @@ -98,7 +98,7 @@ func newFSMetaV1() (fsMeta fsMetaV1) { fsMeta = fsMetaV1{} fsMeta.Version = "1.0.0" fsMeta.Format = "fs" - fsMeta.Minio.Release = minioReleaseTag + fsMeta.Minio.Release = ReleaseTag return fsMeta } diff --git a/fs-v1-metadata_test.go b/cmd/fs-v1-metadata_test.go similarity index 99% rename from fs-v1-metadata_test.go rename to cmd/fs-v1-metadata_test.go index e2f9940fa..4811d0715 100644 --- a/fs-v1-metadata_test.go +++ b/cmd/fs-v1-metadata_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/fs-v1-multipart-common.go b/cmd/fs-v1-multipart-common.go similarity index 99% rename from fs-v1-multipart-common.go rename to cmd/fs-v1-multipart-common.go index 3449b1015..c3ccdbdf7 100644 --- a/fs-v1-multipart-common.go +++ b/cmd/fs-v1-multipart-common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" diff --git a/fs-v1-multipart.go b/cmd/fs-v1-multipart.go similarity index 99% rename from fs-v1-multipart.go rename to cmd/fs-v1-multipart.go index 6f41452c8..84714774c 100644 --- a/fs-v1-multipart.go +++ b/cmd/fs-v1-multipart.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/md5" diff --git a/fs-v1.go b/cmd/fs-v1.go similarity index 99% rename from fs-v1.go rename to cmd/fs-v1.go index a798df063..8553c9808 100644 --- a/fs-v1.go +++ b/cmd/fs-v1.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/md5" diff --git a/fs-v1_test.go b/cmd/fs-v1_test.go similarity index 99% rename from fs-v1_test.go rename to cmd/fs-v1_test.go index a22520f9b..e657bc1ac 100644 --- a/fs-v1_test.go +++ b/cmd/fs-v1_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/generic-handlers.go b/cmd/generic-handlers.go similarity index 99% rename from generic-handlers.go rename to cmd/generic-handlers.go index da5f80554..c91c3e0c8 100644 --- a/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/http" diff --git a/globals.go b/cmd/globals.go similarity index 99% rename from globals.go rename to cmd/globals.go index 891e48f60..136a53580 100644 --- a/globals.go +++ b/cmd/globals.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "github.com/fatih/color" diff --git a/handler-utils.go b/cmd/handler-utils.go similarity index 99% rename from handler-utils.go rename to cmd/handler-utils.go index deb88c402..7e7909a6a 100644 --- a/handler-utils.go +++ b/cmd/handler-utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "io" diff --git a/handler-utils_test.go b/cmd/handler-utils_test.go similarity index 99% rename from handler-utils_test.go rename to cmd/handler-utils_test.go index 767f0a7eb..b3d6230e2 100644 --- a/handler-utils_test.go +++ b/cmd/handler-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/host-to-ip.go b/cmd/host-to-ip.go similarity index 99% rename from host-to-ip.go rename to cmd/host-to-ip.go index fc1352543..a20de6c7f 100644 --- a/host-to-ip.go +++ b/cmd/host-to-ip.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net" diff --git a/host-to-ip_test.go b/cmd/host-to-ip_test.go similarity index 99% rename from host-to-ip_test.go rename to cmd/host-to-ip_test.go index 1fa041e68..e29c22de6 100644 --- a/host-to-ip_test.go +++ b/cmd/host-to-ip_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/httprange.go b/cmd/httprange.go similarity index 99% rename from httprange.go rename to cmd/httprange.go index 71103ed2f..45e5e133e 100644 --- a/httprange.go +++ b/cmd/httprange.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/httprange_test.go b/cmd/httprange_test.go similarity index 99% rename from httprange_test.go rename to cmd/httprange_test.go index 78eaa9a4b..ed57f7f9e 100644 --- a/httprange_test.go +++ b/cmd/httprange_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/leak-detect_test.go b/cmd/leak-detect_test.go similarity index 99% rename from leak-detect_test.go rename to cmd/leak-detect_test.go index 838d63ff1..ff34528f7 100644 --- a/leak-detect_test.go +++ b/cmd/leak-detect_test.go @@ -5,7 +5,7 @@ // Package leaktest provides tools to detect leaked goroutines in tests. // To use it, call "defer leaktest.AfterTest(t)()" at the beginning of each // test that may use goroutines. -package main +package cmd import ( "runtime" diff --git a/logger-console-hook.go b/cmd/logger-console-hook.go similarity index 98% rename from logger-console-hook.go rename to cmd/logger-console-hook.go index f8b4d58b0..dbdf21d6b 100644 --- a/logger-console-hook.go +++ b/cmd/logger-console-hook.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "io/ioutil" diff --git a/logger-file-hook.go b/cmd/logger-file-hook.go similarity index 99% rename from logger-file-hook.go rename to cmd/logger-file-hook.go index 2f626f706..c58bf5359 100644 --- a/logger-file-hook.go +++ b/cmd/logger-file-hook.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/logger-syslog-hook_nix.go b/cmd/logger-syslog-hook_nix.go similarity index 99% rename from logger-syslog-hook_nix.go rename to cmd/logger-syslog-hook_nix.go index 2c497050a..b3b8281cd 100644 --- a/logger-syslog-hook_nix.go +++ b/cmd/logger-syslog-hook_nix.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/logger-syslog-hook_windows.go b/cmd/logger-syslog-hook_windows.go similarity index 98% rename from logger-syslog-hook_windows.go rename to cmd/logger-syslog-hook_windows.go index 08e26d595..7841b215a 100644 --- a/logger-syslog-hook_windows.go +++ b/cmd/logger-syslog-hook_windows.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd type syslogLogger struct { Enable bool `json:"enable"` diff --git a/logger.go b/cmd/logger.go similarity index 96% rename from logger.go rename to cmd/logger.go index 13d352df3..dd0191104 100644 --- a/logger.go +++ b/cmd/logger.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bufio" @@ -56,7 +56,7 @@ func stackInfo() string { stackBuf.ReadFrom(rawStack) // Strip GOPATH of the build system and return. - return strings.Replace(stackBuf.String(), minioGOPATH+"/src/", "", -1) + return strings.Replace(stackBuf.String(), GOPATH+"/src/", "", -1) } // errorIf synonymous with fatalIf but doesn't exit on error != nil diff --git a/logger_test.go b/cmd/logger_test.go similarity index 98% rename from logger_test.go rename to cmd/logger_test.go index 809361fa0..332ad6a56 100644 --- a/logger_test.go +++ b/cmd/logger_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 000000000..8f7ced10e --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,193 @@ +/* + * Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cmd + +import ( + "fmt" + "os" + "sort" + + "github.com/minio/cli" + "github.com/minio/mc/pkg/console" + "github.com/pkg/profile" +) + +var ( + // global flags for minio. + minioFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "help, h", + Usage: "Show help.", + }, + } +) + +// Help template for minio. +var minioHelpTemplate = `NAME: + {{.Name}} - {{.Usage}} + +DESCRIPTION: + {{.Description}} + +USAGE: + minio {{if .Flags}}[flags] {{end}}command{{if .Flags}}{{end}} [arguments...] + +COMMANDS: + {{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} + {{end}}{{if .Flags}} +FLAGS: + {{range .Flags}}{{.}} + {{end}}{{end}} +VERSION: + ` + Version + + `{{ "\n"}}` + +// init - check the environment before main starts +func init() { + // Check if minio was compiled using a supported version of Golang. + checkGoVersion() + + // Set global trace flag. + globalTrace = os.Getenv("MINIO_TRACE") == "1" +} + +func migrate() { + // Migrate config file + migrateConfig() + + // Migrate other configs here. +} + +func enableLoggers() { + // Enable all loggers here. + enableConsoleLogger() + enableFileLogger() + // Add your logger here. +} + +func findClosestCommands(command string) []string { + var closestCommands []string + for _, value := range commandsTree.PrefixMatch(command) { + closestCommands = append(closestCommands, value.(string)) + } + sort.Strings(closestCommands) + // Suggest other close commands - allow missed, wrongly added and + // even transposed characters + for _, value := range commandsTree.walk(commandsTree.root) { + if sort.SearchStrings(closestCommands, value.(string)) < len(closestCommands) { + continue + } + // 2 is arbitrary and represents the max + // allowed number of typed errors + if DamerauLevenshteinDistance(command, value.(string)) < 2 { + closestCommands = append(closestCommands, value.(string)) + } + } + return closestCommands +} + +func registerApp() *cli.App { + // Register all commands. + registerCommand(serverCmd) + registerCommand(versionCmd) + registerCommand(updateCmd) + registerCommand(controlCmd) + + // Set up app. + app := cli.NewApp() + app.Name = "Minio" + app.Author = "Minio.io" + app.Usage = "Cloud Storage Server." + app.Description = `Minio is an Amazon S3 compatible object storage server. Use it to store photos, videos, VMs, containers, log files, or any blob of data as objects.` + app.Flags = append(minioFlags, globalFlags...) + app.Commands = commands + app.CustomAppHelpTemplate = minioHelpTemplate + app.CommandNotFound = func(ctx *cli.Context, command string) { + msg := fmt.Sprintf("‘%s’ is not a minio sub-command. See ‘minio --help’.", command) + closestCommands := findClosestCommands(command) + if len(closestCommands) > 0 { + msg += fmt.Sprintf("\n\nDid you mean one of these?\n") + for _, cmd := range closestCommands { + msg += fmt.Sprintf(" ‘%s’\n", cmd) + } + } + console.Fatalln(msg) + } + return app +} + +func checkMainSyntax(c *cli.Context) { + configPath, err := getConfigPath() + if err != nil { + console.Fatalf("Unable to obtain user's home directory. \nError: %s\n", err) + } + if configPath == "" { + console.Fatalln("Config folder cannot be empty, please specify --config-dir .") + } +} + +// Main - main for minio server. +func Main() { + app := registerApp() + app.Before = func(c *cli.Context) error { + // Sets new config folder. + setGlobalConfigPath(c.GlobalString("config-dir")) + + // Valid input arguments to main. + checkMainSyntax(c) + + // Migrate any old version of config / state files to newer format. + migrate() + + // Initialize config. + err := initConfig() + fatalIf(err, "Unable to initialize minio config.") + + // Enable all loggers by now. + enableLoggers() + + // Set global quiet flag. + globalQuiet = c.Bool("quiet") || c.GlobalBool("quiet") + + // Do not print update messages, if quiet flag is set. + if !globalQuiet { + // Do not print any errors in release update function. + noError := true + updateMsg := getReleaseUpdate(minioUpdateStableURL, noError) + if updateMsg.Update { + console.Println(updateMsg) + } + } + + return nil + } + + // Set ``MINIO_PROFILE_DIR`` to the directory where profiling information should be persisted + profileDir := os.Getenv("MINIO_PROFILE_DIR") + // Enable profiler if ``MINIO_PROFILER`` is set. Supported options are [cpu, mem, block]. + switch os.Getenv("MINIO_PROFILER") { + case "cpu": + defer profile.Start(profile.CPUProfile, profile.ProfilePath(profileDir)).Stop() + case "mem": + defer profile.Start(profile.MemProfile, profile.ProfilePath(profileDir)).Stop() + case "block": + defer profile.Start(profile.BlockProfile, profile.ProfilePath(profileDir)).Stop() + } + + // Run the app - exit on error. + app.RunAndExitOnError() +} diff --git a/main_test.go b/cmd/main_test.go similarity index 98% rename from main_test.go rename to cmd/main_test.go index c13d2fa67..3fea9bdbc 100644 --- a/main_test.go +++ b/cmd/main_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/namespace-lock.go b/cmd/namespace-lock.go similarity index 99% rename from namespace-lock.go rename to cmd/namespace-lock.go index 2822adaff..44cf0df87 100644 --- a/namespace-lock.go +++ b/cmd/namespace-lock.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/namespace-lock_test.go b/cmd/namespace-lock_test.go similarity index 99% rename from namespace-lock_test.go rename to cmd/namespace-lock_test.go index f1d4dfa88..be2945df8 100644 --- a/namespace-lock_test.go +++ b/cmd/namespace-lock_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/notifiers.go b/cmd/notifiers.go similarity index 99% rename from notifiers.go rename to cmd/notifiers.go index 91a804dde..3da1533e7 100644 --- a/notifiers.go +++ b/cmd/notifiers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/notifiers_test.go b/cmd/notifiers_test.go similarity index 99% rename from notifiers_test.go rename to cmd/notifiers_test.go index 4b73cf770..ec9cdc33d 100644 --- a/notifiers_test.go +++ b/cmd/notifiers_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/notify-amqp.go b/cmd/notify-amqp.go similarity index 99% rename from notify-amqp.go rename to cmd/notify-amqp.go index 9a506be50..ac5698d62 100644 --- a/notify-amqp.go +++ b/cmd/notify-amqp.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "io/ioutil" diff --git a/notify-elasticsearch.go b/cmd/notify-elasticsearch.go similarity index 99% rename from notify-elasticsearch.go rename to cmd/notify-elasticsearch.go index e156079d6..a69818928 100644 --- a/notify-elasticsearch.go +++ b/cmd/notify-elasticsearch.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/notify-redis.go b/cmd/notify-redis.go similarity index 99% rename from notify-redis.go rename to cmd/notify-redis.go index 9d38d6beb..a59ea51a9 100644 --- a/notify-redis.go +++ b/cmd/notify-redis.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "io/ioutil" diff --git a/object-api-getobject_test.go b/cmd/object-api-getobject_test.go similarity index 99% rename from object-api-getobject_test.go rename to cmd/object-api-getobject_test.go index 8618a8bf5..99ab8fc72 100644 --- a/object-api-getobject_test.go +++ b/cmd/object-api-getobject_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/object-api-getobjectinfo_test.go b/cmd/object-api-getobjectinfo_test.go similarity index 99% rename from object-api-getobjectinfo_test.go rename to cmd/object-api-getobjectinfo_test.go index eec937c2b..b65a1190d 100644 --- a/object-api-getobjectinfo_test.go +++ b/cmd/object-api-getobjectinfo_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/object-api-listobjects_test.go b/cmd/object-api-listobjects_test.go similarity index 99% rename from object-api-listobjects_test.go rename to cmd/object-api-listobjects_test.go index 13e14ec46..e4e30e1ca 100644 --- a/object-api-listobjects_test.go +++ b/cmd/object-api-listobjects_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/object-api-multipart_test.go b/cmd/object-api-multipart_test.go similarity index 99% rename from object-api-multipart_test.go rename to cmd/object-api-multipart_test.go index 699225815..c2b7fe8d8 100644 --- a/object-api-multipart_test.go +++ b/cmd/object-api-multipart_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/object-api-putobject_test.go b/cmd/object-api-putobject_test.go similarity index 99% rename from object-api-putobject_test.go rename to cmd/object-api-putobject_test.go index 0bb3bf12a..11e90aa06 100644 --- a/object-api-putobject_test.go +++ b/cmd/object-api-putobject_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/object-common.go b/cmd/object-common.go similarity index 99% rename from object-common.go rename to cmd/object-common.go index a90b3bb2f..d9395f1b3 100644 --- a/object-common.go +++ b/cmd/object-common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "path/filepath" diff --git a/object-datatypes.go b/cmd/object-datatypes.go similarity index 99% rename from object-datatypes.go rename to cmd/object-datatypes.go index a4f9fc6b1..c1bec15a8 100644 --- a/object-datatypes.go +++ b/cmd/object-datatypes.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "time" diff --git a/object-errors.go b/cmd/object-errors.go similarity index 99% rename from object-errors.go rename to cmd/object-errors.go index c7cccd04f..a080a52e0 100644 --- a/object-errors.go +++ b/cmd/object-errors.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/object-handlers-common.go b/cmd/object-handlers-common.go similarity index 99% rename from object-handlers-common.go rename to cmd/object-handlers-common.go index c7fe42f52..ee765e9cb 100644 --- a/object-handlers-common.go +++ b/cmd/object-handlers-common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/http" diff --git a/object-handlers.go b/cmd/object-handlers.go similarity index 99% rename from object-handlers.go rename to cmd/object-handlers.go index 3a92a8955..9d5230e79 100644 --- a/object-handlers.go +++ b/cmd/object-handlers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/hex" diff --git a/object-handlers_test.go b/cmd/object-handlers_test.go similarity index 99% rename from object-handlers_test.go rename to cmd/object-handlers_test.go index 1e385688f..5e1676791 100644 --- a/object-handlers_test.go +++ b/cmd/object-handlers_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/object-interface.go b/cmd/object-interface.go similarity index 99% rename from object-interface.go rename to cmd/object-interface.go index 500a80aa7..8b868c9cb 100644 --- a/object-interface.go +++ b/cmd/object-interface.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "io" diff --git a/object-multipart-common.go b/cmd/object-multipart-common.go similarity index 99% rename from object-multipart-common.go rename to cmd/object-multipart-common.go index a66fe5a52..482275f33 100644 --- a/object-multipart-common.go +++ b/cmd/object-multipart-common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" diff --git a/object-utils.go b/cmd/object-utils.go similarity index 99% rename from object-utils.go rename to cmd/object-utils.go index 2421e81de..420099a91 100644 --- a/object-utils.go +++ b/cmd/object-utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/md5" diff --git a/object-utils_test.go b/cmd/object-utils_test.go similarity index 99% rename from object-utils_test.go rename to cmd/object-utils_test.go index a9919f7e1..8bb85a41e 100644 --- a/object-utils_test.go +++ b/cmd/object-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/object_api_suite_test.go b/cmd/object_api_suite_test.go similarity index 99% rename from object_api_suite_test.go rename to cmd/object_api_suite_test.go index f157a4457..a82bf7734 100644 --- a/object_api_suite_test.go +++ b/cmd/object_api_suite_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/posix-dirent-fileno.go b/cmd/posix-dirent-fileno.go similarity index 98% rename from posix-dirent-fileno.go rename to cmd/posix-dirent-fileno.go index e13c522f9..603d876a6 100644 --- a/posix-dirent-fileno.go +++ b/cmd/posix-dirent-fileno.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import "syscall" diff --git a/posix-dirent-ino.go b/cmd/posix-dirent-ino.go similarity index 98% rename from posix-dirent-ino.go rename to cmd/posix-dirent-ino.go index 3e6145131..c8cc000a9 100644 --- a/posix-dirent-ino.go +++ b/cmd/posix-dirent-ino.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import "syscall" diff --git a/posix-list-dir-nix.go b/cmd/posix-list-dir-nix.go similarity index 99% rename from posix-list-dir-nix.go rename to cmd/posix-list-dir-nix.go index a605cb2bd..1023ebf43 100644 --- a/posix-list-dir-nix.go +++ b/cmd/posix-list-dir-nix.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/posix-list-dir-others.go b/cmd/posix-list-dir-others.go similarity index 99% rename from posix-list-dir-others.go rename to cmd/posix-list-dir-others.go index d49a94831..abd3d965b 100644 --- a/posix-list-dir-others.go +++ b/cmd/posix-list-dir-others.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "io" diff --git a/posix-list-dir_test.go b/cmd/posix-list-dir_test.go similarity index 99% rename from posix-list-dir_test.go rename to cmd/posix-list-dir_test.go index efbaa8fd5..5ee7c1ed8 100644 --- a/posix-list-dir_test.go +++ b/cmd/posix-list-dir_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/posix-prepare-path.go b/cmd/posix-prepare-path.go similarity index 99% rename from posix-prepare-path.go rename to cmd/posix-prepare-path.go index 9925217b8..23db02eed 100644 --- a/posix-prepare-path.go +++ b/cmd/posix-prepare-path.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "path/filepath" diff --git a/posix-utils_common.go b/cmd/posix-utils_common.go similarity index 98% rename from posix-utils_common.go rename to cmd/posix-utils_common.go index e846d5cb3..4482a3279 100644 --- a/posix-utils_common.go +++ b/cmd/posix-utils_common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "strings" diff --git a/posix-utils_nix.go b/cmd/posix-utils_nix.go similarity index 99% rename from posix-utils_nix.go rename to cmd/posix-utils_nix.go index c71ff8e73..ebb59ad61 100644 --- a/posix-utils_nix.go +++ b/cmd/posix-utils_nix.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import "os" diff --git a/posix-utils_nix_test.go b/cmd/posix-utils_nix_test.go similarity index 99% rename from posix-utils_nix_test.go rename to cmd/posix-utils_nix_test.go index 013562c18..c76ccea97 100644 --- a/posix-utils_nix_test.go +++ b/cmd/posix-utils_nix_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "io/ioutil" diff --git a/posix-utils_test.go b/cmd/posix-utils_test.go similarity index 99% rename from posix-utils_test.go rename to cmd/posix-utils_test.go index 33d0bc6fd..b0b2cbbe7 100644 --- a/posix-utils_test.go +++ b/cmd/posix-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/posix-utils_windows.go b/cmd/posix-utils_windows.go similarity index 99% rename from posix-utils_windows.go rename to cmd/posix-utils_windows.go index 840c43e43..ef3f5edc5 100644 --- a/posix-utils_windows.go +++ b/cmd/posix-utils_windows.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "io" diff --git a/posix-utils_windows_test.go b/cmd/posix-utils_windows_test.go similarity index 99% rename from posix-utils_windows_test.go rename to cmd/posix-utils_windows_test.go index 50547edb9..d2c3c7ca6 100644 --- a/posix-utils_windows_test.go +++ b/cmd/posix-utils_windows_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/posix.go b/cmd/posix.go similarity index 99% rename from posix.go rename to cmd/posix.go index 2cafe07e7..cfc902196 100644 --- a/posix.go +++ b/cmd/posix.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/posix_test.go b/cmd/posix_test.go similarity index 99% rename from posix_test.go rename to cmd/posix_test.go index 0a24152d8..25ac68b43 100644 --- a/posix_test.go +++ b/cmd/posix_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/rate-limit-handler.go b/cmd/rate-limit-handler.go similarity index 99% rename from rate-limit-handler.go rename to cmd/rate-limit-handler.go index 45b7fb424..3fc371a4a 100644 --- a/rate-limit-handler.go +++ b/cmd/rate-limit-handler.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/routers.go b/cmd/routers.go similarity index 99% rename from routers.go rename to cmd/routers.go index 05bb8d36b..74b718aa3 100644 --- a/routers.go +++ b/cmd/routers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/rpc-client.go b/cmd/rpc-client.go similarity index 99% rename from rpc-client.go rename to cmd/rpc-client.go index 784145380..391ee2477 100644 --- a/rpc-client.go +++ b/cmd/rpc-client.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/http" diff --git a/rpc-control.go b/cmd/rpc-control.go similarity index 99% rename from rpc-control.go rename to cmd/rpc-control.go index 6c2b0a094..8e654b648 100644 --- a/rpc-control.go +++ b/cmd/rpc-control.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/rpc" diff --git a/rpc-server-datatypes.go b/cmd/rpc-server-datatypes.go similarity index 99% rename from rpc-server-datatypes.go rename to cmd/rpc-server-datatypes.go index 85b501901..f036c1fb7 100644 --- a/rpc-server-datatypes.go +++ b/cmd/rpc-server-datatypes.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd // GenericReply represents any generic RPC reply. type GenericReply struct{} diff --git a/rpc-server.go b/cmd/rpc-server.go similarity index 99% rename from rpc-server.go rename to cmd/rpc-server.go index 7550064a2..f57b175e1 100644 --- a/rpc-server.go +++ b/cmd/rpc-server.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "net/rpc" diff --git a/runtime-checks.go b/cmd/runtime-checks.go similarity index 98% rename from runtime-checks.go rename to cmd/runtime-checks.go index fc2d1d2b9..fc16e53e7 100644 --- a/runtime-checks.go +++ b/cmd/runtime-checks.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/server-main.go b/cmd/server-main.go similarity index 99% rename from server-main.go rename to cmd/server-main.go index a4e19c353..69883404c 100644 --- a/server-main.go +++ b/cmd/server-main.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/server-mux.go b/cmd/server-mux.go similarity index 99% rename from server-mux.go rename to cmd/server-mux.go index 69588db95..40ba94bfc 100644 --- a/server-mux.go +++ b/cmd/server-mux.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/tls" diff --git a/server-mux_test.go b/cmd/server-mux_test.go similarity index 99% rename from server-mux_test.go rename to cmd/server-mux_test.go index 96a1232ae..6d547b218 100644 --- a/server-mux_test.go +++ b/cmd/server-mux_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bufio" diff --git a/server-rlimit-nix.go b/cmd/server-rlimit-nix.go similarity index 99% rename from server-rlimit-nix.go rename to cmd/server-rlimit-nix.go index c69500a7c..e3ed78beb 100644 --- a/server-rlimit-nix.go +++ b/cmd/server-rlimit-nix.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd import ( "syscall" diff --git a/server-rlimit-win.go b/cmd/server-rlimit-win.go similarity index 98% rename from server-rlimit-win.go rename to cmd/server-rlimit-win.go index 9cc676709..8dd2a6c70 100644 --- a/server-rlimit-win.go +++ b/cmd/server-rlimit-win.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package main +package cmd func setMaxOpenFiles() error { // Golang uses Win32 file API (CreateFile, WriteFile, ReadFile, diff --git a/server-startup-msg.go b/cmd/server-startup-msg.go similarity index 99% rename from server-startup-msg.go rename to cmd/server-startup-msg.go index e87adede5..23c7d253c 100644 --- a/server-startup-msg.go +++ b/cmd/server-startup-msg.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/server_test.go b/cmd/server_test.go similarity index 99% rename from server_test.go rename to cmd/server_test.go index e81fe8eb2..651c4730d 100644 --- a/server_test.go +++ b/cmd/server_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/server_utils_test.go b/cmd/server_utils_test.go similarity index 99% rename from server_utils_test.go rename to cmd/server_utils_test.go index e95b6ee87..32eb208b6 100644 --- a/server_utils_test.go +++ b/cmd/server_utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/xml" diff --git a/signals.go b/cmd/signals.go similarity index 98% rename from signals.go rename to cmd/signals.go index e7e8b02bf..2431671de 100644 --- a/signals.go +++ b/cmd/signals.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/signature-jwt.go b/cmd/signature-jwt.go similarity index 99% rename from signature-jwt.go rename to cmd/signature-jwt.go index 5a7b82f20..107c02efd 100644 --- a/signature-jwt.go +++ b/cmd/signature-jwt.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/signature-jwt_test.go b/cmd/signature-jwt_test.go similarity index 99% rename from signature-jwt_test.go rename to cmd/signature-jwt_test.go index 9402a3ebf..8137dad3c 100644 --- a/signature-jwt_test.go +++ b/cmd/signature-jwt_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/signature-v4-parser.go b/cmd/signature-v4-parser.go similarity index 99% rename from signature-v4-parser.go rename to cmd/signature-v4-parser.go index 6ac12d453..a90945bc9 100644 --- a/signature-v4-parser.go +++ b/cmd/signature-v4-parser.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/url" diff --git a/signature-v4-parser_test.go b/cmd/signature-v4-parser_test.go similarity index 99% rename from signature-v4-parser_test.go rename to cmd/signature-v4-parser_test.go index 18d34123b..d0ec21cac 100644 --- a/signature-v4-parser_test.go +++ b/cmd/signature-v4-parser_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/url" diff --git a/signature-v4-postpolicyform.go b/cmd/signature-v4-postpolicyform.go similarity index 99% rename from signature-v4-postpolicyform.go rename to cmd/signature-v4-postpolicyform.go index 784b45a1e..8f05d6aa5 100644 --- a/signature-v4-postpolicyform.go +++ b/cmd/signature-v4-postpolicyform.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/base64" diff --git a/signature-v4-postpolicyform_test.go b/cmd/signature-v4-postpolicyform_test.go similarity index 99% rename from signature-v4-postpolicyform_test.go rename to cmd/signature-v4-postpolicyform_test.go index 805d97abd..b49e06d48 100644 --- a/signature-v4-postpolicyform_test.go +++ b/cmd/signature-v4-postpolicyform_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/signature-v4-utils.go b/cmd/signature-v4-utils.go similarity index 99% rename from signature-v4-utils.go rename to cmd/signature-v4-utils.go index d12034a51..d0956422d 100644 --- a/signature-v4-utils.go +++ b/cmd/signature-v4-utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/hmac" diff --git a/signature-v4-utils_test.go b/cmd/signature-v4-utils_test.go similarity index 99% rename from signature-v4-utils_test.go rename to cmd/signature-v4-utils_test.go index 980aa2f4c..9b4be2513 100644 --- a/signature-v4-utils_test.go +++ b/cmd/signature-v4-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/http" diff --git a/signature-v4.go b/cmd/signature-v4.go similarity index 95% rename from signature-v4.go rename to cmd/signature-v4.go index e61201d57..e0b051f17 100644 --- a/signature-v4.go +++ b/cmd/signature-v4.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// This file implements helper functions to validate AWS +// Package cmd This file implements helper functions to validate AWS // Signature Version '4' authorization header. // // This package provides comprehensive helpers for following signature @@ -22,7 +22,7 @@ // - Based on Authorization header. // - Based on Query parameters. // - Based on Form POST policy. -package main +package cmd import ( "bytes" @@ -205,13 +205,13 @@ func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, validate req := *r // Parse request query string. - preSignValues, err := parsePreSignV4(req.URL.Query()) + pSignValues, err := parsePreSignV4(req.URL.Query()) if err != ErrNone { return err } // Verify if the access key id matches. - if preSignValues.Credential.accessKey != cred.AccessKeyID { + if pSignValues.Credential.accessKey != cred.AccessKeyID { return ErrInvalidAccessKeyID } @@ -222,7 +222,7 @@ func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, validate } // Verify if region is valid. - sRegion := preSignValues.Credential.scope.region + sRegion := pSignValues.Credential.scope.region // Should validate region, only if region is set. Some operations // do not need region validated for example GetBucketLocation. if validateRegion { @@ -234,7 +234,7 @@ func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, validate } // Extract all the signed headers along with its values. - extractedSignedHeaders, errCode := extractSignedHeaders(preSignValues.SignedHeaders, req.Header) + extractedSignedHeaders, errCode := extractSignedHeaders(pSignValues.SignedHeaders, req.Header) if errCode != ErrNone { return errCode } @@ -246,13 +246,13 @@ func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, validate query.Set("X-Amz-Algorithm", signV4Algorithm) - if time.Now().UTC().Sub(preSignValues.Date) > time.Duration(preSignValues.Expires) { + if time.Now().UTC().Sub(pSignValues.Date) > time.Duration(pSignValues.Expires) { return ErrExpiredPresignRequest } // Save the date and expires. - t := preSignValues.Date - expireSeconds := int(time.Duration(preSignValues.Expires) / time.Second) + t := pSignValues.Date + expireSeconds := int(time.Duration(pSignValues.Expires) / time.Second) // Construct the query. query.Set("X-Amz-Date", t.Format(iso8601Format)) diff --git a/signature-v4_test.go b/cmd/signature-v4_test.go similarity index 99% rename from signature-v4_test.go rename to cmd/signature-v4_test.go index 22d4c8211..e066a3d5c 100644 --- a/signature-v4_test.go +++ b/cmd/signature-v4_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/signature-verify-reader.go b/cmd/signature-verify-reader.go similarity index 99% rename from signature-verify-reader.go rename to cmd/signature-verify-reader.go index b5fc68939..e50af8291 100644 --- a/signature-verify-reader.go +++ b/cmd/signature-verify-reader.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/hex" diff --git a/storage-datatypes.go b/cmd/storage-datatypes.go similarity index 98% rename from storage-datatypes.go rename to cmd/storage-datatypes.go index 430ae6775..b367041a7 100644 --- a/storage-datatypes.go +++ b/cmd/storage-datatypes.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/storage-errors.go b/cmd/storage-errors.go similarity index 99% rename from storage-errors.go rename to cmd/storage-errors.go index b322f8b42..787febf25 100644 --- a/storage-errors.go +++ b/cmd/storage-errors.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "errors" diff --git a/storage-interface.go b/cmd/storage-interface.go similarity index 99% rename from storage-interface.go rename to cmd/storage-interface.go index f3f6fb113..db1380186 100644 --- a/storage-interface.go +++ b/cmd/storage-interface.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd // StorageAPI interface. type StorageAPI interface { diff --git a/strconv-bytes.go b/cmd/strconv-bytes.go similarity index 99% rename from strconv-bytes.go rename to cmd/strconv-bytes.go index daf5df477..f0fc3438f 100644 --- a/strconv-bytes.go +++ b/cmd/strconv-bytes.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/strconv-bytes_test.go b/cmd/strconv-bytes_test.go similarity index 99% rename from strconv-bytes_test.go rename to cmd/strconv-bytes_test.go index a855b46b3..fd0206d16 100644 --- a/strconv-bytes_test.go +++ b/cmd/strconv-bytes_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/streaming-signature-v4.go b/cmd/streaming-signature-v4.go similarity index 99% rename from streaming-signature-v4.go rename to cmd/streaming-signature-v4.go index 3adf00bae..3c8fc4e6f 100644 --- a/streaming-signature-v4.go +++ b/cmd/streaming-signature-v4.go @@ -14,9 +14,9 @@ * limitations under the License. */ -// This file implements helper functions to validate Streaming AWS +// Package cmd This file implements helper functions to validate Streaming AWS // Signature Version '4' authorization header. -package main +package cmd import ( "bufio" diff --git a/streaming-signature-v4_test.go b/cmd/streaming-signature-v4_test.go similarity index 99% rename from streaming-signature-v4_test.go rename to cmd/streaming-signature-v4_test.go index 1c021cc01..831566b40 100644 --- a/streaming-signature-v4_test.go +++ b/cmd/streaming-signature-v4_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bufio" diff --git a/test-utils_test.go b/cmd/test-utils_test.go similarity index 99% rename from test-utils_test.go rename to cmd/test-utils_test.go index 5099b8d73..dcd6663a6 100644 --- a/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/tree-walk-pool.go b/cmd/tree-walk-pool.go similarity index 99% rename from tree-walk-pool.go rename to cmd/tree-walk-pool.go index 8bbde3cc0..4dd44ecb5 100644 --- a/tree-walk-pool.go +++ b/cmd/tree-walk-pool.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "errors" diff --git a/tree-walk-pool_test.go b/cmd/tree-walk-pool_test.go similarity index 99% rename from tree-walk-pool_test.go rename to cmd/tree-walk-pool_test.go index 32d7eda6e..7918681b8 100644 --- a/tree-walk-pool_test.go +++ b/cmd/tree-walk-pool_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/tree-walk.go b/cmd/tree-walk.go similarity index 99% rename from tree-walk.go rename to cmd/tree-walk.go index 8c9cc6785..d3ca940ad 100644 --- a/tree-walk.go +++ b/cmd/tree-walk.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "sort" diff --git a/tree-walk_test.go b/cmd/tree-walk_test.go similarity index 99% rename from tree-walk_test.go rename to cmd/tree-walk_test.go index 8c0dbe74f..b4e6064df 100644 --- a/tree-walk_test.go +++ b/cmd/tree-walk_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/trie.go b/cmd/trie.go similarity index 99% rename from trie.go rename to cmd/trie.go index 844458aa7..fb84c3556 100644 --- a/trie.go +++ b/cmd/trie.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd // This package borrows idea from - https://godoc.org/golang.org/x/text/internal/triegen diff --git a/trie_test.go b/cmd/trie_test.go similarity index 99% rename from trie_test.go rename to cmd/trie_test.go index b6b247fa6..f89af985a 100644 --- a/trie_test.go +++ b/cmd/trie_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/typed-errors.go b/cmd/typed-errors.go similarity index 99% rename from typed-errors.go rename to cmd/typed-errors.go index 7e502ce25..84cde5c73 100644 --- a/typed-errors.go +++ b/cmd/typed-errors.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "errors" diff --git a/update-main.go b/cmd/update-main.go similarity index 97% rename from update-main.go rename to cmd/update-main.go index 3069fff16..a6a8885fc 100644 --- a/update-main.go +++ b/cmd/update-main.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" @@ -152,7 +152,7 @@ func getReleaseUpdate(updateURL string, noError bool) updateMessage { // Initialize update message. updateMsg := updateMessage{ Download: downloadURL, - Version: minioVersion, + Version: Version, } // Instantiate a new client with 3 sec timeout. @@ -168,13 +168,13 @@ func getReleaseUpdate(updateURL string, noError bool) updateMessage { fatalIf((err), "Unable to read from update URL ‘"+newUpdateURL+"’.") // Error out if 'update' command is issued for development based builds. - if minioVersion == "DEVELOPMENT.GOGET" && !noError { + if Version == "DEVELOPMENT.GOGET" && !noError { fatalIf((errors.New("")), "Update mechanism is not supported for ‘go get’ based binary builds. Please download official releases from https://minio.io/#minio") } // Parse current minio version into RFC3339. - current, err := time.Parse(time.RFC3339, minioVersion) + current, err := time.Parse(time.RFC3339, Version) if err != nil && noError { return updateMsg } diff --git a/update-notifier.go b/cmd/update-notifier.go similarity index 99% rename from update-notifier.go rename to cmd/update-notifier.go index a872fe6a7..87f4d988c 100644 --- a/update-notifier.go +++ b/cmd/update-notifier.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/utils.go b/cmd/utils.go similarity index 99% rename from utils.go rename to cmd/utils.go index 83b0582f8..2e6715975 100644 --- a/utils.go +++ b/cmd/utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/base64" diff --git a/utils_test.go b/cmd/utils_test.go similarity index 99% rename from utils_test.go rename to cmd/utils_test.go index 0d368bd3c..becf63a48 100644 --- a/utils_test.go +++ b/cmd/utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "testing" diff --git a/version-main.go b/cmd/version-main.go similarity index 85% rename from version-main.go rename to cmd/version-main.go index 510072066..8b0bb8d03 100644 --- a/version-main.go +++ b/cmd/version-main.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "github.com/minio/cli" @@ -34,7 +34,7 @@ USAGE: } func mainVersion(ctx *cli.Context) { - console.Println("Version: " + minioVersion) - console.Println("Release-Tag: " + minioReleaseTag) - console.Println("Commit-ID: " + minioCommitID) + console.Println("Version: " + Version) + console.Println("Release-Tag: " + ReleaseTag) + console.Println("Commit-ID: " + CommitID) } diff --git a/version_test.go b/cmd/version_test.go similarity index 92% rename from version_test.go rename to cmd/version_test.go index c7c838b34..37e6ef710 100644 --- a/version_test.go +++ b/cmd/version_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "net/http" @@ -28,6 +28,6 @@ type VersionSuite struct{} var _ = Suite(&VersionSuite{}) func (s *VersionSuite) TestVersion(c *C) { - _, err := time.Parse(minioVersion, http.TimeFormat) + _, err := time.Parse(Version, http.TimeFormat) c.Assert(err, NotNil) } diff --git a/web-handlers.go b/cmd/web-handlers.go similarity index 99% rename from web-handlers.go rename to cmd/web-handlers.go index cda31496a..eae3e7683 100644 --- a/web-handlers.go +++ b/cmd/web-handlers.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" @@ -100,7 +100,7 @@ func (web *webAPIHandlers) ServerInfo(r *http.Request, args *WebGenericArgs, rep goruntime := fmt.Sprintf("Version: %s | CPUs: %s", runtime.Version(), strconv.Itoa(runtime.NumCPU())) reply.MinioEnvVars = os.Environ() - reply.MinioVersion = minioVersion + reply.MinioVersion = Version reply.MinioMemory = mem reply.MinioPlatform = platform reply.MinioRuntime = goruntime diff --git a/web-handlers_test.go b/cmd/web-handlers_test.go similarity index 99% rename from web-handlers_test.go rename to cmd/web-handlers_test.go index 50c3314c7..c8da764f7 100644 --- a/web-handlers_test.go +++ b/cmd/web-handlers_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" @@ -184,7 +184,7 @@ func testServerInfoWebHandler(obj ObjectLayer, instanceType string, t TestErrHan if err != nil { t.Fatalf("Failed, %v", err) } - if serverInfoReply.MinioVersion != minioVersion { + if serverInfoReply.MinioVersion != Version { t.Fatalf("Cannot get minio version from server info handler") } } diff --git a/web-router.go b/cmd/web-router.go similarity index 99% rename from web-router.go rename to cmd/web-router.go index 6e063a43a..f2a5e18e4 100644 --- a/web-router.go +++ b/cmd/web-router.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/xl-v1-bucket.go b/cmd/xl-v1-bucket.go similarity index 99% rename from xl-v1-bucket.go rename to cmd/xl-v1-bucket.go index 49ffdfd68..9e5501561 100644 --- a/xl-v1-bucket.go +++ b/cmd/xl-v1-bucket.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "path" diff --git a/xl-v1-common.go b/cmd/xl-v1-common.go similarity index 99% rename from xl-v1-common.go rename to cmd/xl-v1-common.go index f0f9edc59..28551c0ac 100644 --- a/xl-v1-common.go +++ b/cmd/xl-v1-common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "path" diff --git a/xl-v1-errors.go b/cmd/xl-v1-errors.go similarity index 99% rename from xl-v1-errors.go rename to cmd/xl-v1-errors.go index 18045d9e6..4ba07138e 100644 --- a/xl-v1-errors.go +++ b/cmd/xl-v1-errors.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "errors" diff --git a/xl-v1-healing.go b/cmd/xl-v1-healing.go similarity index 99% rename from xl-v1-healing.go rename to cmd/xl-v1-healing.go index 6fee67d4d..a9c5b9d1d 100644 --- a/xl-v1-healing.go +++ b/cmd/xl-v1-healing.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "time" diff --git a/xl-v1-healing_test.go b/cmd/xl-v1-healing_test.go similarity index 99% rename from xl-v1-healing_test.go rename to cmd/xl-v1-healing_test.go index f56f44a71..da18c8b8e 100644 --- a/xl-v1-healing_test.go +++ b/cmd/xl-v1-healing_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "testing" diff --git a/xl-v1-list-objects-heal.go b/cmd/xl-v1-list-objects-heal.go similarity index 99% rename from xl-v1-list-objects-heal.go rename to cmd/xl-v1-list-objects-heal.go index f9de4ed61..577ad453f 100644 --- a/xl-v1-list-objects-heal.go +++ b/cmd/xl-v1-list-objects-heal.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "path" diff --git a/xl-v1-list-objects.go b/cmd/xl-v1-list-objects.go similarity index 99% rename from xl-v1-list-objects.go rename to cmd/xl-v1-list-objects.go index 27867a8ff..2cac2943c 100644 --- a/xl-v1-list-objects.go +++ b/cmd/xl-v1-list-objects.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import "strings" diff --git a/xl-v1-metadata.go b/cmd/xl-v1-metadata.go similarity index 99% rename from xl-v1-metadata.go rename to cmd/xl-v1-metadata.go index 29caf4230..fbdd7f129 100644 --- a/xl-v1-metadata.go +++ b/cmd/xl-v1-metadata.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" @@ -119,7 +119,7 @@ func newXLMetaV1(object string, dataBlocks, parityBlocks int) (xlMeta xlMetaV1) xlMeta = xlMetaV1{} xlMeta.Version = "1.0.0" xlMeta.Format = "xl" - xlMeta.Minio.Release = minioReleaseTag + xlMeta.Minio.Release = ReleaseTag xlMeta.Erasure = erasureInfo{ Algorithm: erasureAlgorithmKlauspost, DataBlocks: dataBlocks, diff --git a/xl-v1-metadata_test.go b/cmd/xl-v1-metadata_test.go similarity index 99% rename from xl-v1-metadata_test.go rename to cmd/xl-v1-metadata_test.go index 7ea8e7059..b45062320 100644 --- a/xl-v1-metadata_test.go +++ b/cmd/xl-v1-metadata_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "strconv" diff --git a/xl-v1-multipart-common.go b/cmd/xl-v1-multipart-common.go similarity index 99% rename from xl-v1-multipart-common.go rename to cmd/xl-v1-multipart-common.go index 2dca561ca..7d85c2693 100644 --- a/xl-v1-multipart-common.go +++ b/cmd/xl-v1-multipart-common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" diff --git a/xl-v1-multipart.go b/cmd/xl-v1-multipart.go similarity index 99% rename from xl-v1-multipart.go rename to cmd/xl-v1-multipart.go index 58dd02783..7b1cdd929 100644 --- a/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/md5" diff --git a/xl-v1-object.go b/cmd/xl-v1-object.go similarity index 99% rename from xl-v1-object.go rename to cmd/xl-v1-object.go index 9e0775485..560407d51 100644 --- a/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "crypto/md5" diff --git a/xl-v1-object_test.go b/cmd/xl-v1-object_test.go similarity index 99% rename from xl-v1-object_test.go rename to cmd/xl-v1-object_test.go index bf9e0919c..ec6e633dc 100644 --- a/xl-v1-object_test.go +++ b/cmd/xl-v1-object_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "bytes" diff --git a/xl-v1-utils.go b/cmd/xl-v1-utils.go similarity index 99% rename from xl-v1-utils.go rename to cmd/xl-v1-utils.go index 07b499f64..66c5ac4a9 100644 --- a/xl-v1-utils.go +++ b/cmd/xl-v1-utils.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "encoding/json" diff --git a/xl-v1-utils_test.go b/cmd/xl-v1-utils_test.go similarity index 99% rename from xl-v1-utils_test.go rename to cmd/xl-v1-utils_test.go index 1f905a6db..85af8d0d9 100644 --- a/xl-v1-utils_test.go +++ b/cmd/xl-v1-utils_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "reflect" diff --git a/xl-v1.go b/cmd/xl-v1.go similarity index 99% rename from xl-v1.go rename to cmd/xl-v1.go index a15027bf2..b7bfa1376 100644 --- a/xl-v1.go +++ b/cmd/xl-v1.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "fmt" diff --git a/xl-v1_test.go b/cmd/xl-v1_test.go similarity index 99% rename from xl-v1_test.go rename to cmd/xl-v1_test.go index b56d581e0..e31aa803a 100644 --- a/xl-v1_test.go +++ b/cmd/xl-v1_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package main +package cmd import ( "os" diff --git a/main.go b/main.go index 3969e8f72..03fd0d366 100644 --- a/main.go +++ b/main.go @@ -1,192 +1,7 @@ -/* - * Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package main -import ( - "fmt" - "os" - "sort" - - "github.com/minio/cli" - "github.com/minio/mc/pkg/console" - "github.com/pkg/profile" -) - -var ( - // global flags for minio. - minioFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "help, h", - Usage: "Show help.", - }, - } -) - -// Help template for minio. -var minioHelpTemplate = `NAME: - {{.Name}} - {{.Usage}} - -DESCRIPTION: - {{.Description}} - -USAGE: - minio {{if .Flags}}[flags] {{end}}command{{if .Flags}}{{end}} [arguments...] - -COMMANDS: - {{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} - {{end}}{{if .Flags}} -FLAGS: - {{range .Flags}}{{.}} - {{end}}{{end}} -VERSION: - ` + minioVersion + - `{{ "\n"}}` - -// init - check the environment before main starts -func init() { - // Check if minio was compiled using a supported version of Golang. - checkGoVersion() - - // Set global trace flag. - globalTrace = os.Getenv("MINIO_TRACE") == "1" -} - -func migrate() { - // Migrate config file - migrateConfig() - - // Migrate other configs here. -} - -func enableLoggers() { - // Enable all loggers here. - enableConsoleLogger() - enableFileLogger() - // Add your logger here. -} - -func findClosestCommands(command string) []string { - var closestCommands []string - for _, value := range commandsTree.PrefixMatch(command) { - closestCommands = append(closestCommands, value.(string)) - } - sort.Strings(closestCommands) - // Suggest other close commands - allow missed, wrongly added and - // even transposed characters - for _, value := range commandsTree.walk(commandsTree.root) { - if sort.SearchStrings(closestCommands, value.(string)) < len(closestCommands) { - continue - } - // 2 is arbitrary and represents the max - // allowed number of typed errors - if DamerauLevenshteinDistance(command, value.(string)) < 2 { - closestCommands = append(closestCommands, value.(string)) - } - } - return closestCommands -} - -func registerApp() *cli.App { - // Register all commands. - registerCommand(serverCmd) - registerCommand(versionCmd) - registerCommand(updateCmd) - registerCommand(controlCmd) - - // Set up app. - app := cli.NewApp() - app.Name = "Minio" - app.Author = "Minio.io" - app.Usage = "Cloud Storage Server." - app.Description = `Minio is an Amazon S3 compatible object storage server. Use it to store photos, videos, VMs, containers, log files, or any blob of data as objects.` - app.Flags = append(minioFlags, globalFlags...) - app.Commands = commands - app.CustomAppHelpTemplate = minioHelpTemplate - app.CommandNotFound = func(ctx *cli.Context, command string) { - msg := fmt.Sprintf("‘%s’ is not a minio sub-command. See ‘minio --help’.", command) - closestCommands := findClosestCommands(command) - if len(closestCommands) > 0 { - msg += fmt.Sprintf("\n\nDid you mean one of these?\n") - for _, cmd := range closestCommands { - msg += fmt.Sprintf(" ‘%s’\n", cmd) - } - } - console.Fatalln(msg) - } - return app -} - -func checkMainSyntax(c *cli.Context) { - configPath, err := getConfigPath() - if err != nil { - console.Fatalf("Unable to obtain user's home directory. \nError: %s\n", err) - } - if configPath == "" { - console.Fatalln("Config folder cannot be empty, please specify --config-dir .") - } -} +import minio "github.com/minio/minio/cmd" func main() { - app := registerApp() - app.Before = func(c *cli.Context) error { - // Sets new config folder. - setGlobalConfigPath(c.GlobalString("config-dir")) - - // Valid input arguments to main. - checkMainSyntax(c) - - // Migrate any old version of config / state files to newer format. - migrate() - - // Initialize config. - err := initConfig() - fatalIf(err, "Unable to initialize minio config.") - - // Enable all loggers by now. - enableLoggers() - - // Set global quiet flag. - globalQuiet = c.Bool("quiet") || c.GlobalBool("quiet") - - // Do not print update messages, if quiet flag is set. - if !globalQuiet { - // Do not print any errors in release update function. - noError := true - updateMsg := getReleaseUpdate(minioUpdateStableURL, noError) - if updateMsg.Update { - console.Println(updateMsg) - } - } - - return nil - } - - // Set ``MINIO_PROFILE_DIR`` to the directory where profiling information should be persisted - profileDir := os.Getenv("MINIO_PROFILE_DIR") - // Enable profiler if ``MINIO_PROFILER`` is set. Supported options are [cpu, mem, block]. - switch os.Getenv("MINIO_PROFILER") { - case "cpu": - defer profile.Start(profile.CPUProfile, profile.ProfilePath(profileDir)).Stop() - case "mem": - defer profile.Start(profile.MemProfile, profile.ProfilePath(profileDir)).Stop() - case "block": - defer profile.Start(profile.BlockProfile, profile.ProfilePath(profileDir)).Stop() - } - - // Run the app - exit on error. - app.RunAndExitOnError() + minio.Main() }