commit
c73a4f9d68
11
.travis.yml
Normal file
11
.travis.yml
Normal file
@ -0,0 +1,11 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.10.x
|
||||
|
||||
|
||||
before_install:
|
||||
- make build-dev-deps
|
||||
|
||||
script:
|
||||
- make lint
|
51
Jenkinsfile
vendored
Normal file
51
Jenkinsfile
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
node('node') {
|
||||
|
||||
// Install the desired Go version
|
||||
def root = tool name: 'Go 1.10', type: 'go'
|
||||
|
||||
// Export environment variables pointing to the directory where Go was installed
|
||||
withEnv(["GOROOT=${root}", "PATH+GO=${root}/bin", "PATH=$PATH:${root}/bin"]) {
|
||||
sh 'go version'
|
||||
}
|
||||
try {
|
||||
|
||||
stage 'Checkout'
|
||||
|
||||
checkout scm
|
||||
|
||||
stage 'Test'
|
||||
|
||||
sh """#!/bin/bash -e
|
||||
echo $root
|
||||
echo "path="
|
||||
echo $PATH
|
||||
make build-dev-deps lint
|
||||
"""
|
||||
|
||||
stage 'Build Docker'
|
||||
echo 'Build'
|
||||
|
||||
stage 'Deploy'
|
||||
echo 'Deploy'
|
||||
|
||||
|
||||
stage 'Cleanup'
|
||||
|
||||
echo 'prune and cleanup'
|
||||
|
||||
}
|
||||
|
||||
catch (err) {
|
||||
currentBuild.result = "FAILURE"
|
||||
|
||||
/*
|
||||
mail body: "project build error is here: ${env.BUILD_URL}" ,
|
||||
from: 'build@storj.io',
|
||||
replyTo: 'build@storj.io',
|
||||
subject: 'project build failed',
|
||||
to: "${env.CHANGE_AUTHOR_EMAIL}"
|
||||
|
||||
throw err
|
||||
*/
|
||||
}
|
||||
}
|
16
Makefile
16
Makefile
@ -1,14 +1,17 @@
|
||||
.PHONY: test lint
|
||||
|
||||
lint: check-copyrights
|
||||
@echo "Running ${@}"
|
||||
@gometalinter.v2 \
|
||||
@gometalinter \
|
||||
--deadline=60s \
|
||||
--disable-all \
|
||||
--enable=golint \
|
||||
--enable=goimports \
|
||||
--enable=vet \
|
||||
--enable=deadcode \
|
||||
--enable=gosimple \
|
||||
--enable=goconst \
|
||||
--exclude=.*\.pb\.go \
|
||||
--exclude=.*_test.go \
|
||||
./...
|
||||
|
||||
check-copyrights:
|
||||
@ -22,6 +25,11 @@ proto:
|
||||
|
||||
|
||||
build-dev-deps:
|
||||
go get -u golang.org/x/vgo
|
||||
vgo install ./...
|
||||
go get -u github.com/golang/protobuf/protoc-gen-go
|
||||
go get -u gopkg.in/alecthomas/gometalinter.v2
|
||||
gometalinter.v2 --install
|
||||
go get -u github.com/alecthomas/gometalinter
|
||||
gometalinter --install --force
|
||||
|
||||
test:
|
||||
go test -v ./...
|
||||
|
@ -1,11 +0,0 @@
|
||||
# build
|
||||
FROM golang:alpine AS build-env
|
||||
ADD . /go/src/research/lang/storj-node-go/
|
||||
RUN cd /go/src/research/lang/storj-node-go/ && go build -o main
|
||||
|
||||
# final stage
|
||||
FROM alpine
|
||||
WORKDIR /app
|
||||
COPY --from=build-env /go/src/research/lang/storj-node-go/main /app/
|
||||
|
||||
ENTRYPOINT ./main
|
@ -33,6 +33,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Main is the exported CLI executable function
|
||||
func Main() error {
|
||||
encKey := sha256.Sum256([]byte(*key))
|
||||
fc, err := infectious.NewFEC(*rsk, *rsn)
|
||||
|
@ -27,6 +27,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Main is the exported CLI executable function
|
||||
func Main() error {
|
||||
pieces, err := ioutil.ReadDir(flag.Arg(0))
|
||||
if err != nil {
|
||||
|
@ -42,6 +42,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Main is the exported CLI executable function
|
||||
func Main() error {
|
||||
encKey := sha256.Sum256([]byte(*key))
|
||||
fc, err := infectious.NewFEC(*rsk, *rsn)
|
||||
|
@ -36,6 +36,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Main is the exported CLI executable function
|
||||
func Main() error {
|
||||
err := os.MkdirAll(flag.Arg(0), 0755)
|
||||
if err != nil {
|
||||
|
32
go.mod
32
go.mod
@ -1,9 +1,29 @@
|
||||
module "storj.io/storj"
|
||||
module storj.io/storj
|
||||
|
||||
require (
|
||||
"github.com/spf13/viper" v1.0.2
|
||||
"github.com/tyler-smith/go-bip39" v0.0.0-20160629163856-8e7a99b3e716
|
||||
"github.com/urfave/cli" v1.20.0
|
||||
"github.com/zeebo/errs" v0.1.0
|
||||
"golang.org/x/crypto" v0.0.0-20180410182641-f70185d77e82
|
||||
github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/go-redis/redis v0.0.0-20180417061816-9ccc23344a52
|
||||
github.com/gogo/protobuf v1.0.0
|
||||
github.com/golang/protobuf v1.0.0
|
||||
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
|
||||
github.com/magiconair/properties v1.7.6
|
||||
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238
|
||||
github.com/pelletier/go-toml v1.1.0
|
||||
github.com/spacemonkeygo/errors v0.0.0-20171212215202-9064522e9fd1
|
||||
github.com/spf13/afero v1.1.0
|
||||
github.com/spf13/cast v1.2.0
|
||||
github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec
|
||||
github.com/spf13/pflag v1.0.1
|
||||
github.com/spf13/viper v1.0.2
|
||||
github.com/tyler-smith/go-bip39 v0.0.0-20160629163856-8e7a99b3e716
|
||||
github.com/urfave/cli v1.20.0
|
||||
github.com/vivint/infectious v0.0.0-20180418194855-57d6abddc3d4
|
||||
github.com/zeebo/errs v0.1.0
|
||||
golang.org/x/crypto v0.0.0-20180410182641-f70185d77e82
|
||||
golang.org/x/net v0.0.0-20180420171651-5f9ae10d9af5
|
||||
golang.org/x/sys v0.0.0-20180430173509-4adea008a5e5
|
||||
golang.org/x/text v0.3.0
|
||||
google.golang.org/genproto v0.0.0-20180427144745-86e600f69ee4
|
||||
google.golang.org/grpc v1.11.3
|
||||
gopkg.in/yaml.v2 v2.2.1
|
||||
)
|
||||
|
@ -141,7 +141,7 @@ func ServeContent(w http.ResponseWriter, r *http.Request, name string,
|
||||
|
||||
w.WriteHeader(code)
|
||||
|
||||
if r.Method != "HEAD" {
|
||||
if r.Method != http.MethodHead {
|
||||
r := sendContent()
|
||||
defer r.Close()
|
||||
io.CopyN(w, r, sendSize)
|
||||
@ -178,7 +178,7 @@ func checkPreconditions(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
switch checkIfNoneMatch(w, r) {
|
||||
case condFalse:
|
||||
if r.Method == "GET" || r.Method == "HEAD" {
|
||||
if r.Method == http.MethodGet || r.Method == http.MethodHead {
|
||||
writeNotModified(w)
|
||||
return true, ""
|
||||
}
|
||||
@ -284,7 +284,7 @@ func checkIfNoneMatch(w http.ResponseWriter, r *http.Request) condResult {
|
||||
}
|
||||
|
||||
func checkIfModifiedSince(r *http.Request, modtime time.Time) condResult {
|
||||
if r.Method != "GET" && r.Method != "HEAD" {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
return condNone
|
||||
}
|
||||
ims := r.Header.Get("If-Modified-Since")
|
||||
@ -305,7 +305,7 @@ func checkIfModifiedSince(r *http.Request, modtime time.Time) condResult {
|
||||
|
||||
func checkIfRange(w http.ResponseWriter, r *http.Request, modtime time.Time) (
|
||||
rv condResult) {
|
||||
if r.Method != "GET" && r.Method != "HEAD" {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
return condNone
|
||||
}
|
||||
ir := r.Header.Get("If-Range")
|
||||
@ -419,6 +419,7 @@ func parseRange(s string, size int64) ([]httpRange, error) {
|
||||
if !strings.HasPrefix(s, b) {
|
||||
return nil, errors.New("invalid range")
|
||||
}
|
||||
|
||||
var ranges []httpRange
|
||||
noOverlap := false
|
||||
for _, ra := range strings.Split(s[len(b):], ",") {
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// FileHandleRanger returns a RangerCloser from a file handle. The
|
||||
// RangerCloser's Close method will call fh.Close().
|
||||
// FileHandleRanger returns a RangeCloser from a file handle. The
|
||||
// Closer's Close method will call fh.Close().
|
||||
// Footgun: If FileHandleRanger fails, fh.Close will not have been called.
|
||||
func FileHandleRanger(fh *os.File) (RangerCloser, error) {
|
||||
func FileHandleRanger(fh *os.File) (RangeCloser, error) {
|
||||
stat, err := fh.Stat()
|
||||
if err != nil {
|
||||
return nil, Error.Wrap(err)
|
||||
@ -25,8 +25,8 @@ func FileHandleRanger(fh *os.File) (RangerCloser, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// FileRanger returns a RangerCloser from a path.
|
||||
func FileRanger(path string) (RangerCloser, error) {
|
||||
// FileRanger returns a RangeCloser from a path.
|
||||
func FileRanger(path string) (RangeCloser, error) {
|
||||
fh, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -19,15 +19,15 @@ type Ranger interface {
|
||||
Range(offset, length int64) io.ReadCloser
|
||||
}
|
||||
|
||||
// A RangerCloser is a Ranger that must be closed when finished
|
||||
type RangerCloser interface {
|
||||
// A RangeCloser is a Ranger that must be closed when finished
|
||||
type RangeCloser interface {
|
||||
Ranger
|
||||
io.Closer
|
||||
}
|
||||
|
||||
// NopCloser makes an existing Ranger function as a RangerCloser
|
||||
// NopCloser makes an existing Ranger function as a RangeCloser
|
||||
// with a no-op for Close()
|
||||
func NopCloser(r Ranger) RangerCloser {
|
||||
func NopCloser(r Ranger) RangeCloser {
|
||||
return struct {
|
||||
Ranger
|
||||
io.Closer
|
||||
|
@ -15,7 +15,10 @@ type mockRedisClient struct {
|
||||
pingCalled int
|
||||
}
|
||||
|
||||
// ErrMissingKey is the error returned if a key is not in the mock store
|
||||
var ErrMissingKey = errors.New("missing")
|
||||
|
||||
// ErrForced is the error returned when the forced error flag is passed to mock an error
|
||||
var ErrForced = errors.New("error forced by using 'error' key in mock")
|
||||
|
||||
func (m *mockRedisClient) Get(key string) ([]byte, error) {
|
Loading…
Reference in New Issue
Block a user