Documentation
¶
Overview ¶
Package repository reads and writes registered datasets, the storages they live on, and the sharing rows that open either up.
Index ¶
- type DataProductRepository
- func (r *DataProductRepository) Delete(ctx context.Context, p *model.DataProduct) error
- func (r *DataProductRepository) FindAll(ctx context.Context) ([]model.DataProduct, error)
- func (r *DataProductRepository) FindByDataStorageID(ctx context.Context, storageID string) ([]model.DataProduct, error)
- func (r *DataProductRepository) FindByID(ctx context.Context, id string) (*model.DataProduct, error)
- func (r *DataProductRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.DataProduct, error)
- func (r *DataProductRepository) FindByOwnerID(ctx context.Context, userID string) ([]model.DataProduct, error)
- func (r *DataProductRepository) Save(ctx context.Context, p *model.DataProduct) error
- func (r *DataProductRepository) WithTx(tx *gorm.DB) *DataProductRepository
- type SCPDataStorageRepository
- func (r *SCPDataStorageRepository) CountByKeyID(ctx context.Context, keyID string) (int64, error)
- func (r *SCPDataStorageRepository) Delete(ctx context.Context, s *model.SCPDataStorage) error
- func (r *SCPDataStorageRepository) FindAll(ctx context.Context) ([]model.SCPDataStorage, error)
- func (r *SCPDataStorageRepository) FindByID(ctx context.Context, id string) (*model.SCPDataStorage, error)
- func (r *SCPDataStorageRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.SCPDataStorage, error)
- func (r *SCPDataStorageRepository) FindByOwnerID(ctx context.Context, userID string) ([]model.SCPDataStorage, error)
- func (r *SCPDataStorageRepository) Save(ctx context.Context, s *model.SCPDataStorage) error
- func (r *SCPDataStorageRepository) WithTx(tx *gorm.DB) *SCPDataStorageRepository
- type VirtualDataDirectoryRepository
- func (r *VirtualDataDirectoryRepository) CountByDataProductID(ctx context.Context, productID string) (int64, error)
- func (r *VirtualDataDirectoryRepository) Delete(ctx context.Context, d *model.VirtualDataDirectory) error
- func (r *VirtualDataDirectoryRepository) FindAll(ctx context.Context) ([]model.VirtualDataDirectory, error)
- func (r *VirtualDataDirectoryRepository) FindByID(ctx context.Context, id string) (*model.VirtualDataDirectory, error)
- func (r *VirtualDataDirectoryRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.VirtualDataDirectory, error)
- func (r *VirtualDataDirectoryRepository) FindByNameUnderParent(ctx context.Context, parentID *string, ownerID, name string) (*model.VirtualDataDirectory, error)
- func (r *VirtualDataDirectoryRepository) FindChildDirectories(ctx context.Context, parentID string) ([]model.VirtualDataDirectory, error)
- func (r *VirtualDataDirectoryRepository) FindRootsByOwnerID(ctx context.Context, userID string) ([]model.VirtualDataDirectory, error)
- func (r *VirtualDataDirectoryRepository) FindSubtreeIDs(ctx context.Context, id string, maxDepth int) ([]string, error)
- func (r *VirtualDataDirectoryRepository) Save(ctx context.Context, d *model.VirtualDataDirectory) error
- func (r *VirtualDataDirectoryRepository) WithTx(tx *gorm.DB) *VirtualDataDirectoryRepository
- type VirtualDataFileRepository
- func (r *VirtualDataFileRepository) CountByDataProductID(ctx context.Context, productID string) (int64, error)
- func (r *VirtualDataFileRepository) Delete(ctx context.Context, f *model.VirtualDataFile) error
- func (r *VirtualDataFileRepository) FindByID(ctx context.Context, id string) (*model.VirtualDataFile, error)
- func (r *VirtualDataFileRepository) FindByNameUnderParent(ctx context.Context, parentID, name string) (*model.VirtualDataFile, error)
- func (r *VirtualDataFileRepository) FindByParentID(ctx context.Context, parentID string) ([]model.VirtualDataFile, error)
- func (r *VirtualDataFileRepository) Save(ctx context.Context, f *model.VirtualDataFile) error
- func (r *VirtualDataFileRepository) WithTx(tx *gorm.DB) *VirtualDataFileRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataProductRepository ¶
type DataProductRepository struct {
// contains filtered or unexported fields
}
DataProductRepository reads and writes registered datasets.
func NewDataProductRepository ¶
func NewDataProductRepository(db *gorm.DB) *DataProductRepository
NewDataProductRepository returns a repository backed by db.
func (*DataProductRepository) Delete ¶
func (r *DataProductRepository) Delete(ctx context.Context, p *model.DataProduct) error
Delete removes a product.
func (*DataProductRepository) FindAll ¶
func (r *DataProductRepository) FindAll(ctx context.Context) ([]model.DataProduct, error)
FindAll returns every product across every owner.
func (*DataProductRepository) FindByDataStorageID ¶
func (r *DataProductRepository) FindByDataStorageID(ctx context.Context, storageID string) ([]model.DataProduct, error)
FindByDataStorageID returns every product staged on one storage. It is what makes deleting a storage still in use reportable as a conflict.
func (*DataProductRepository) FindByID ¶
func (r *DataProductRepository) FindByID(ctx context.Context, id string) (*model.DataProduct, error)
FindByID returns one product, or gorm.ErrRecordNotFound.
func (*DataProductRepository) FindByIDsExcludingOwner ¶
func (r *DataProductRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.DataProduct, error)
FindByIDsExcludingOwner returns the products named by ids that userID does not own.
The ids come from the sharing table, which no longer knows what kind of record it is opening up beyond its type tag; this turns them back into entities. Data products the caller owns are dropped, because ownership is not a share and the caller asking "what has been shared with me?" already has /me for their own.
func (*DataProductRepository) FindByOwnerID ¶
func (r *DataProductRepository) FindByOwnerID(ctx context.Context, userID string) ([]model.DataProduct, error)
FindByOwnerID returns every product owned by one user.
func (*DataProductRepository) Save ¶
func (r *DataProductRepository) Save(ctx context.Context, p *model.DataProduct) error
Save inserts or updates a product.
func (*DataProductRepository) WithTx ¶
func (r *DataProductRepository) WithTx(tx *gorm.DB) *DataProductRepository
WithTx returns a repository bound to tx.
type SCPDataStorageRepository ¶
type SCPDataStorageRepository struct {
// contains filtered or unexported fields
}
SCPDataStorageRepository reads and writes SCP data storages.
Reads preload the SSH credential because the response DTO carries its public summary: the host and the login user are columns on the storage itself, but the key it presents is a reference, and a storage without it is not much use to a caller deciding whether to put data there.
func NewSCPDataStorageRepository ¶
func NewSCPDataStorageRepository(db *gorm.DB) *SCPDataStorageRepository
NewSCPDataStorageRepository returns a repository backed by db.
func (*SCPDataStorageRepository) CountByKeyID ¶
CountByKeyID reports how many storages still present one SSH credential, for the same reason the cluster configs do: the key's foreign key is RESTRICT, and a 409 naming what holds it beats a constraint violation.
func (*SCPDataStorageRepository) Delete ¶
func (r *SCPDataStorageRepository) Delete(ctx context.Context, s *model.SCPDataStorage) error
Delete removes a storage.
func (*SCPDataStorageRepository) FindAll ¶
func (r *SCPDataStorageRepository) FindAll(ctx context.Context) ([]model.SCPDataStorage, error)
FindAll returns every storage.
func (*SCPDataStorageRepository) FindByID ¶
func (r *SCPDataStorageRepository) FindByID(ctx context.Context, id string) (*model.SCPDataStorage, error)
FindByID returns one storage, or gorm.ErrRecordNotFound.
func (*SCPDataStorageRepository) FindByIDsExcludingOwner ¶
func (r *SCPDataStorageRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.SCPDataStorage, error)
FindByIDsExcludingOwner returns the storages named by ids that userID does not own.
The ids come from the sharing table, which no longer knows what kind of record it is opening up beyond its type tag; this turns them back into entities. Storages the caller owns are dropped, because ownership is not a share and the caller asking "what has been shared with me?" already has /me for their own.
func (*SCPDataStorageRepository) FindByOwnerID ¶
func (r *SCPDataStorageRepository) FindByOwnerID(ctx context.Context, userID string) ([]model.SCPDataStorage, error)
FindByOwnerID returns every storage owned by one user.
func (*SCPDataStorageRepository) Save ¶
func (r *SCPDataStorageRepository) Save(ctx context.Context, s *model.SCPDataStorage) error
Save inserts or updates a storage.
func (*SCPDataStorageRepository) WithTx ¶
func (r *SCPDataStorageRepository) WithTx(tx *gorm.DB) *SCPDataStorageRepository
WithTx returns a repository bound to tx.
type VirtualDataDirectoryRepository ¶
type VirtualDataDirectoryRepository struct {
// contains filtered or unexported fields
}
func NewVirtualDataDirectoryRepository ¶
func NewVirtualDataDirectoryRepository(db *gorm.DB) *VirtualDataDirectoryRepository
func (*VirtualDataDirectoryRepository) CountByDataProductID ¶
func (r *VirtualDataDirectoryRepository) CountByDataProductID(ctx context.Context, productID string) (int64, error)
CountByDataProductID reports how many directory nodes cite one product. It is what makes deleting a product still used by a dataset reportable as a conflict.
func (*VirtualDataDirectoryRepository) Delete ¶
func (r *VirtualDataDirectoryRepository) Delete(ctx context.Context, d *model.VirtualDataDirectory) error
func (*VirtualDataDirectoryRepository) FindAll ¶
func (r *VirtualDataDirectoryRepository) FindAll(ctx context.Context) ([]model.VirtualDataDirectory, error)
func (*VirtualDataDirectoryRepository) FindByID ¶
func (r *VirtualDataDirectoryRepository) FindByID(ctx context.Context, id string) (*model.VirtualDataDirectory, error)
func (*VirtualDataDirectoryRepository) FindByIDsExcludingOwner ¶
func (r *VirtualDataDirectoryRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.VirtualDataDirectory, error)
FindByIDsExcludingOwner returns the directorys named by ids that userID does not own.
The ids come from the sharing table, which no longer knows what kind of record it is opening up beyond its type tag; this turns them back into entities. Directories the caller owns are dropped, because ownership is not a share and the caller asking "what has been shared with me?" already has /me for their own.
func (*VirtualDataDirectoryRepository) FindByNameUnderParent ¶
func (r *VirtualDataDirectoryRepository) FindByNameUnderParent(ctx context.Context, parentID *string, ownerID, name string) (*model.VirtualDataDirectory, error)
func (*VirtualDataDirectoryRepository) FindChildDirectories ¶
func (r *VirtualDataDirectoryRepository) FindChildDirectories(ctx context.Context, parentID string) ([]model.VirtualDataDirectory, error)
func (*VirtualDataDirectoryRepository) FindRootsByOwnerID ¶
func (r *VirtualDataDirectoryRepository) FindRootsByOwnerID(ctx context.Context, userID string) ([]model.VirtualDataDirectory, error)
func (*VirtualDataDirectoryRepository) FindSubtreeIDs ¶
func (r *VirtualDataDirectoryRepository) FindSubtreeIDs(ctx context.Context, id string, maxDepth int) ([]string, error)
FindSubtreeIDs returns id and the ids of every directory beneath it, breadth first.
Deleting a directory cascades the rows under it through the self-referencing foreign key, but the shares hanging off those rows point at nothing and so are not cascaded with them. The caller deletes them by id, which is what this is for.
maxDepth bounds the walk: the schema cannot express "no cycles", and a cycle would otherwise make this loop forever. Nodes already seen are not revisited, so a cycle yields a finite set rather than a wrong one.
func (*VirtualDataDirectoryRepository) Save ¶
func (r *VirtualDataDirectoryRepository) Save(ctx context.Context, d *model.VirtualDataDirectory) error
func (*VirtualDataDirectoryRepository) WithTx ¶
func (r *VirtualDataDirectoryRepository) WithTx(tx *gorm.DB) *VirtualDataDirectoryRepository
type VirtualDataFileRepository ¶
type VirtualDataFileRepository struct {
// contains filtered or unexported fields
}
func NewVirtualDataFileRepository ¶
func NewVirtualDataFileRepository(db *gorm.DB) *VirtualDataFileRepository
func (*VirtualDataFileRepository) CountByDataProductID ¶
func (*VirtualDataFileRepository) Delete ¶
func (r *VirtualDataFileRepository) Delete(ctx context.Context, f *model.VirtualDataFile) error
func (*VirtualDataFileRepository) FindByID ¶
func (r *VirtualDataFileRepository) FindByID(ctx context.Context, id string) (*model.VirtualDataFile, error)
func (*VirtualDataFileRepository) FindByNameUnderParent ¶
func (r *VirtualDataFileRepository) FindByNameUnderParent(ctx context.Context, parentID, name string) (*model.VirtualDataFile, error)
func (*VirtualDataFileRepository) FindByParentID ¶
func (r *VirtualDataFileRepository) FindByParentID(ctx context.Context, parentID string) ([]model.VirtualDataFile, error)
func (*VirtualDataFileRepository) Save ¶
func (r *VirtualDataFileRepository) Save(ctx context.Context, f *model.VirtualDataFile) error
func (*VirtualDataFileRepository) WithTx ¶
func (r *VirtualDataFileRepository) WithTx(tx *gorm.DB) *VirtualDataFileRepository