cabridss

package
v0.0.0-...-aa4546b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_META_SIZE = 100000
View Source
const MAX_TIME int64 = 9223372036854775807
View Source
const MIN_TIME int64 = -9223372036854775808

Variables

View Source
var (
	// ErrPasswordRequired is returned when accessing encrypted content
	// without access to the user's master password
	ErrPasswordRequired = errors.New("password required to perform this action")
)

Functions

func AppendSlashIf

func AppendSlashIf(path string) string

func CabriPlumberDefaultConfig

func CabriPlumberDefaultConfig(serial bool, redLimit int) plumber.Config

func CleanObsDss

func CleanObsDss(config ObsConfig) error

CleanObsDss cleans an "object-storage" DSS (data storage system) config provides the object store specification

func CmpAcl

func CmpAcl(acl1, acl2 []ACLEntry) bool

func Decrypt

func Decrypt(src io.Reader, sids ...string) (io.Reader, error)

Decrypt decrypts a file encrypted to one or more sids X25519 identities encoded as strings.

It returns a Reader reading the decrypted plaintext of the age file read from src. All identities will be tried until one successfully decrypts the file.

func DecryptFileWithPass

func DecryptFileWithPass(source, target, pass string) error

DecryptFileWithPass decrypts a file source to a file target with a given password pass using Scrypt encoding

func DecryptMsg

func DecryptMsg(jbs []byte, sids ...string) (string, error)

DecryptMsg decrypts jbs encrypted content to one or more sids X25519 identities encoded as strings. It returns the message in cleartext

jbs are the json encoded bytes

All identities will be tried until one successfully decrypts the content.

func DecryptMsgWithPass

func DecryptMsgWithPass(jbs []byte, pass string) (string, error)

DecryptMsgWithPass decrypts jbs encrypted content with a given password using Scrypt encoding It returns the message in cleartext

jbs are the json encoded bytes

func DecryptUserConfig

func DecryptUserConfig(config DssBaseConfig, configDir string) error

func Encrypt

func Encrypt(dst io.Writer, srs ...string) (io.WriteCloser, error)

Encrypt encrypts a file to one or more X25519 srs recipients encoded as strings.

Writes to the returned WriteCloser are encrypted and written to dst as an age file. Every recipient will be able to decrypt the file.

The caller must call Close on the WriteCloser when done for the last chunk to be encrypted and flushed to dst.

func EncryptFileWithPass

func EncryptFileWithPass(source, target, pass string) error

EncryptFileWithPass encrypts a file source to a file target with a given password pass using Scrypt encoding

func EncryptMsg

func EncryptMsg(msg string, srs ...string) ([]byte, error)

EncryptMsg encrypts a msg to one or more X25519 srs recipients encoded as strings.

Every recipient will be able to decrypt the result.

It returns the encrypted content as json encoded bytes.

func EncryptMsgWithPass

func EncryptMsgWithPass(msg string, pass string) ([]byte, error)

EncryptMsgWithPass encrypts a msg with a given password using Scrypt encoding

It returns the encrypted content as json encoded bytes.

func EncryptUserConfig

func EncryptUserConfig(config DssBaseConfig, configDir string) error

func GetCustomConfig

func GetCustomConfig(c echo.Context) interface{}

func GetHomeConfigDir

func GetHomeConfigDir(config DssBaseConfig) (string, error)

func GetServerIndexesForTests

func GetServerIndexesForTests(dss HDss) (Index, Index)

func HasRaiseError

func HasRaiseError() bool

func IdPkeys

func IdPkeys(uc UserConfig) (users []string)

func IdSecrets

func IdSecrets(uc UserConfig) (secrets []string)

func LoadDssConfig

func LoadDssConfig(bc DssBaseConfig, persistentConfig interface{}) error

func MkallContent

func MkallContent(dss Dss, cpath string, mtime int64) error

func MkallNs

func MkallNs(dss Dss, npath string, mtime int64) error

func NewClientErr

func NewClientErr(where string, resp *http.Response, err error, bs []byte) error

func NewReadCloserWithCb

func NewReadCloserWithCb(underlying io.Reader, closeCb func() error) (io.ReadCloser, error)

func NewServerErr

func NewServerErr(where string, err error) error

func NewTempFileWriteCloserWithCb

func NewTempFileWriteCloserWithCb(fs afero.Fs, dir, pattern string, closeCb WriteCloserErrCb) (io.WriteCloser, error)

func NewWriteCloserWithCb

func NewWriteCloserWithCb(underlying io.WriteCloser, closeCb WriteCloserErrCb) io.WriteCloser

func OsUserHomeDir

func OsUserHomeDir() (string, error)

func OverwriteDssConfig

func OverwriteDssConfig(bc DssBaseConfig, dssConfig interface{}) error

func Parent

