s3browser-backend/cmd/s3Browser.go

44 lines
1.6 KiB
Go
Raw Permalink Normal View History

2021-07-26 12:52:36 +00:00
package main
2021-08-01 11:00:47 +00:00
import (
"time"
s3browser "git.kapelle.org/niklas/s3browser/internal"
2021-09-24 13:39:23 +00:00
types "git.kapelle.org/niklas/s3browser/internal/types"
2021-09-09 11:41:38 +00:00
"github.com/alexflint/go-arg"
2021-08-01 11:00:47 +00:00
)
2021-07-26 12:52:36 +00:00
2021-09-09 11:41:38 +00:00
type args struct {
S3Endpoint string `arg:"--s3-endpoint,required,env:S3_ENDPOINT" help:"host[:port]" placeholder:"ENDPOINT"`
S3AccessKey string `arg:"--s3-access-key,required,env:S3_ACCESS_KEY" placeholder:"ACCESS_KEY"`
S3SecretKey string `arg:"--s3-secret-key,required,env:S3_SECRET_KEY" placeholder:"SECRET_KEY"`
S3DisableSSL bool `arg:"--s3-disable-ssl,env:S3_DISABLE_SSL" default:"false"`
Address string `arg:"--address,env:ADDRESS" default:":3000" help:"what address to listen on" placeholder:"ADDRESS"`
CacheTTL int64 `arg:"--cache-ttl,env:CACHE_TTL" help:"Time in seconds" default:"30" placeholder:"TTL"`
CacheCleanup int64 `arg:"--cache-cleanup,env:CACHE_CLEANUP" help:"Time in seconds" default:"60" placeholder:"CLEANUP"`
Verbose bool `arg:"-v,--verbose,env:VERBOSE" help:"verbosity level" default:"false"`
2021-11-04 19:28:37 +00:00
DBConnection string `arg:"--db,required,env:DB_CONNECTION" help:"DSN in format: https://github.com/go-sql-driver/mysql#dsn-data-source-name"`
2021-09-09 11:41:38 +00:00
}
func (args) Version() string {
// TODO
return "s3Browser 0.1"
}
2021-07-26 12:52:36 +00:00
func main() {
2021-09-09 11:41:38 +00:00
var args args
arg.MustParse(&args)
2021-09-24 13:39:23 +00:00
s3browser.Start(types.AppConfig{
2021-09-09 11:41:38 +00:00
S3Endoint: args.S3Endpoint,
S3SSL: !args.S3DisableSSL,
S3AccessKey: args.S3AccessKey,
S3SecretKey: args.S3SecretKey,
2021-11-04 19:28:37 +00:00
DSN: args.DBConnection,
2021-09-09 11:41:38 +00:00
CacheTTL: time.Duration(args.CacheTTL) * time.Second,
CacheCleanup: time.Duration(args.CacheCleanup) * time.Second,
Address: args.Address,
LogDebug: args.Verbose,
2021-07-26 12:52:36 +00:00
})
}