This commit is contained in:
parent
09549b0178
commit
3a1ac5fcf5
12
config.go
12
config.go
@ -6,11 +6,23 @@ import (
|
||||
)
|
||||
|
||||
type Conf struct {
|
||||
Fs FsConf `ini:"fs"`
|
||||
Http HttpConf `ini:"http"`
|
||||
Repo RepoConf `ini:"repo"`
|
||||
PGP PGPConf `ini:"pgp"`
|
||||
}
|
||||
|
||||
type FsConf struct {
|
||||
Driver string `ini:"driver"`
|
||||
S3 struct {
|
||||
Bucket string `ini:"bucket"`
|
||||
Region string `ini:"region"`
|
||||
Endpoint string `ini:"endpoint"`
|
||||
ID string `ini:"id"`
|
||||
Secret string `ini:"secret"`
|
||||
} `ini:"s3"`
|
||||
}
|
||||
|
||||
type HttpConf struct {
|
||||
Port int `ini:"port"`
|
||||
Key string `ini:"key"`
|
||||
|
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.14
|
||||
require (
|
||||
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2
|
||||
github.com/blang/semver v3.5.1+incompatible
|
||||
github.com/fclairamb/afero-s3 v0.1.0 // indirect
|
||||
github.com/go-ini/ini v1.28.2
|
||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||
github.com/spf13/afero v1.2.2
|
||||
|
15
go.sum
15
go.sum
@ -1,25 +1,40 @@
|
||||
github.com/aws/aws-sdk-go v1.31.3 h1:vJDjoM+VlM/ZEmGyaIhUXaYAtB9lra7Qhr58SSHHjPE=
|
||||
github.com/aws/aws-sdk-go v1.31.3/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
|
||||
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2 h1:oMCHnXa6CCCafdPDbMh/lWRhRByN0VFLvv+g+ayx1SI=
|
||||
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
|
||||
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
|
||||
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fclairamb/afero-s3 v0.1.0 h1:WfPD2Px6AlcEBw1jUmJC295wpTXkfglYtzbSdTfaNzg=
|
||||
github.com/fclairamb/afero-s3 v0.1.0/go.mod h1:HHcYBsOLXjeqdnKQ61Rx43+vj+jGe9DjYTQbKhendwQ=
|
||||
github.com/go-ini/ini v1.28.2 h1:drmmYv7psRpoGZkPtPKKTB+ZFSnvmwCMfNj5o1nLh2Y=
|
||||
github.com/go-ini/ini v1.28.2/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
|
||||
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
golang.org/x/crypto v0.0.0-20170523101029-7e9105388ebf h1:Ak4rvIfvuVxAE1NgtCq1GvH0e5psMKmzowfoGdL8QBA=
|
||||
golang.org/x/crypto v0.0.0-20170523101029-7e9105388ebf/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
31
server.go
31
server.go
@ -4,6 +4,10 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
s3 "github.com/fclairamb/afero-s3"
|
||||
"github.com/go-ini/ini"
|
||||
"github.com/spf13/afero"
|
||||
"golang.org/x/crypto/openpgp"
|
||||
@ -18,7 +22,7 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var VERSION = "1.4.0"
|
||||
var VERSION = "1.4.1"
|
||||
|
||||
func packageName(name string) string {
|
||||
if index := strings.Index(name, "_"); index != -1 {
|
||||
@ -71,7 +75,30 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
fs = afero.NewBasePathFs(afero.NewOsFs(), conf.Repo.Root)
|
||||
|
||||
switch conf.Fs.Driver {
|
||||
case "s3":
|
||||
awsConfig := &aws.Config{
|
||||
Region: aws.String(conf.Fs.S3.Region),
|
||||
Credentials: credentials.NewStaticCredentials(conf.Fs.S3.ID, conf.Fs.S3.Secret, ""),
|
||||
}
|
||||
|
||||
if conf.Fs.S3.Endpoint != "" {
|
||||
awsConfig.Endpoint = aws.String(conf.Fs.S3.Endpoint)
|
||||
}
|
||||
|
||||
sess, err := session.NewSession(awsConfig)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalln("Unable to create S3 session:", err)
|
||||
}
|
||||
|
||||
fs = s3.NewFs(conf.Fs.S3.Bucket, sess)
|
||||
case "local":
|
||||
fallthrough
|
||||
default:
|
||||
fs = afero.NewBasePathFs(afero.NewOsFs(), conf.Repo.Root)
|
||||
}
|
||||
|
||||
if err := createDirs(conf); err != nil {
|
||||
log.Println(err)
|
||||
|
Loading…
Reference in New Issue
Block a user