mirror of
https://github.com/pgsty/minio.git
synced 2026-10-03 16:25:58 +03:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c59a41668 | |||
| 29a2ffef5d | |||
| c836c454cc | |||
| 0f7300058b | |||
| c5300ec279 | |||
| 3d8d12ba1b |
+3
-5
@@ -1,19 +1,17 @@
|
|||||||
FROM golang:1.6-alpine
|
FROM golang:1.7-alpine
|
||||||
|
|
||||||
WORKDIR /go/src/app
|
WORKDIR /go/src/app
|
||||||
ENV ALLOW_CONTAINER_ROOT=1
|
|
||||||
|
|
||||||
COPY . /go/src/app
|
COPY . /go/src/app
|
||||||
RUN \
|
RUN \
|
||||||
apk add --no-cache git && \
|
apk add --no-cache git && \
|
||||||
go-wrapper download && \
|
go-wrapper download && \
|
||||||
go-wrapper install && \
|
go-wrapper install -ldflags "-X github.com/minio/minio/cmd.Version=2016-10-07T01:16:39Z -X github.com/minio/minio/cmd.ReleaseTag=RELEASE.2016-10-07T01-16-39Z -X github.com/minio/minio/cmd.CommitID=b06a514ce0cf10f1d4c8bbc7b5cdbd956c567ab9" && \
|
||||||
mkdir -p /export/docker && \
|
mkdir -p /export/docker && \
|
||||||
cp /go/src/app/docs/Docker.md /export/docker/ && \
|
cp /go/src/app/docs/Docker.md /export/docker/ && \
|
||||||
rm -rf /go/pkg /go/src && \
|
rm -rf /go/pkg /go/src && \
|
||||||
apk del git
|
apk del git
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
ENTRYPOINT ["go-wrapper", "run", "server"]
|
ENTRYPOINT ["go-wrapper", "run"]
|
||||||
VOLUME ["/export"]
|
VOLUME ["/export"]
|
||||||
CMD ["/export"]
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
# Minio Quickstart Guide [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://goreportcard.com/report/minio/minio) [](https://codecov.io/gh/minio/minio)
|
# Minio Quickstart Guide [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://goreportcard.com/report/minio/minio) [](https://hub.docker.com/r/minio/minio/) [](https://codecov.io/gh/minio/minio)
|
||||||
|
|
||||||
Minio is an object storage server released under Apache License v2.0. It is compatible with Amazon S3 cloud storage service. It is best suited for storing unstructured data such as photos, videos, log files, backups and container / VM images. Size of an object can range from a few KBs to a maximum of 5TB.
|
Minio is an object storage server released under Apache License v2.0. It is compatible with Amazon S3 cloud storage service. It is best suited for storing unstructured data such as photos, videos, log files, backups and container / VM images. Size of an object can range from a few KBs to a maximum of 5TB.
|
||||||
|
|
||||||
## 1. Download
|
## 1. Download
|
||||||
|
|
||||||
Minio server is light enough to be bundled with the application stack, similar to NodeJS, Redis and MySQL.
|
Minio server is light enough to be bundled with the application stack, similar to NodeJS, Redis and MySQL.
|
||||||
|
|
||||||
| Platform| Architecture | URL|
|
| Platform| Architecture | URL|
|
||||||
@@ -17,7 +16,6 @@ Minio server is light enough to be bundled with the application stack, similar t
|
|||||||
|FreeBSD|64-bit|https://dl.minio.io/server/minio/release/freebsd-amd64/minio|
|
|FreeBSD|64-bit|https://dl.minio.io/server/minio/release/freebsd-amd64/minio|
|
||||||
|
|
||||||
### Install from Homebrew
|
### Install from Homebrew
|
||||||
|
|
||||||
Install minio packages using [Homebrew](http://brew.sh/)
|
Install minio packages using [Homebrew](http://brew.sh/)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -26,169 +24,79 @@ $ minio --help
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Install from Source
|
### Install from Source
|
||||||
|
|
||||||
Source installation is only intended for developers and advanced users. If you do not have a working Golang environment, please follow [How to install Golang](https://docs.minio.io/docs/how-to-install-golang).
|
Source installation is only intended for developers and advanced users. If you do not have a working Golang environment, please follow [How to install Golang](https://docs.minio.io/docs/how-to-install-golang).
|
||||||
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
||||||
$ go get -u github.com/minio/minio
|
$ go get -u github.com/minio/minio
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2. Run Minio Server
|
## 2. Run Minio Server
|
||||||
|
In the examples below, Minio serves the contents of the ``Photos`` directory as an object store.
|
||||||
|
|
||||||
|
### Docker Container
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ docker pull minio/minio
|
||||||
|
$ docker run -p 9000:9000 minio/minio server /export
|
||||||
|
```
|
||||||
|
|
||||||
|
Please visit Minio Docker quickstart guide for more [here](https://docs.minio.io/docs/minio-docker-quickstart-guide)
|
||||||
|
|
||||||
### GNU/Linux
|
### GNU/Linux
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
||||||
$ chmod +x minio
|
$ chmod +x minio
|
||||||
$ ./minio --help
|
$ ./minio --help
|
||||||
$ ./minio server ~/Photos
|
$ ./minio server ~/Photos
|
||||||
|
...
|
||||||
Endpoint: http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
AccessKey: USWUXHGYZQYFYFFIT3RE
|
|
||||||
SecretKey: MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
Region: us-east-1
|
|
||||||
|
|
||||||
Browser Access:
|
|
||||||
http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
|
|
||||||
Command-line Access: https://docs.minio.io/docs/minio-client-quickstart-guide
|
|
||||||
$ mc config host add myminio http://10.0.0.10:9000 USWUXHGYZQYFYFFIT3RE MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
|
|
||||||
Object API (Amazon S3 compatible):
|
|
||||||
Go: https://docs.minio.io/docs/golang-client-quickstart-guide
|
|
||||||
Java: https://docs.minio.io/docs/java-client-quickstart-guide
|
|
||||||
Python: https://docs.minio.io/docs/python-client-quickstart-guide
|
|
||||||
JavaScript: https://docs.minio.io/docs/javascript-client-quickstart-guide
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### OS X
|
### OS X
|
||||||
|
|
||||||
|
```sh
|
||||||
```sh
|
|
||||||
|
|
||||||
$ chmod 755 minio
|
$ chmod 755 minio
|
||||||
$ ./minio --help
|
$ ./minio --help
|
||||||
$ ./minio server ~/Photos
|
$ ./minio server ~/Photos
|
||||||
|
...
|
||||||
Endpoint: http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
AccessKey: USWUXHGYZQYFYFFIT3RE
|
|
||||||
SecretKey: MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
Region: us-east-1
|
|
||||||
|
|
||||||
Browser Access:
|
|
||||||
http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
|
|
||||||
Command-line Access: https://docs.minio.io/docs/minio-client-quickstart-guide
|
|
||||||
$ mc config host add myminio http://10.0.0.10:9000 USWUXHGYZQYFYFFIT3RE MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
|
|
||||||
Object API (Amazon S3 compatible):
|
|
||||||
Go: https://docs.minio.io/docs/golang-client-quickstart-guide
|
|
||||||
Java: https://docs.minio.io/docs/java-client-quickstart-guide
|
|
||||||
Python: https://docs.minio.io/docs/python-client-quickstart-guide
|
|
||||||
JavaScript: https://docs.minio.io/docs/javascript-client-quickstart-guide
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Microsoft Windows
|
### Microsoft Windows
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
||||||
C:\Users\Username\Downloads> minio.exe --help
|
C:\Users\Username\Downloads> minio.exe --help
|
||||||
C:\Users\Username\Downloads> minio.exe server D:\Photos
|
C:\Users\Username\Downloads> minio.exe server D:\Photos
|
||||||
|
...
|
||||||
Endpoint: http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
AccessKey: USWUXHGYZQYFYFFIT3RE
|
|
||||||
SecretKey: MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
Region: us-east-1
|
|
||||||
|
|
||||||
Browser Access:
|
|
||||||
http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
|
|
||||||
Command-line Access: https://docs.minio.io/docs/minio-client-quickstart-guide
|
|
||||||
$ mc.exe config host add myminio http://10.0.0.10:9000 USWUXHGYZQYFYFFIT3RE MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
|
|
||||||
Object API (Amazon S3 compatible):
|
|
||||||
Go: https://docs.minio.io/docs/golang-client-quickstart-guide
|
|
||||||
Java: https://docs.minio.io/docs/java-client-quickstart-guide
|
|
||||||
Python: https://docs.minio.io/docs/python-client-quickstart-guide
|
|
||||||
JavaScript: https://docs.minio.io/docs/javascript-client-quickstart-guide
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker Container
|
|
||||||
|
|
||||||
```sh
|
|
||||||
|
|
||||||
$ docker pull minio/minio
|
|
||||||
$ docker run -p 9000:9000 minio/minio
|
|
||||||
|
|
||||||
```
|
|
||||||
Please visit Minio Docker quickstart guide for more [here](https://docs.minio.io/docs/minio-docker-quickstart-guide)
|
|
||||||
|
|
||||||
### FreeBSD
|
### FreeBSD
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
||||||
$ chmod 755 minio
|
$ chmod 755 minio
|
||||||
$ ./minio --help
|
$ ./minio --help
|
||||||
$ ./minio server ~/Photos
|
$ ./minio server ~/Photos
|
||||||
|
...
|
||||||
Endpoint: http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
AccessKey: USWUXHGYZQYFYFFIT3RE
|
|
||||||
SecretKey: MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
Region: us-east-1
|
|
||||||
|
|
||||||
Browser Access:
|
|
||||||
http://10.0.0.10:9000 http://127.0.0.1:9000 http://172.17.0.1:9000
|
|
||||||
|
|
||||||
Command-line Access: https://docs.minio.io/docs/minio-client-quickstart-guide
|
|
||||||
$ mc config host add myminio http://10.0.0.10:9000 USWUXHGYZQYFYFFIT3RE MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
|
||||||
|
|
||||||
Object API (Amazon S3 compatible):
|
|
||||||
Go: https://docs.minio.io/docs/golang-client-quickstart-guide
|
|
||||||
Java: https://docs.minio.io/docs/java-client-quickstart-guide
|
|
||||||
Python: https://docs.minio.io/docs/python-client-quickstart-guide
|
|
||||||
JavaScript: https://docs.minio.io/docs/javascript-client-quickstart-guide
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Please visit official zfs FreeBSD guide for more details [here](https://www.freebsd.org/doc/handbook/zfs-quickstart.html)
|
Please visit official zfs FreeBSD guide for more details [here](https://www.freebsd.org/doc/handbook/zfs-quickstart.html)
|
||||||
|
|
||||||
## 3. Test Minio Server using Minio Browser
|
## 3. Test Minio Server using Minio Browser
|
||||||
|
|
||||||
Open a web browser and navigate to http://127.0.0.1:9000 to view your buckets on minio server.
|
Open a web browser and navigate to http://127.0.0.1:9000 to view your buckets on minio server.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## 4. Test Minio Server using `mc`
|
## 4. Test Minio Server using `mc`
|
||||||
|
|
||||||
|
|
||||||
Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide). Use `mc ls` command to list all the buckets on your minio server.
|
Install mc from [here](https://docs.minio.io/docs/minio-client-quickstart-guide). Use `mc ls` command to list all the buckets on your minio server.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ mc config host add myminio http://10.0.0.10:9000 USWUXHGYZQYFYFFIT3RE MOJRH0mkL1IPauahWITSVvyDrQbEEIwljvmxdq03
|
||||||
|
$ mc mb myminio/mybucket
|
||||||
$ mc ls myminio/
|
$ mc ls myminio/
|
||||||
[2015-08-05 08:13:22 IST] 0B andoria/
|
[2015-08-05 08:13:11 IST] 0B mybucket/
|
||||||
[2015-08-05 06:14:26 IST] 0B deflector/
|
|
||||||
[2015-08-05 08:13:11 IST] 0B ferenginar/
|
|
||||||
[2016-03-08 14:56:35 IST] 0B jarjarbing/
|
|
||||||
[2016-01-20 16:07:41 IST] 0B my.minio.io/
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For more examples please navigate to [Minio Client Complete Guide](https://docs.minio.io/docs/minio-client-complete-guide).
|
For more examples please navigate to [Minio Client Complete Guide](https://docs.minio.io/docs/minio-client-complete-guide).
|
||||||
|
|
||||||
|
|
||||||
## 5. Explore Further
|
## 5. Explore Further
|
||||||
|
|
||||||
- [Minio Erasure Code QuickStart Guide](https://docs.minio.io/docs/minio-erasure-code-quickstart-guide)
|
- [Minio Erasure Code QuickStart Guide](https://docs.minio.io/docs/minio-erasure-code-quickstart-guide)
|
||||||
- [Minio Docker Quickstart Guide](https://docs.minio.io/docs/minio-docker-quickstart-guide)
|
- [Minio Docker Quickstart Guide](https://docs.minio.io/docs/minio-docker-quickstart-guide)
|
||||||
- [Use `mc` with Minio Server](https://docs.minio.io/docs/minio-client-quickstart-guide)
|
- [Use `mc` with Minio Server](https://docs.minio.io/docs/minio-client-quickstart-guide)
|
||||||
@@ -196,6 +104,5 @@ For more examples please navigate to [Minio Client Complete Guide](https://docs.
|
|||||||
- [Use `s3cmd` with Minio Server](https://docs.minio.io/docs/s3cmd-with-minio)
|
- [Use `s3cmd` with Minio Server](https://docs.minio.io/docs/s3cmd-with-minio)
|
||||||
- [Use `minio-go` SDK with Minio Server](https://docs.minio.io/docs/golang-client-quickstart-guide)
|
- [Use `minio-go` SDK with Minio Server](https://docs.minio.io/docs/golang-client-quickstart-guide)
|
||||||
|
|
||||||
|
|
||||||
## 6. Contribute to Minio Project
|
## 6. Contribute to Minio Project
|
||||||
Please follow Minio [Contributor's Guide](https://github.com/minio/minio/blob/master/CONTRIBUTING.md)
|
Please follow Minio [Contributor's Guide](https://github.com/minio/minio/blob/master/CONTRIBUTING.md)
|
||||||
|
|||||||
+11
-6
@@ -20,6 +20,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
@@ -165,14 +167,17 @@ func Main() {
|
|||||||
|
|
||||||
// Do not print update messages, if quiet flag is set.
|
// Do not print update messages, if quiet flag is set.
|
||||||
if !globalQuiet {
|
if !globalQuiet {
|
||||||
// Do not print any errors in release update function.
|
if strings.HasPrefix(ReleaseTag, "RELEASE.") && c.Args().Get(0) != "update" {
|
||||||
noError := true
|
updateMsg, _, err := getReleaseUpdate(minioUpdateStableURL, time.Second*1)
|
||||||
updateMsg := getReleaseUpdate(minioUpdateStableURL, noError)
|
if err != nil {
|
||||||
if updateMsg.Update {
|
// Ignore all network related errors.
|
||||||
console.Println(updateMsg)
|
return nil
|
||||||
|
}
|
||||||
|
if updateMsg.Update {
|
||||||
|
console.Println(updateMsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -354,7 +354,7 @@ func doesSignatureMatch(hashedPayload string, r *http.Request, validateRegion bo
|
|||||||
for _, h := range signV4Values.SignedHeaders {
|
for _, h := range signV4Values.SignedHeaders {
|
||||||
if h == "content-length" {
|
if h == "content-length" {
|
||||||
header = cloneHeader(req.Header)
|
header = cloneHeader(req.Header)
|
||||||
header.Add("content-length", strconv.FormatInt(r.ContentLength, 10))
|
header.Set("content-length", strconv.FormatInt(r.ContentLength, 10))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+82
-52
@@ -17,10 +17,13 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -33,10 +36,6 @@ import (
|
|||||||
// command specific flags.
|
// command specific flags.
|
||||||
var (
|
var (
|
||||||
updateFlags = []cli.Flag{
|
updateFlags = []cli.Flag{
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "help, h",
|
|
||||||
Usage: "Help for update.",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "experimental, E",
|
Name: "experimental, E",
|
||||||
Usage: "Check experimental update.",
|
Usage: "Check experimental update.",
|
||||||
@@ -49,7 +48,7 @@ var updateCmd = cli.Command{
|
|||||||
Name: "update",
|
Name: "update",
|
||||||
Usage: "Check for a new software update.",
|
Usage: "Check for a new software update.",
|
||||||
Action: mainUpdate,
|
Action: mainUpdate,
|
||||||
Flags: updateFlags,
|
Flags: append(updateFlags, globalFlags...),
|
||||||
CustomHelpTemplate: `Name:
|
CustomHelpTemplate: `Name:
|
||||||
minio {{.Name}} - {{.Usage}}
|
minio {{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
@@ -114,7 +113,8 @@ func parseReleaseData(data string) (time.Time, error) {
|
|||||||
if releaseDateSplits[0] != "minio" {
|
if releaseDateSplits[0] != "minio" {
|
||||||
return time.Time{}, (errors.New("Update data malformed, missing minio tag"))
|
return time.Time{}, (errors.New("Update data malformed, missing minio tag"))
|
||||||
}
|
}
|
||||||
// "OFFICIAL" tag is still kept for backward compatibility, we should remove this for the next release.
|
// "OFFICIAL" tag is still kept for backward compatibility.
|
||||||
|
// We should remove this for the next release.
|
||||||
if releaseDateSplits[1] != "RELEASE" && releaseDateSplits[1] != "OFFICIAL" {
|
if releaseDateSplits[1] != "RELEASE" && releaseDateSplits[1] != "OFFICIAL" {
|
||||||
return time.Time{}, (errors.New("Update data malformed, missing RELEASE tag"))
|
return time.Time{}, (errors.New("Update data malformed, missing RELEASE tag"))
|
||||||
}
|
}
|
||||||
@@ -132,8 +132,28 @@ func parseReleaseData(data string) (time.Time, error) {
|
|||||||
return parsedDate, nil
|
return parsedDate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User Agent should always following the below style.
|
||||||
|
// Please open an issue to discuss any new changes here.
|
||||||
|
//
|
||||||
|
// Minio (OS; ARCH) APP/VER APP/VER
|
||||||
|
var (
|
||||||
|
userAgentSuffix = "Minio/" + Version + " " + "Minio/" + ReleaseTag + " " + "Minio/" + CommitID
|
||||||
|
userAgentPrefix = "Minio (" + runtime.GOOS + "; " + runtime.GOARCH + ") "
|
||||||
|
userAgent = userAgentPrefix + userAgentSuffix
|
||||||
|
)
|
||||||
|
|
||||||
|
// Check if the operating system is a docker container.
|
||||||
|
func isDocker() bool {
|
||||||
|
cgroup, err := ioutil.ReadFile("/proc/self/cgroup")
|
||||||
|
if err != nil && os.IsNotExist(err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
fatalIf(err, "Unable to read `cgroup` file.")
|
||||||
|
return bytes.Contains(cgroup, []byte("docker"))
|
||||||
|
}
|
||||||
|
|
||||||
// verify updates for releases.
|
// verify updates for releases.
|
||||||
func getReleaseUpdate(updateURL string, noError bool) updateMessage {
|
func getReleaseUpdate(updateURL string, duration time.Duration) (updateMsg updateMessage, errMsg string, err error) {
|
||||||
// Construct a new update url.
|
// Construct a new update url.
|
||||||
newUpdateURLPrefix := updateURL + "/" + runtime.GOOS + "-" + runtime.GOARCH
|
newUpdateURLPrefix := updateURL + "/" + runtime.GOOS + "-" + runtime.GOARCH
|
||||||
newUpdateURL := newUpdateURLPrefix + "/minio.shasum"
|
newUpdateURL := newUpdateURLPrefix + "/minio.shasum"
|
||||||
@@ -143,78 +163,80 @@ func getReleaseUpdate(updateURL string, noError bool) updateMessage {
|
|||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
case "windows":
|
||||||
// For windows.
|
// For windows.
|
||||||
downloadURL = newUpdateURLPrefix + "/minio.exe?update=yes"
|
downloadURL = newUpdateURLPrefix + "/minio.exe"
|
||||||
default:
|
default:
|
||||||
// For all other operating systems.
|
// For all other operating systems.
|
||||||
downloadURL = newUpdateURLPrefix + "/minio?update=yes"
|
downloadURL = newUpdateURLPrefix + "/minio"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize update message.
|
// Initialize update message.
|
||||||
updateMsg := updateMessage{
|
updateMsg = updateMessage{
|
||||||
Download: downloadURL,
|
Download: downloadURL,
|
||||||
Version: Version,
|
Version: Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate a new client with 3 sec timeout.
|
// Instantiate a new client with 3 sec timeout.
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 3 * time.Second,
|
Timeout: duration,
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch new update.
|
|
||||||
data, err := client.Get(newUpdateURL)
|
|
||||||
if err != nil && noError {
|
|
||||||
return updateMsg
|
|
||||||
}
|
|
||||||
fatalIf((err), "Unable to read from update URL ‘"+newUpdateURL+"’.")
|
|
||||||
|
|
||||||
// Error out if 'update' command is issued for development based builds.
|
|
||||||
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.
|
// Parse current minio version into RFC3339.
|
||||||
current, err := time.Parse(time.RFC3339, Version)
|
current, err := time.Parse(time.RFC3339, Version)
|
||||||
if err != nil && noError {
|
if err != nil {
|
||||||
return updateMsg
|
errMsg = "Unable to parse version string as time."
|
||||||
|
return
|
||||||
}
|
}
|
||||||
fatalIf((err), "Unable to parse version string as time.")
|
|
||||||
|
|
||||||
// Verify if current minio version is zero.
|
// Verify if current minio version is zero.
|
||||||
if current.IsZero() && !noError {
|
if current.IsZero() {
|
||||||
fatalIf((errors.New("")),
|
err = errors.New("date should not be zero")
|
||||||
"Updates mechanism is not supported for custom builds. Please download official releases from https://minio.io/#minio")
|
errMsg = "Updates mechanism is not supported for custom builds. Please download official releases from https://minio.io/#minio"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize new request.
|
||||||
|
req, err := http.NewRequest("GET", newUpdateURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set user agent.
|
||||||
|
req.Header.Set("User-Agent", userAgent+" "+fmt.Sprintf("Docker/%t", isDocker()))
|
||||||
|
|
||||||
|
// Fetch new update.
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify if we have a valid http response i.e http.StatusOK.
|
// Verify if we have a valid http response i.e http.StatusOK.
|
||||||
if data != nil {
|
if resp != nil {
|
||||||
if data.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
// Return quickly if noError is set.
|
errMsg = "Failed to retrieve update notice."
|
||||||
if noError {
|
err = errors.New("http status : " + resp.Status)
|
||||||
return updateMsg
|
return
|
||||||
}
|
|
||||||
fatalIf((errors.New("")), "Failed to retrieve update notice. "+data.Status)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the response body.
|
// Read the response body.
|
||||||
updateBody, err := ioutil.ReadAll(data.Body)
|
updateBody, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil && noError {
|
if err != nil {
|
||||||
return updateMsg
|
errMsg = "Failed to retrieve update notice. Please try again later."
|
||||||
|
return
|
||||||
}
|
}
|
||||||
fatalIf((err), "Failed to retrieve update notice. Please try again later.")
|
|
||||||
|
errMsg = "Failed to retrieve update notice. Please try again later. Please report this issue at https://github.com/minio/minio/issues"
|
||||||
|
|
||||||
// Parse the date if its valid.
|
// Parse the date if its valid.
|
||||||
latest, err := parseReleaseData(string(updateBody))
|
latest, err := parseReleaseData(string(updateBody))
|
||||||
if err != nil && noError {
|
if err != nil {
|
||||||
return updateMsg
|
return
|
||||||
}
|
}
|
||||||
errMsg := "Failed to retrieve update notice. Please try again later. Please report this issue at https://github.com/minio/minio/issues"
|
|
||||||
fatalIf(err, errMsg)
|
|
||||||
|
|
||||||
// Verify if the date is not zero.
|
// Verify if the date is not zero.
|
||||||
if latest.IsZero() && !noError {
|
if latest.IsZero() {
|
||||||
fatalIf((errors.New("")), errMsg)
|
err = errors.New("date should not be zero")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the update latest?.
|
// Is the update latest?.
|
||||||
@@ -223,18 +245,26 @@ func getReleaseUpdate(updateURL string, noError bool) updateMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return update message.
|
// Return update message.
|
||||||
return updateMsg
|
return updateMsg, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// main entry point for update command.
|
// main entry point for update command.
|
||||||
func mainUpdate(ctx *cli.Context) {
|
func mainUpdate(ctx *cli.Context) {
|
||||||
// Print all errors as they occur.
|
// Error out if 'update' command is issued for development based builds.
|
||||||
noError := false
|
if Version == "DEVELOPMENT.GOGET" {
|
||||||
|
fatalIf(errors.New(""), "Update mechanism is not supported for ‘go get’ based binary builds. Please download official releases from https://minio.io/#minio")
|
||||||
|
}
|
||||||
|
|
||||||
// Check for update.
|
// Check for update.
|
||||||
|
var updateMsg updateMessage
|
||||||
|
var errMsg string
|
||||||
|
var err error
|
||||||
|
var secs = time.Second * 3
|
||||||
if ctx.Bool("experimental") {
|
if ctx.Bool("experimental") {
|
||||||
console.Println(getReleaseUpdate(minioUpdateExperimentalURL, noError))
|
updateMsg, errMsg, err = getReleaseUpdate(minioUpdateExperimentalURL, secs)
|
||||||
} else {
|
} else {
|
||||||
console.Println(getReleaseUpdate(minioUpdateStableURL, noError))
|
updateMsg, errMsg, err = getReleaseUpdate(minioUpdateStableURL, secs)
|
||||||
}
|
}
|
||||||
|
fatalIf(err, errMsg)
|
||||||
|
console.Println(updateMsg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user