Skip to content

Commit

Permalink
feat: force bucket name regardless of ssh user
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Aug 18, 2024
1 parent 2551cf3 commit c482180
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ MINIO_URL="http://minio:9000"
MINIO_ROOT_USER="miniosecret"
MINIO_ROOT_PASSWORD="miniosecret"

# OBJECT_DRIVER="s3"
# OBJECT_BUCKET_NAME="xyz" # optional, force the bucket name
# AWS_ACCESS_KEY_ID="yyy"
# AWS_SECRET_ACCESS_KEY="zzz"
# AWS_REGION="us-east-2"

# OBJECT_DRIVER="fs"
# OBJECT_URL="./.storage"
9 changes: 9 additions & 0 deletions asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ func (an *AssetNamesBasic) BucketName(user string) string {
func (an *AssetNamesBasic) ObjectName(entry *utils.FileEntry) string {
return entry.Filepath
}

type AssetNamesForceBucket struct {
*AssetNamesBasic
Name string
}

func (an *AssetNamesForceBucket) BucketName(user string) string {
return an.Name
}
6 changes: 6 additions & 0 deletions cmd/authorized_keys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func main() {
host := pobj.GetEnv("SSH_HOST", "0.0.0.0")
port := pobj.GetEnv("SSH_PORT", "2222")
keyPath := pobj.GetEnv("SSH_AUTHORIZED_KEYS", "./ssh_data/authorized_keys")
bucketName := pobj.GetEnv("OBJECT_BUCKET_NAME", "")

st, err := pobj.EnvDriverDetector(logger)
if err != nil {
Expand All @@ -29,6 +30,11 @@ func main() {
Logger: logger,
Storage: st,
}
if bucketName != "" {
cfg.AssetNames = &pobj.AssetNamesForceBucket{
Name: bucketName,
}
}

handler := pobj.NewUploadAssetHandler(cfg)

Expand Down

0 comments on commit c482180

Please sign in to comment.