Storage: support git + github backed roots (#52192)

This commit is contained in:
Ryan McKinley
2022-07-28 23:26:44 -07:00
committed by GitHub
parent e2044cde13
commit 197acd73c0
26 changed files with 1391 additions and 275 deletions
+19 -11
View File
@@ -13,10 +13,12 @@ import (
const rootStorageTypeSQL = "sql"
type rootStorageSQL struct {
baseStorageRuntime
var _ storageRuntime = &rootStorageSQL{}
type rootStorageSQL struct {
settings *StorageSQLConfig
meta RootStorageMeta
store filestorage.FileStorage
}
// getDbRootFolder creates a DB path prefix for a given storage name and orgId.
@@ -28,19 +30,17 @@ func getDbStoragePathPrefix(orgId int64, storageName string) string {
return filestorage.Join(fmt.Sprintf("%d", orgId), storageName+filestorage.Delimiter)
}
func newSQLStorage(prefix string, name string, descr string, cfg *StorageSQLConfig, sql *sqlstore.SQLStore, orgId int64) *rootStorageSQL {
func newSQLStorage(meta RootStorageMeta, prefix string, name string, descr string, cfg *StorageSQLConfig, sql *sqlstore.SQLStore, orgId int64) *rootStorageSQL {
if cfg == nil {
cfg = &StorageSQLConfig{}
}
meta := RootStorageMeta{
Config: RootStorageConfig{
Type: rootStorageTypeSQL,
Prefix: prefix,
Name: name,
Description: descr,
SQL: cfg,
},
meta.Config = RootStorageConfig{
Type: rootStorageTypeSQL,
Prefix: prefix,
Name: name,
Description: descr,
SQL: cfg,
}
if prefix == "" {
@@ -78,6 +78,14 @@ func (s *rootStorageSQL) Write(ctx context.Context, cmd *WriteValueRequest) (*Wr
return &WriteValueResponse{Code: 200}, nil
}
func (s *rootStorageSQL) Meta() RootStorageMeta {
return s.meta
}
func (s *rootStorageSQL) Store() filestorage.FileStorage {
return s.store
}
func (s *rootStorageSQL) Sync() error {
return nil // already in sync
}