Files
shorebird-server/internal/storage/factory.go
T
Tony 3bb4ab494e feat: implement database and storage abstractions
- Added `internal/db/store.go` to define the Store interface for database operations, including user, organization, app, channel, release, patch, and artifact management.
- Introduced `internal/models/models.go` changes to reflect updated organization and artifact response structures.
- Created `internal/storage/factory.go`, `local.go`, and `s3.go` to implement storage backends for local filesystem and S3-compatible services.
- Removed deprecated `internal/storage/storage.go` and refactored storage interface into `internal/storage/store.go`.
- Updated frontend JavaScript in `web/js/app.js` to display server health information, including storage and database backend details.
2026-06-12 08:45:01 +08:00

38 lines
916 B
Go

package storage
import "fmt"
// Config holds common storage configuration used by the factory.
type Config struct {
// Type is "local" or "s3". Empty defaults to "local".
Type string
// Local settings
LocalDir string
ServerBaseURL string
// S3 settings
S3Endpoint string
S3AccessKey string
S3SecretKey string
S3UseSSL bool
S3ReleaseBucket string
S3PatchBucket string
}
// NewStore creates the appropriate Store backend based on Config.Type.
func NewStore(cfg Config) (Store, error) {
switch cfg.Type {
case "s3", "minio":
return NewS3Store(
cfg.S3Endpoint, cfg.S3AccessKey, cfg.S3SecretKey,
cfg.S3ReleaseBucket, cfg.S3PatchBucket, cfg.S3UseSSL,
)
default:
if cfg.Type != "" && cfg.Type != "local" {
fmt.Printf("storage: unknown type %q, falling back to local\n", cfg.Type)
}
return NewLocalStore(cfg.LocalDir, cfg.ServerBaseURL)
}
}