func Parent(npath string) (parent string)

func RemoveSlashIf

func RemoveSlashIf(path string) string

func RemoveSlashIfNsIf

func RemoveSlashIfNsIf(path string, isNs bool) string

func RestServerConfigurator

func RestServerConfigurator(e *echo.Echo, root string, configs map[string]interface{}) error

func SaveDssConfig

func SaveDssConfig(bc DssBaseConfig, dssConfig interface{}) error

func SaveUserConfig

func SaveUserConfig(config DssBaseConfig, configDir string, uc UserConfig) error

func UserConfigPutIdentity

func UserConfigPutIdentity(config DssBaseConfig, configDir string, identity IdentityConfig) error

func Users

func Users(aes []ACLEntry) (users []string)

func WebDssServerConfigurator

func WebDssServerConfigurator(e *echo.Echo, root string, configs map[string]interface{}) error

func WebTestServerConfigurator

func WebTestServerConfigurator(e *echo.Echo, root string, _ map[string]interface{}) error

func WfsDssServerConfigurator

func WfsDssServerConfigurator(e *echo.Echo, root string, configs map[string]interface{}) error

Types

type ACLEntry

type ACLEntry struct {
	// on unix-like fsy DSS: x-uid:<uid> or x-gid:<gid> will be honored
	User   string `json:"user"` // on encrypted DSS, any alias for an IdentityConfig whose secret is owned by the user will be honored
	Rights Rights `json:"rights"`
}

func CheckUiACL

func CheckUiACL(sacl []string) (acl []ACLEntry, err error)

CheckUiACL convert a list of <user:rights> strings into actual ACL

func (ACLEntry) GetRights

func (ace ACLEntry) GetRights() Rights

func (ACLEntry) GetUser

func (ace ACLEntry) GetUser() string

type AuditIndexInfo

type AuditIndexInfo struct {
	Error string // "IndexInternal", "IndexMissing", "StorageMissing", "Inconsistent"
	Err   error  // origin error
	Time  int64  // the time of the entry in the DSS
	Bytes []byte // the metadata
}

func (AuditIndexInfo) String

func (aii AuditIndexInfo) String() string

type Client

type Client struct {
	http.Client
	// contains filtered or unexported fields
}

func (*Client) Do

func (c *Client) Do(req *http.Request, opts *ClientReqOpts) (*http.Response, error)

type ClientReqOpts

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

type ContentHandle

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

func (*ContentHandle) Close

func (ch *ContentHandle) Close() (err error)

func (*ContentHandle) Write

func (ch *ContentHandle) Write(p []byte) (n int, err error)

type CreateNewParams

type CreateNewParams struct {
	ConfigPassword string                                                      // if not "" master password used to encrypt client configuration
	ConfigDir      string                                                      // if not "" path to the user's configuration directory
	Create         bool                                                        // perform CreateXxx or NewXxx?
	DssType        string                                                      // fsy, olf, obs, smf
	Root           string                                                      // fsy, olf, smf
	Size           string                                                      // if olf: s,m,l
	LocalPath      string                                                      // fsy, obs, smf (Root assumed if olf or smf)
	Encrypted      bool                                                        // all but fsy: enable repository encryption
	GetIndex       func(config DssBaseConfig, localPath string) (Index, error) // see DssBaseConfig
	Lsttime        int64                                                       // all but fsy: if not zero is the upper time of entries retrieved in it
	Aclusers       []string                                                    // all but fsy: if not nil is a List of ACL users for access check
	Endpoint       string                                                      // obs: AWS S3 or Openstack Swift endpoint, eg "https://s3.gra.cloud.ovh.net"
	Region         string                                                      // obs: AWS S3  or Openstack Swift region, eg "GRA"
	AccessKey      string                                                      // obs: AWS S3 access key (Openstack Swift must generate it)
	SecretKey      string                                                      // obs: AWS S3 secret key (Openstack Swift must generate it)
	Container      string                                                      // obs: AWS S3 bucket or Openstack Swift container
	RedLimit       int                                                         // all: reducer limit or 0
}

type Dss

