s3browser-backend/cmd/s3Browser.go

43 lines
1.5 KiB
Go

package main
import (
"time"
s3browser "git.kapelle.org/niklas/s3browser/internal"
"github.com/alexflint/go-arg"
)
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"`
S3Buket string `arg:"--s3-buket,required,env:S3_BUKET" placeholder:"BUKET"`
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"`
}
func (args) Version() string {
// TODO
return "s3Browser 0.1"
}
func main() {
var args args
arg.MustParse(&args)
s3browser.Start(s3browser.AppConfig{
S3Endoint: args.S3Endpoint,
S3SSL: !args.S3DisableSSL,
S3AccessKey: args.S3AccessKey,
S3SecretKey: args.S3SecretKey,
S3Buket: args.S3Buket,
CacheTTL: time.Duration(args.CacheTTL) * time.Second,
CacheCleanup: time.Duration(args.CacheCleanup) * time.Second,
Address: args.Address,
LogDebug: args.Verbose,
})
}