s3-share/cmd/s3share.go

42 lines
1.6 KiB
Go
Raw Normal View History

2022-05-09 12:52:18 +00:00
package main
2022-05-09 14:10:05 +00:00
import (
s3share "git.kapelle.org/niklas/s3share/internal"
"git.kapelle.org/niklas/s3share/internal/types"
"github.com/alexflint/go-arg"
)
type args struct {
S3Endpoint string `arg:"--s3-endpoint,required,env:S3_ENDPOINT" help:"host[:port]" placeholder:"ENDPOINT"`
S3Bucket string `arg:"--s3-bucket,required,env:S3_BUCKET" help:"bucket to use" placeholder:"BUCKET"`
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"`
2022-05-12 21:37:59 +00:00
APIUsername string `arg:"--api-username,required,env:API_USERNAME" help:"username for API" placeholder:"USERNAME"`
APIPassword string `arg:"--api-password,required,env:API_PASSWORD" help:"password for API" placeholder:"PASSWORD"`
2022-05-15 22:27:52 +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"`
2022-05-09 14:10:05 +00:00
}
func (args) Version() string {
// TODO
return "s3share 0.1"
}
2022-05-09 12:52:18 +00:00
func main() {
2022-05-09 14:10:05 +00:00
var args args
arg.MustParse(&args)
s3share.Start(&types.AppConfig{
S3Endpoint: args.S3Endpoint,
S3AccessKey: args.S3AccessKey,
S3SecretKey: args.S3SecretKey,
S3SSL: !args.S3DisableSSL,
2022-05-10 10:48:36 +00:00
S3Bucket: args.S3Bucket,
2022-05-09 14:10:05 +00:00
Address: args.Address,
2022-05-12 21:37:59 +00:00
APIUsername: args.APIUsername,
APIPassword: args.APIPassword,
2022-05-15 22:27:52 +00:00
DSN: args.DBConnection,
2022-05-09 14:10:05 +00:00
})
2022-05-09 12:52:18 +00:00
}