storage

package
v0.10.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Code for storing & retrieving DataTug projects

  • filestore - stores to file system (folders & JSON files)

Documentation

Overview

Package dtprojcreator is a generated GoMock package.

Index

Constants

View Source
const (
	RepoRootDataTugFileName = ".datatug.yaml"
	BoardsFolder            = "boards"
	ProjectSummaryFileName  = "datatug-project.json"
	DataFolder              = "data"
	DbsFolder               = "dbs"
	EnvDbCatalogsFolder     = "catalogs"
	DbModelsFolder          = "dbmodels"
	EntitiesFolder          = "entities"
	EnvironmentsFolder      = "environments"
	QueriesFolder           = "queries"
	RecordsetsFolder        = "recordsets"
	ServersFolder           = "servers"
	SchemasFolder           = "schemas"
)
View Source
const (
	BoardFileSuffix           = "board"
	DbCatalogFileSuffix       = "db"
	DbCatalogObjectFileSuffix = "objects"
	DbCatalogRefsFileSuffix   = "refs"
	DbModelFileSuffix         = "dbmodel"
	DbServerFileSuffix        = "dbserver"
	RecordsetFileSuffix       = "recordset"
	EntityFileSuffix          = "entity"
	ServerFileSuffix          = "server"
	ColumnsFileSuffix         = "columns"
	QueryFileSuffix           = "query"
)
View Source
const (
	EnvironmentSummaryFileName = "environment-summary.json"
)
View Source
const SingleProjectID = "."

SingleProjectID defines a short version of project GetID for a single project storage

Variables

View Source
var NewDatatugStore = func(id string) (Store, error) {
	panic("var 'NewDatatugStore' is not initialized")
}

NewDatatugStore creates new instance of Store for a specific storage

Functions

func ContextWithDatatugStore

func ContextWithDatatugStore(ctx context.Context, store Store) context.Context

func GetProjItemIDFromFileName

func GetProjItemIDFromFileName(fileName string) (id string, suffix string)

func GetProjectStore

func GetProjectStore(ctx context.Context, storeID, projectID string) (datatug.ProjectStore, error)

func JsonFileName

func JsonFileName(id, suffix string) string

Types

type CreateFolderRequest

type CreateFolderRequest struct {
	Name string
	Path string
	Note string
}

func (CreateFolderRequest) Validate

func (v CreateFolderRequest) Validate() error

type FileLoadError

type FileLoadError struct {
	FileName string `json:"fileName,omitempty"`
	Err      string `json:"err,omitempty"`
	// contains filtered or unexported fields
}

func NewFileLoadError

func NewFileLoadError(fileName string, err error) FileLoadError

func (FileLoadError) Error

func (e FileLoadError) Error() string

func (FileLoadError) String

func (e FileLoadError) String() string

type FilesLoadError

type FilesLoadError struct {
	// contains filtered or unexported fields
}

func NewFilesLoadError

func NewFilesLoadError(errs []FileLoadError) FilesLoadError

func (FilesLoadError) Error

func (e FilesLoadError) Error() string

func (FilesLoadError) Errors

func (e FilesLoadError) Errors() []FileLoadError

func (FilesLoadError) String

func (e FilesLoadError) String() string

type FoldersStore

type FoldersStore interface {
	CreateFolder(ctx context.Context, request CreateFolderRequest) (folder *datatug.Folder, err error)
	GetFolder(ctx context.Context, path string) (folder *datatug.Folder, err error)
	DeleteFolder(ctx context.Context, path string) (err error)
}

type MockStorage

type MockStorage struct {
	// contains filtered or unexported fields
}

MockStorage is a mock of Storage interface.

func NewMockStorage

func NewMockStorage(ctrl *gomock.Controller) *MockStorage

NewMockStorage creates a new mock instance.

func (*MockStorage) Commit

func (m *MockStorage) Commit(ctx context.Context, message string) error

Commit mocks base method.

func (*MockStorage) EXPECT

func (m *MockStorage) EXPECT() *MockStorageMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStorage) FileExists

func (m *MockStorage) FileExists(ctx context.Context, filePath string) (bool, error)

FileExists mocks base method.

func (*MockStorage) OpenFile

func (m *MockStorage) OpenFile(ctx context.Context, filePath string) (io.ReadCloser, error)

OpenFile mocks base method.

func (*MockStorage) WriteFile

func (m *MockStorage) WriteFile(ctx context.Context, filePath string, reader io.Reader) error

WriteFile mocks base method.

type MockStorageMockRecorder

type MockStorageMockRecorder struct {
	// contains filtered or unexported fields
}

MockStorageMockRecorder is the mock recorder for MockStorage.

func (*MockStorageMockRecorder) Commit

func (mr *MockStorageMockRecorder) Commit(ctx, message any) *gomock.Call

Commit indicates an expected call of Commit.

func (*MockStorageMockRecorder) FileExists

func (mr *MockStorageMockRecorder) FileExists(ctx, filePath any) *gomock.Call

FileExists indicates an expected call of FileExists.

func (*MockStorageMockRecorder) OpenFile

func (mr *MockStorageMockRecorder) OpenFile(ctx, filePath any) *gomock.Call

OpenFile indicates an expected call of OpenFile.

func (*MockStorageMockRecorder) WriteFile

func (mr *MockStorageMockRecorder) WriteFile(ctx, filePath, reader any) *gomock.Call

WriteFile indicates an expected call of WriteFile.

type ProjectStoreRef

type ProjectStoreRef interface {
	ProjectStore() datatug.ProjectStore
}

type RecordsetLoader

type RecordsetLoader interface {
	// ID returns recordset id
	ID() string
	// LoadRecordsetDefinition loads recordset definition
	LoadRecordsetDefinition(ctx context.Context) (dataset *datatug.RecordsetDefinition, err error)
	// LoadRecordsetData loads recordset data
	LoadRecordsetData(ctx context.Context, fileName string) (recordset *datatug.Recordset, err error)
}

RecordsetLoader loads recordset data

type RecordsetsStore

type RecordsetsStore interface {
	ProjectStoreRef
	Recordset(id string) RecordsetLoader
	// LoadRecordsetDefinitions loads list of recordsets summary
	LoadRecordsetDefinitions(ctx context.Context) (datasets []*datatug.RecordsetDefinition, err error)
}

RecordsetsStore provides access to recordset records

type Store

type Store interface {
	GetProjectStore(projectID string) datatug.ProjectStore

	// CreateProject creates a new DataTug project
	CreateProject(ctx context.Context, request dto.CreateProjectRequest) (
		projectSummary *datatug.ProjectSummary,
		err error,
	)
	DeleteProject(ctx context.Context, id string) error

	// GetProjects returns list of projects
	GetProjects(ctx context.Context) (projectBriefs []datatug.ProjectBrief, err error)
}

Store defines interface for loading & saving DataTug projects Each store can keep multiple projects. Projects can be stored locally on file system or on server on some database.

var Current Store

Current holds currently active storage interface

TODO: to be replaced with `func NewDatatugStore(id string) Store`

func GetStore

func GetStore(ctx context.Context, id string) (Store, error)

func NewNoOpStore

func NewNoOpStore() Store

func StoreFromContext

func StoreFromContext(ctx context.Context) (Store, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL