Documentation
¶
Overview ¶
Package repository reads and writes Slurm clusters, their partitions, and the login configs users reach them through.
Index ¶
- type ClusterPartitionRepository
- func (r *ClusterPartitionRepository) Delete(ctx context.Context, p *model.ClusterPartition) error
- func (r *ClusterPartitionRepository) FindByClusterID(ctx context.Context, clusterID string) ([]model.ClusterPartition, error)
- func (r *ClusterPartitionRepository) FindByIDAndClusterID(ctx context.Context, partitionID, clusterID string) (*model.ClusterPartition, error)
- func (r *ClusterPartitionRepository) Save(ctx context.Context, p *model.ClusterPartition) error
- func (r *ClusterPartitionRepository) WithTx(tx *gorm.DB) *ClusterPartitionRepository
- type SlurmClusterConfigRepository
- func (r *SlurmClusterConfigRepository) CountByKeyID(ctx context.Context, keyID string) (int64, error)
- func (r *SlurmClusterConfigRepository) Delete(ctx context.Context, c *model.SlurmClusterConfig) error
- func (r *SlurmClusterConfigRepository) FindAll(ctx context.Context) ([]model.SlurmClusterConfig, error)
- func (r *SlurmClusterConfigRepository) FindByID(ctx context.Context, id string) (*model.SlurmClusterConfig, error)
- func (r *SlurmClusterConfigRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.SlurmClusterConfig, error)
- func (r *SlurmClusterConfigRepository) FindByOwnerID(ctx context.Context, userID string) ([]model.SlurmClusterConfig, error)
- func (r *SlurmClusterConfigRepository) FindBySlurmClusterID(ctx context.Context, clusterID string) ([]model.SlurmClusterConfig, error)
- func (r *SlurmClusterConfigRepository) Save(ctx context.Context, c *model.SlurmClusterConfig) error
- func (r *SlurmClusterConfigRepository) WithTx(tx *gorm.DB) *SlurmClusterConfigRepository
- type SlurmClusterRepository
- func (r *SlurmClusterRepository) Delete(ctx context.Context, c *model.SlurmCluster) error
- func (r *SlurmClusterRepository) ExistsByName(ctx context.Context, name string) (bool, error)
- func (r *SlurmClusterRepository) FindAll(ctx context.Context) ([]model.SlurmCluster, error)
- func (r *SlurmClusterRepository) FindByID(ctx context.Context, id string) (*model.SlurmCluster, error)
- func (r *SlurmClusterRepository) Save(ctx context.Context, c *model.SlurmCluster) error
- func (r *SlurmClusterRepository) WithTx(tx *gorm.DB) *SlurmClusterRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterPartitionRepository ¶
type ClusterPartitionRepository struct {
// contains filtered or unexported fields
}
ClusterPartitionRepository reads and writes partitions.
func NewClusterPartitionRepository ¶
func NewClusterPartitionRepository(db *gorm.DB) *ClusterPartitionRepository
NewClusterPartitionRepository returns a repository backed by db.
func (*ClusterPartitionRepository) Delete ¶
func (r *ClusterPartitionRepository) Delete(ctx context.Context, p *model.ClusterPartition) error
Delete removes a partition.
func (*ClusterPartitionRepository) FindByClusterID ¶
func (r *ClusterPartitionRepository) FindByClusterID(ctx context.Context, clusterID string) ([]model.ClusterPartition, error)
FindByClusterID returns every partition of one cluster.
func (*ClusterPartitionRepository) FindByIDAndClusterID ¶
func (r *ClusterPartitionRepository) FindByIDAndClusterID(ctx context.Context, partitionID, clusterID string) (*model.ClusterPartition, error)
FindByIDAndClusterID looks a partition up within one cluster.
Scoping the lookup by cluster is deliberate: it stops a partition id belonging to one cluster from being reached through another cluster's path.
func (*ClusterPartitionRepository) Save ¶
func (r *ClusterPartitionRepository) Save(ctx context.Context, p *model.ClusterPartition) error
Save inserts or updates a partition.
func (*ClusterPartitionRepository) WithTx ¶
func (r *ClusterPartitionRepository) WithTx(tx *gorm.DB) *ClusterPartitionRepository
WithTx returns a repository bound to tx.
type SlurmClusterConfigRepository ¶
type SlurmClusterConfigRepository struct {
// contains filtered or unexported fields
}
SlurmClusterConfigRepository reads and writes cluster login configs.
Reads preload the cluster and the key summary because the response DTO carries both: a config without the machine it logs in to, and without which key it presents, is not much use to a caller deciding whether to launch through it.
func NewSlurmClusterConfigRepository ¶
func NewSlurmClusterConfigRepository(db *gorm.DB) *SlurmClusterConfigRepository
NewSlurmClusterConfigRepository returns a repository backed by db.
func (*SlurmClusterConfigRepository) CountByKeyID ¶
func (r *SlurmClusterConfigRepository) CountByKeyID(ctx context.Context, keyID string) (int64, error)
CountByKeyID reports how many configs still present one SSH credential. The credentials vertical asks before deleting a key: the foreign key is RESTRICT, so without this the delete would fail as an opaque constraint violation rather than a 409 naming what still holds it.
func (*SlurmClusterConfigRepository) Delete ¶
func (r *SlurmClusterConfigRepository) Delete(ctx context.Context, c *model.SlurmClusterConfig) error
Delete removes a config.
func (*SlurmClusterConfigRepository) FindAll ¶
func (r *SlurmClusterConfigRepository) FindAll(ctx context.Context) ([]model.SlurmClusterConfig, error)
FindAll returns every config.
func (*SlurmClusterConfigRepository) FindByID ¶
func (r *SlurmClusterConfigRepository) FindByID(ctx context.Context, id string) (*model.SlurmClusterConfig, error)
FindByID returns one config, or gorm.ErrRecordNotFound.
func (*SlurmClusterConfigRepository) FindByIDsExcludingOwner ¶
func (r *SlurmClusterConfigRepository) FindByIDsExcludingOwner(ctx context.Context, ids []string, userID string) ([]model.SlurmClusterConfig, error)
FindByIDsExcludingOwner returns the configs named by ids that userID does not own.
The ids come from the sharing table, which knows a resource only by its type tag; this turns them back into entities. Configs 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 (*SlurmClusterConfigRepository) FindByOwnerID ¶
func (r *SlurmClusterConfigRepository) FindByOwnerID(ctx context.Context, userID string) ([]model.SlurmClusterConfig, error)
FindByOwnerID returns every config owned by one user.
func (*SlurmClusterConfigRepository) FindBySlurmClusterID ¶
func (r *SlurmClusterConfigRepository) FindBySlurmClusterID(ctx context.Context, clusterID string) ([]model.SlurmClusterConfig, error)
FindBySlurmClusterID returns every config registered against one cluster. It is what makes deleting a cluster still in use reportable as a conflict rather than a foreign key error.
func (*SlurmClusterConfigRepository) Save ¶
func (r *SlurmClusterConfigRepository) Save(ctx context.Context, c *model.SlurmClusterConfig) error
Save inserts or updates a config.
func (*SlurmClusterConfigRepository) WithTx ¶
func (r *SlurmClusterConfigRepository) WithTx(tx *gorm.DB) *SlurmClusterConfigRepository
WithTx returns a repository bound to tx.
type SlurmClusterRepository ¶
type SlurmClusterRepository struct {
// contains filtered or unexported fields
}
SlurmClusterRepository reads and writes clusters.
Reads preload Partitions because the response DTO always carries them; the Java service achieved the same thing by running reads inside a transaction so the lazy association could still be walked during mapping.
func NewSlurmClusterRepository ¶
func NewSlurmClusterRepository(db *gorm.DB) *SlurmClusterRepository
NewSlurmClusterRepository returns a repository backed by db.
func (*SlurmClusterRepository) Delete ¶
func (r *SlurmClusterRepository) Delete(ctx context.Context, c *model.SlurmCluster) error
Delete removes a cluster; its partitions go with it via the cascading constraint.
func (*SlurmClusterRepository) ExistsByName ¶
ExistsByName reports whether a cluster of that name is already registered.
Carried over from the Java repository, which declared it but never called it — no service rejects a duplicate name, and no unique constraint backs it either.
func (*SlurmClusterRepository) FindAll ¶
func (r *SlurmClusterRepository) FindAll(ctx context.Context) ([]model.SlurmCluster, error)
FindAll returns every cluster with its partitions.
func (*SlurmClusterRepository) FindByID ¶
func (r *SlurmClusterRepository) FindByID(ctx context.Context, id string) (*model.SlurmCluster, error)
FindByID returns one cluster with its partitions, or gorm.ErrRecordNotFound.
func (*SlurmClusterRepository) Save ¶
func (r *SlurmClusterRepository) Save(ctx context.Context, c *model.SlurmCluster) error
Save inserts or updates a cluster.
func (*SlurmClusterRepository) WithTx ¶
func (r *SlurmClusterRepository) WithTx(tx *gorm.DB) *SlurmClusterRepository
WithTx returns a repository bound to tx.