type Dss interface {
	// Mkns creates a namespace in the Dss, return an error if any happens
	//
	// npath is the full namespace without leading or trailing slash
	// mtime is the last modification POSIX time
	// children are the children names, a trailing slash denotes a namespace, else regular content
	// acl is the access control List to the namespace
	Mkns(npath string, mtime int64, children []string, acl []ACLEntry) error

	// Updatens updates a namespace in the Dss, return an error if any happens
	//
	// npath is the full namespace without leading or trailing slash
	// mtime is the last modification POSIX time
	// children are the children names, a trailing slash denotes a namespace, else regular content
	// acl is the access control List to the namespace
	Updatens(npath string, mtime int64, children []string, acl []ACLEntry) error

	// Lsns lists a namespace's content, return it or an error if any happens
	//
	// npath is the full namespace without leading or trailing slash
	//
	// returns:
	// - children names, a trailing slash denotes a namespace, else regular content
	// - err error if any happens
	Lsns(npath string) (children []string, err error)

	// IsDuplicate checks if content's checksum ch already exists in DSS
	//
	// returns duplicate status and an error if any happens
	IsDuplicate(ch string) (bool, error)

	// GetContentWriter creates content for writing
	//
	// npath is the full namespace + name without leading slash
	// mtime is the last modification POSIX time
	// acl is the access control List to the content
	// cb if not nil is a callback called when writer is closed
	//
	// returns:
	// - a writer to provide the content
	// - err error if any happens
	GetContentWriter(npath string, mtime int64, acl []ACLEntry, cb WriteCloserCb) (io.WriteCloser, error)

	// GetContentReader opens content for reading
	//
	// npath is the full namespace + name without leading slash
	//
	// returns:
	// - a reader to retrieve the content
	// - err error if any happens
	GetContentReader(npath string) (io.ReadCloser, error)

	// Symlink makes a symlink from npath to target path
	//
	// npath is the full namespace + name without leading slash
	// tpath is the target as a relative path following underlying OS conventions
	// mtime is the last modification POSIX time
	// acl is the access control List to the content
	//
	// returns:
	// - err error if any happens
	Symlink(npath string, tpath string, mtime int64, acl []ACLEntry) error

	// Remove removes a namespace (and recursively its children) or some content
	//
	// npath is the full namespace + name without leading slash, trailing slash indicates it is a namespace
	//
	// returns:
	// - err error if any happens
	Remove(npath string) error

	// GetMeta gets a namespace or some content metadata
	//
	// npath is the full namespace + name without leading slash, trailing slash indicates it is a namespace
	//
	// returns:
	// - the metadata
	// - err error if any happens
	GetMeta(npath string, getCh bool) (IMeta, error)

	// SetCurrentTime injects arbitrary current time for tests
	// does nothing on fsy DSS
	SetCurrentTime(time int64)

	// SetMetaMockCbs injects arbitrary json [un]marshal for tests if build tag constraint enables
	SetMetaMockCbs(cbs *MetaMockCbs)

	// SetAfs injects abstract FS for tests if build tag constraint enables
	SetAfs(tfs afero.Fs)

	// GetAfs retrieves it
	GetAfs() afero.Fs

	// Close can be necessary to perform final cleanup or index synchronization
	Close() error

	// SetSu enables superuser access for synchro
	SetSu()

	// SuEnableWrite enables physical write access for fsy: DSS in case SetSu is active
	//
	// npath is the full namespace + name without leading slash, trailing slash indicates it is a namespace
	//
	// returns:
	// - err error if any happens
	SuEnableWrite(npath string) error
}

Dss is the Data Storage System interface.

Any Dss should implement this interface.

func CreateOrNewDss

func CreateOrNewDss(params CreateNewParams) (dss Dss, err error)

func NewFsyDss

func NewFsyDss(config FsyConfig, root string) (Dss, error)

func NewWfsDss

func NewWfsDss(wdc WfsDssConfig) (Dss, error)

NewWfsDss opens a web client for a remote "fsy" DSS (data storage system) wdc provides the web client configuration returns a pointer to the ready to use DSS or an error if any occur

type DssBaseConfig

type DssBaseConfig struct {
	ConfigDir         string                                                      `json:"-"`          // if not "" path to the user's configuration directory
	ConfigPassword    string                                                      `json:"-"`          // if master password is used to encrypt client configuration
	LocalPath         string                                                      `json:"-"`          // local path for configuration and index, or "" if unused (index will be memory based)
	RepoId            string                                                      `json:"repoId"`     // uuid of the repository
	Unlock            bool                                                        `json:"-"`          // unlocks index concurrent updates lock
	AutoRepair        bool                                                        `json:"autoRepair"` // if unlock required, automatically repairs the index
	ReIndex           bool                                                        `json:"-"`          // forces full content reindexation
	GetIndex          func(config DssBaseConfig, localPath string) (Index, error) `json:"-"`          // non-default function to instantiate an index
	XImpl             string                                                      `json:"xImpl"`      // index implementation code: bdb, memory, no
	LibApi            bool                                                        `json:"-"`          // prevents using a web API server for local DSS access
	WebProtocol       string                                                      `json:"-"`          // web API server protocol
	WebHost           string                                                      `json:"-"`          // web API server host
	WebPort           string                                                      `json:"-"`          // web API server port
	WebClientTimeout  time.Duration                                               `json:"-"`          // client timeout in seconds, a Timeout of zero means no timeout
	TlsCert           string                                                      `json:"-"`          // certificate file on https server or untrusted CA on https client
	TlsKey            string                                                      `json:"-"`          // certificate key file on https server
	TlsNoCheck        bool                                                        `json:"-"`          // no check of certificate by https client
	BasicAuthUser     string                                                      `json:"-"`          // adds basic authentication
	BasicAuthPassword string                                                      `json:"-"`          // basic authentication password
	WebRoot           string                                                      `json:"-"`          // web API server root
	Encrypted         bool                                                        `json:"encrypted"`  // repository is encrypted
	ReducerLimit      int                                                         `json:"-"`          // if not 0 max number of parallel I/O
}

type EDssConfig

type EDssConfig struct {
	WebDssConfig
}

type ErrBadParameter

type ErrBadParameter struct {
	Key   string
	Value fmt.Stringer
	Err   error
}

ErrBadParameter is returned when REST API receives a bad parameter

func (*ErrBadParameter) Error

func (e *ErrBadParameter) Error() string

func (*ErrBadParameter) Unwrap

func (e *ErrBadParameter) Unwrap() error

type ErrorCollector

type ErrorCollector []error

func (*ErrorCollector) Any

func (c *ErrorCollector) Any() bool

func (*ErrorCollector) Collect

func (c *ErrorCollector) Collect(e error)

func (*ErrorCollector) Error

func (c *ErrorCollector) Error() (err string)

type FsyConfig

type FsyConfig struct {
	DssBaseConfig
}

type FsyDss

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

func (*FsyDss) Close

func (fsy *FsyDss) Close() error

func (*FsyDss) GetAfs

func (fsy *FsyDss) GetAfs() afero.Fs

func (*FsyDss) GetContentReader

func (fsy *FsyDss) GetContentReader(npath string) (rc io.ReadCloser, err error)

func (*FsyDss) GetContentWriter

func (fsy *FsyDss) GetContentWriter(npath string, mtime int64, acl []ACLEntry, cb WriteCloserCb) (wc io.WriteCloser, err error)

func (*FsyDss) GetMeta

func (fsy *FsyDss) GetMeta(npath string, getCh bool) (meta IMeta, err error)

func (*FsyDss) GetRoot

func (fsy *FsyDss) GetRoot() string

func (*FsyDss) IsDuplicate

func (fsy *FsyDss) IsDuplicate(ch string) (bool, error)

func (*FsyDss) Lsns

func (fsy *FsyDss) Lsns(npath string) (children []string, err error)

func (*FsyDss) Mkns

func (fsy *FsyDss) Mkns(npath string, mtime int64, children []string, acl []ACLEntry) error

func (*FsyDss) Remove

func (fsy *FsyDss) Remove(npath string) (err error)

func (*FsyDss) SetAfs

func (fsy *FsyDss) SetAfs(afs afero.Fs)

func (*FsyDss) SetCurrentTime

func (fsy *FsyDss) SetCurrentTime(time int64)

func (*FsyDss) SetMetaMockCbs

func (fsy *FsyDss) SetMetaMockCbs(cbs *MetaMockCbs)

func (*FsyDss) SetSu

func (fsy *FsyDss) SetSu()

func (*FsyDss) SuEnableWrite

func (fsy *FsyDss) SuEnableWrite(npath string) error
func (fsy *FsyDss) Symlink(npath string, tpath string, mtime int64, acl []ACLEntry) error

func (*FsyDss) Updatens

func (fsy *FsyDss) Updatens(npath string, mtime int64, children []string, acl []ACLEntry) error

type HDss

type HDss interface {
	Dss

	// GetHistory gets the history of the npath entry as a map of entry state sorted by time
	//
	// npath is the full namespace + name without leading slash, trailing slash indicates it is a namespace
	// recursive requests the service to recursively get the history of all namespace children
	// resolution "s" for seconds, "m" for minutes, "h" for hours, "d" for days summarizes the history with given resolution
	//
	// returns:
	// - the history (inclusive times when the entry is visible) for all entries
	// - err error if any happens
	GetHistory(npath string, recursive bool, resolution string) (map[string][]HistoryInfo, error)

	// RemoveHistory removes history entries for a given time period
	//
	// it must be noted that removing a parent history may cause children to be removed for a larger period of time
	//
	// npath is the full namespace + name without leading slash, trailing slash indicates it is a namespace
	// recursive requests the service to recursively remove the history of all namespace children,
	// evaluate don't remove, just report work to be done
	// start is the inclusive index time above which entries must be removed, zero meanning all past entries
	// end is the inclusive index time below which entries must be removed, zero meaning all future entries
	//
	// returns:
	// - the history (inclusive times when the entry is removed) for all entries
	// - err error if any happens
	RemoveHistory(npath string, recursive, evaluate bool, start, end int64) (map[string][]HistoryInfo, error)

	// GetIndex provides the DSS index or nil
	GetIndex() Index

	// DumpIndex for debug
	DumpIndex() string

	// GetRepoId provides the DSS repoId or ""
	GetRepoId() string

	// IsEncrypted tells if repository is encrypted
	IsEncrypted() bool

	// IsRepoEncrypted tells if repository configuration is set to encrypted
	IsRepoEncrypted() bool

	// AuditIndex compares the DSS index with meta and content actually stored
	AuditIndex() (map[string][]AuditIndexInfo, error)

	// ScanStorage scans the DSS storage and loads meta and content sha256 sum
	//
	// checksum checks content checksums
	// purge removes unreferenced content from the repository
	// purgeHidden removes hidden meta and content from the repository
	ScanStorage(checksum, purge, purgeHidden bool) (StorageInfo, *ErrorCollector)

	// GetHistoryChunks returns history chunks loaded from local index
	//
	// resolution s, m, h, d from seconds to days
	//
	// returns:
	// - the DSS activity periods sorted by time
	// - err error if any happens
	GetHistoryChunks(resolution string) ([]HistoryChunk, error)

	// Reindex scans the DSS storage and loads meta and content sha256 sum into the index
	Reindex() (StorageInfo, *ErrorCollector)
}

HDss is the Data Storage System interface for DSS with history support.

func CreateObsDss

func CreateObsDss(config ObsConfig) (HDss, error)

CreateObsDss creates an "object-storage" DSS (data storage system) config provides the object store specification returns a pointer to the ready to use DSS or an error if any occur

func CreateOlfDss

func CreateOlfDss(config OlfConfig) (HDss, error)

CreateOlfDss creates an "object-storage-like files" DSS data storage system config provides the object store specification returns a pointer to the ready to use DSS or an error if any occur

func NewEDss

func NewEDss(config EDssConfig, slsttime int64, aclusers []string) (HDss, error)

NewEDss opens a web or direct api client for an "object-storage" encrypted DSS (data storage system) config provides the object store specification lsttime if not zero is the upper time of entries retrieved in it aclusers if not nil is a List of ACL users for access check and for decryption returns a pointer to the ready to use DSS or an error if any occur If lsttime is not zero, access will be read-only

func NewObsDss

func NewObsDss(config ObsConfig, slsttime int64, aclusers []string) (HDss, error)

NewObsDss opens an "object-storage" DSS (data storage system) config provides the object store specification lsttime if not zero is the upper time of entries retrieved in it aclusers if not nil is a List of ACL users for access check returns a pointer to the ready to use DSS or an error if any occur If lsttime is not zero, access will be read-only

func NewOlfDss

func NewOlfDss(config OlfConfig, slsttime int64, aclusers []string) (HDss, error)

NewOlfDss opens an "object-storage-like files" DSS (data storage system) config provides the object store specification lsttime if not zero is the upper time of entries retrieved in it aclusers if not nil is a List of ACL users for access check returns a pointer to the ready to use DSS or an error if any occur If lsttime is not zero, access will be read-only

func NewWebDss

func NewWebDss(config WebDssConfig, slsttime int64, aclusers []string) (HDss, error)

NewWebDss opens a web client for an "object-storage" DSS (data storage system) config provides the object store specification lsttime if not zero is the upper time of entries retrieved in it aclusers if not nil is a List of ACL users for access check returns a pointer to the ready to use DSS or an error if any occur If lsttime is not zero, access will be read-only

type HistoryChunk

type HistoryChunk struct {
	Start int64 `json:"start"` // period start time POSIX aligned to resolution
	End   int64 `json:"end"`   // period end time POSIX aligned to resolution
	Count int   `json:"count"` // number of history updates in the time period
}

func (HistoryChunk) String

func (hc HistoryChunk) String() string

type HistoryInfo

type HistoryInfo struct {
	Start int64 // start time POSIX of the history entry
	End   int64 // end time POSIX of the history entry
	HMeta Meta  // the  metadata
}

func (HistoryInfo) String

func (hi HistoryInfo) String() string

type IMeta

type IMeta interface {
	GetPath() string                     // path in the DSS
	GetMtime() int64                     // last modification POSIX time
	GetSize() int64                      // content size
	GetCh() string                       // content truncated SHA256 checksum (panic if DSS does not enable)
	GetChUnsafe() string                 // content truncated SHA256 checksum or empty if DSS does not enable
	GetIsNs() bool                       // is it a namespace, if true has children
	GetChildren() []string               // namespace children, sorted by name
	GetIsSymLink() bool                  // is it a symbolic link, if true has SymLinkTarget
	GetSymLinkTarget() string            // target of the symbolic link
	GetAcl() []ACLEntry                  // access control List, sorted by user
	GetItime() int64                     // index time
	Equals(other IMeta, chacl bool) bool // checks equality (does not compare Ch if one end is unavailable) compare ACL if chacl true
}

type IS3Session

type IS3Session interface {
	Initialize() error
	Check() error
	List(prefix string) ([]string, error)
	Meta(key string) (S3Meta, error)
	Put(key string, content []byte) error
	Get(key string) ([]byte, error)
	Upload(key string, r io.Reader) error
	Download(key string) (io.ReadCloser, error)
	Delete(key string) error
	DeleteAll(prefix string) error
}

func NewS3Session

func NewS3Session(config ObsConfig, getMock func(IS3Session) IS3Session) IS3Session

func NewS3sMockFs

func NewS3sMockFs(root string, getMock func(IS3Session) IS3Session) IS3Session

func NewS3sMockTests

func NewS3sMockTests(parent IS3Session, testsCb func(args ...any) interface{}) IS3Session

type IdentityConfig

type IdentityConfig struct {
	Alias  string `json:"alias"`
	PKey   string `json:"pKey"`
	Secret string `json:"secret"`
}

IdentityConfig refers to an age identity identified by an alias, Identities are used for encryption (PKeys of the ACL users using identities aliases) and for decryption (secrets of the DSS aclusers using identities aliases) "" is the default alias for an identity when none is provided

func GenIdentity

func GenIdentity(alias string) (IdentityConfig, error)

type Index

type Index interface {
	IsPersistent() bool

	Close() error
	Repair(readOnly bool) ([]string, error)
	Dump() string
	// contains filtered or unexported methods
}

func GetPIndex

func GetPIndex(bc DssBaseConfig, localPath string) (Index, error)

GetPIndex provides the buntdb index with the localPath

func NewMIndex

func NewMIndex() Index

func NewNIndex

func NewNIndex() Index

func NewPIndex

func NewPIndex(path string, unlock, autoRepair bool) (Index, error)

type LibApiDssConfig

type LibApiDssConfig struct {
	IsOlf  bool
	OlfCfg OlfConfig
	IsObs  bool
	IsSmf  bool
	ObsCfg ObsConfig
}

type Meta

type Meta struct {
	Path          string     `json:"path"`                    // full path for data content
	Mtime         int64      `json:"mtime"`                   // last modification POSIX time
	Size          int64      `json:"size"`                    // content size
	Ch            string     `json:"ch"`                      // truncated SHA256 checksum of the content
	IsNs          bool       `json:"isNs"`                    // is it a namespace, if true has children
	Children      []string   `json:"children"`                // namespace children, sorted by name
	IsSymLink     bool       `json:"isSymLink,omitempty"`     // is it a symbolic link, if true has SymLinkTarget
	SymLinkTarget string     `json:"symLinkTarget,omitempty"` // target of the symbolic link
	ACL           []ACLEntry `json:"acl"`                     // access control List, sorted by user
	Itime         int64      `json:"itime"`                   // index time
	ECh           string     `json:"ech"`                     // truncated SHA256 checksum of the encrypted content if encrypted else empty
	EMId          string     `json:"emid"`                    // encrypted meta-data unique identifier if encrypted else empty
}

func (Meta) Equals

func (m Meta) Equals(om IMeta, chacl bool) bool

func (Meta) GetAcl

func (m Meta) GetAcl() []ACLEntry

func (Meta) GetCh

func (m Meta) GetCh() string

func (Meta) GetChUnsafe

func (m Meta) GetChUnsafe() string

func (Meta) GetChildren

func (m Meta) GetChildren() []string

func (Meta) GetIsNs

func (m Meta) GetIsNs() bool
func (m Meta) GetIsSymLink() bool

func (Meta) GetItime

func (m Meta) GetItime() int64

func (Meta) GetMtime

func (m Meta) GetMtime() int64

func (Meta) GetPath

func (m Meta) GetPath() string

func (Meta) GetSize

func (m Meta) GetSize() int64

func (Meta) GetSymLinkTarget

func (m Meta) GetSymLinkTarget() string

type MetaMockCbs

type MetaMockCbs struct {
	MockMarshal   func(v interface{}) ([]byte, error)
	MockUnmarshal func(data []byte, v interface{}) error
}

type ODss

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

func (*ODss) AuditIndex

func (ods *ODss) AuditIndex() (map[string][]AuditIndexInfo, error)

func (*ODss) Close

func (ods *ODss) Close() error

func (*ODss) DumpIndex

func (ods *ODss) DumpIndex() string

func (*ODss) GetAfs

func (ods *ODss) GetAfs() afero.Fs

func (*ODss) GetContentReader

func (ods *ODss) GetContentReader(npath string) (rc io.ReadCloser, err error)

func (*ODss) GetContentWriter

func (ods *ODss) GetContentWriter(npath string, mtime int64, acl []ACLEntry, cb WriteCloserCb) (wc io.WriteCloser, err error)

func (*ODss) GetHistory

func (ods *ODss) GetHistory(npath string, recursive bool, resolution string) (map[string][]HistoryInfo, error)

func (*ODss) GetHistoryChunks

func (ods *ODss) GetHistoryChunks(resolution string) ([]HistoryChunk, error)

func (*ODss) GetIndex

func (ods *ODss) GetIndex() Index

func (*ODss) GetMeta

func (ods *ODss) GetMeta(npath string, getCh bool) (meta IMeta, err error)

func (*ODss) GetRepoId

func (ods *ODss) GetRepoId() string

func (*ODss) IsDuplicate

func (ods *ODss) IsDuplicate(ch string) (bool, error)

func (*ODss) IsEncrypted

func (ods *ODss) IsEncrypted() bool

func (*ODss) IsRepoEncrypted

func (ods *ODss) IsRepoEncrypted() bool

func (*ODss) Lsns

func (ods *ODss) Lsns(npath string) (children []string, err error)

func (*ODss) Mkns

func (ods *ODss) Mkns(npath string, mtime int64, children []string, acl []ACLEntry) error

func (*ODss) Reindex

func (ods *ODss) Reindex() (StorageInfo, *ErrorCollector)

func (*ODss) Remove

func (ods *ODss) Remove(npath string) (err error)

func (*ODss) RemoveHistory

func (ods *ODss) RemoveHistory(npath string, recursive, evaluate bool, start, end int64) (map[string][]HistoryInfo, error)

func (*ODss) ScanStorage

func (ods *ODss) ScanStorage(checksum, purge, purgeHidden bool) (StorageInfo, *ErrorCollector)

func (*ODss) SetAfs

func (ods *ODss) SetAfs(tfs afero.Fs)

func (*ODss) SetCurrentTime

func (ods *ODss) SetCurrentTime(time int64)

func (*ODss) SetMetaMockCbs

func (ods *ODss) SetMetaMockCbs(cbs *MetaMockCbs)

func (*ODss) SetSu

func (ods *ODss) SetSu()

func (*ODss) SuEnableWrite

func (ods *ODss) SuEnableWrite(string) error
func (ods *ODss) Symlink(npath string, tpath string, mtime int64, acl []ACLEntry) (err error)

func (*ODss) Updatens

func (ods *ODss) Updatens(npath string, mtime int64, children []string, acl []ACLEntry) error

type ObsConfig

type ObsConfig struct {
	DssBaseConfig
	Endpoint     string            `json:"endpoint"`  // AWS S3 or Openstack Swift endpoint, eg "https://s3.gra.cloud.ovh.net"
	Region       string            `json:"region"`    // AWS S3  or Openstack Swift region, eg "GRA"
	AccessKey    string            `json:"accessKey"` // AWS S3 access key (Openstack Swift must generate it)
	SecretKey    string            `json:"secretKey"` // AWS S3 secret key (Openstack Swift must generate it)
	Container    string            `json:"container"` // AWS S3 bucket or Openstack Swift container
	GetS3Session func() IS3Session `json:"-"`         // if not nil enables to set a mock S3 implementation
}

type OlfConfig

type OlfConfig struct {
	DssBaseConfig
	Root string // filesystem root for the OLF DSS
	Size string // DSS size may be small, medium or large ("s", "m" or "l")

}

type PixClient

type PixClient struct {
	InternalId int `json:"internalId"` // client internal id (key prefix to client entries in DB)
	TxId       int `json:"txCounter"`  // current client transaction id (key prefix to client new transactions in DB)
}

type PixClients

type PixClients struct {
	IdCounter int                   `json:"counter"` // next internal id to be used
	Clients   map[string]*PixClient `json:"clients"` // mapping external client id to internal id
}

type ReadCloserWithCb

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

func (*ReadCloserWithCb) Close

func (rcwc *ReadCloserWithCb) Close() error

func (*ReadCloserWithCb) Read

func (rcwc *ReadCloserWithCb) Read(p []byte) (n int, err error)

type Rights

type Rights struct {
	Read    bool `json:"read"`
	Write   bool `json:"write"`
	Execute bool `json:"execute"`
}

func GetUserRights

func GetUserRights(aes []ACLEntry, user string, defaultRights Rights) Rights

type S3Meta

type S3Meta struct {
	Length int64
}

type SIHnIt

type SIHnIt struct {
	Hn string `json:"hn"`
	It int64  `json:"it"`
}

type StorageInfo

type StorageInfo struct {
	Path2Meta     map[string][]byte           `json:"path2Meta"`
	Path2CMeta    map[string][]byte           `json:"path2CMeta"`
	Path2HnIt     map[string]SIHnIt           `json:"path2HnIt"`
	ExistingCs    map[string]bool             `json:"existingCs"`
	ExistingEcs   map[string]bool             `json:"existingEcs"`
	Path2Content  map[string]string           `json:"path2Content"`
	Path2CContent map[string]string           `json:"path2CContent"`
	Path2Error    map[string]error            `json:"path2Error"`
	XLMetas       map[string]map[int64][]byte `json:"xlmetas"` // Local meta data
	XRMetas       map[string]map[int64][]byte `json:"xrmetas"` // Remote meta data
}

type TempFileWriteCloserWithCb

type TempFileWriteCloserWithCb struct {
	WriteCloserWithCb
	// contains filtered or unexported fields
}

type TimeResolution

type TimeResolution string

TimeResolution values are "s" seconds, "m" minutes, "h" hours, "d" days

func (TimeResolution) Align

func (tr TimeResolution) Align(ns int64) int64

func (TimeResolution) NanoSeconds

func (tr TimeResolution) NanoSeconds() int64

type TimedMeta

type TimedMeta struct {
	Time  int64  `json:"time,string"`
	Bytes string `json:"bytes"`
}

type TlsConfig

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

type UnixNanoUTC

type UnixNanoUTC int64

func (UnixNanoUTC) String

func (t UnixNanoUTC) String() string

type UnixUTC

type UnixUTC int64

func (UnixUTC) String

func (t UnixUTC) String() string

type UpdatedData

type UpdatedData struct {
	Changed map[string][]TimedMeta `json:"changed"`
	Deleted map[string]bool        `json:"deleted"`
}

type UserConfig

type UserConfig struct {
	ClientId   string `json:"clientId"`
	Identities []IdentityConfig
	Internal   IdentityConfig
}

func CurrentUserConfig

func CurrentUserConfig(config DssBaseConfig) (uc UserConfig, err error)

func GetHomeUserConfig

func GetHomeUserConfig(config DssBaseConfig) (UserConfig, error)

func GetUserConfig

func GetUserConfig(config DssBaseConfig, configDir string) (UserConfig, error)

func (*UserConfig) GetIdentity

func (uc *UserConfig) GetIdentity(alias string) IdentityConfig

func (*UserConfig) PutIdentity

func (uc *UserConfig) PutIdentity(identity IdentityConfig)

type WebApiClient

type WebApiClient interface {
	Url() string
	DoAsJson(request *http.Request, outBody any) (*http.Response, error)
	SimpleDoAsJson(method, url string, inBody any, outBody any) (*http.Response, error)
	GetConfig() interface{}
	SetCabriHeader(h string)
}

func NewWebApiClient

func NewWebApiClient(protocol string, host string, port string, tlsConfig *TlsConfig, root string, config interface{}, timeout time.Duration) (WebApiClient, error)

type WebDssConfig

type WebDssConfig struct {
	DssBaseConfig
	LibApiDssConfig
	ClId string
}

type WebDssServerConfig

type WebDssServerConfig struct {
	WebServerConfig
	UserConfig
	Dss HDss
}

type WebServer

type WebServer interface {
	Serve() error
	Shutdown() error
	ConfigureApi(
		root string, customConfig interface{},
		shutdownCallback func(root string, customConfigs map[string]interface{}) error,
		ctor func(e *echo.Echo, root string, customConfigs map[string]interface{}) error,
	) error
	// contains filtered or unexported methods
}

func NewEServer

func NewEServer(addr string, hasLog bool, tlsConfig *TlsConfig) WebServer

func NewRestServer

func NewRestServer(root string, config WebDssServerConfig) (WebServer, error)

func NewWebDssServer

func NewWebDssServer(root string, config WebDssServerConfig) (WebServer, error)

func NewWfsDssServer

func NewWfsDssServer(root string, config WfsDssServerConfig) (WebServer, error)

type WebServerConfig

type WebServerConfig struct {
	Addr              string // host[:port]
	HasLog            bool
	IsTls             bool   // https
	TlsCert           string // certificate file on https server or untrusted CA on https client
	TlsKey            string // certificate key file on https server
	TlsNoCheck        bool   // no check of certificate by https client
	BasicAuthUser     string
	BasicAuthPassword string
}

type WfsDssConfig

type WfsDssConfig struct {
	DssBaseConfig
}

type WfsDssServerConfig

type WfsDssServerConfig struct {
	WebServerConfig
	Dss Dss
}

type WriteCloserCb

type WriteCloserCb func(err error, size int64, ch string)

type WriteCloserErrCb

type WriteCloserErrCb func(err error, size int64, ch string, me *WriteCloserWithCb) error

type WriteCloserWithCb

type WriteCloserWithCb struct {
	Underlying io.WriteCloser
	// contains filtered or unexported fields
}

func (*WriteCloserWithCb) Close

func (wcwc *WriteCloserWithCb) Close() error

func (*WriteCloserWithCb) Write

func (wcwc *WriteCloserWithCb) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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