convert

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyChunk    = errors.New("missing chunk")
	ErrNoLocFunction = errors.New("missing location function")
)

Functions

This section is empty.

Types

type DumpConverter

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

func NewToDump

func NewToDump(src source.Sourcer, trg fsadapter.FS, opts ...DumpOption) *DumpConverter

NewToDump creates a new dump converter.

func (*DumpConverter) Convert

func (d *DumpConverter) Convert(ctx context.Context) error

type DumpOption

type DumpOption func(*DumpConverter)

func DumpWithIncludeFiles

func DumpWithIncludeFiles(b bool) DumpOption

func DumpWithLogger

func DumpWithLogger(log *slog.Logger) DumpOption

type FileCopier

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

func NewFileCopier

func NewFileCopier(src source.Sourcer, trg fsadapter.FS, trgLoc func(*slack.Channel, *slack.File) string, enabled bool) *FileCopier

func (*FileCopier) Copy

func (c *FileCopier) Copy(ch *slack.Channel, msg *slack.Message) error

Copy iterates through the files in the message and copies them to the target directory. Source file location is determined by calling the srcFileLoc function, joined with the chunk directory name. target file location — by calling trgFileLoc function, and is relative to the target fsadapter root.

type Option

type Option func(*options)

func WithIgnoreCopyErrors

func WithIgnoreCopyErrors(b bool) Option

func WithIncludeAvatars

func WithIncludeAvatars(b bool) Option

WithIncludeAvatars sets the IncludeAvatars option.

func WithIncludeFiles

func WithIncludeFiles(b bool) Option

WithIncludeFiles sets the IncludeFiles option.

func WithLogger

func WithLogger(lg *slog.Logger) Option

WithLogger sets the logger.

func WithTrgFileLoc

func WithTrgFileLoc(fn func(*slack.Channel, *slack.File) string) Option

WithTrgFileLoc sets the TrgFileLoc function.

type SourceEncoder

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

SourceEncoder allows to convert any source to a chunked format.

func NewSourceEncoder

func NewSourceEncoder(src source.Sourcer, fsa fsadapter.FS, enc chunk.Encoder, opts ...Option) *SourceEncoder

func (*SourceEncoder) Convert

func (s *SourceEncoder) Convert(ctx context.Context) error

type Target

type Target interface {
	// Convert should convert the data for the single channel and save it to
	// the target format.
	transform.Converter
	// Users should convert and write users.
	Users(ctx context.Context, uu []slack.User) error
	// Channels should converts and write channels.
	Channels(ctx context.Context, uu []slack.Channel) error
	// WorkspaceInfo writes workspace info.
	WorkspaceInfo(ctx context.Context, wi *slack.AuthTestResponse) error
}

Target is the interface for writing the target format.

type ToExport

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

ToExport is a converter between Chunk and Export formats. Zero value is not usable.

func NewToExport

func NewToExport(src source.Sourcer, trg fsadapter.FS, opt ...Option) *ToExport

NewToExport returns the converter from any source to export format. src is the Source to be converted (e.g. chunk or database), trgfs is the target FS adapter where files and data will be written. By default, the converter does not include files and avatars. The default storage format for both source and destination is Mattermost, use functional options to configure this behaviour.

func (*ToExport) Convert

func (c *ToExport) Convert(ctx context.Context) error

Convert converts the chunk directory contents to the export format. It validates the input parameters.

func (*ToExport) Validate

func (c *ToExport) Validate() error

Validate validates the input parameters.

Directories

Path Synopsis
Package mock_convert is a generated GoMock package.
Package mock_convert is a generated GoMock package.
fileproc
Package fileproc is the file processor that can be used in conjunction with the transformer.
Package fileproc is the file processor that can be used in conjunction with the transformer.

Jump to

Keyboard shortcuts

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