commands

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTMNameTooLong = fmt.Errorf("TM name too long (max %d allowed)", maxNameLength)

Functions

func AttachmentFetch

func AttachmentFetch(ctx context.Context, spec model.RepoSpec, ref model.AttachmentContainerRef, attachmentName string) ([]byte, error)

func CalculateFileDigest

func CalculateFileDigest(raw []byte) (string, []byte, error)

CalculateFileDigest calculates the hash string for TM version. Returns the 12-char hash string, the file contents that were hashed, and an error. The contents that were hashed may differ from the input. The changes to the contents are made to make the hashing reliable and idempotent: normalizing line endings, and setting 'id' to empty string If the file is not a valid json, the function is not guaranteed to return with an error

func Delete

func Delete(ctx context.Context, rSpec model.RepoSpec, id string) error

func DeleteAttachment

func DeleteAttachment(ctx context.Context, spec model.RepoSpec, ref model.AttachmentContainerRef, attachmentName string) error

func FetchByName

func FetchByName(ctx context.Context, spec model.RepoSpec, fn model.FetchName, restoreId bool) (string, []byte, error, []*repos.RepoAccessError)

func FetchByTMID

func FetchByTMID(ctx context.Context, spec model.RepoSpec, tmid string, restoreId bool) (string, []byte, error, []*repos.RepoAccessError)

func FetchByTMIDOrName

func FetchByTMIDOrName(ctx context.Context, spec model.RepoSpec, idOrName string, restoreId bool) (string, []byte, error, []*repos.RepoAccessError)

func GetTMMetadata

func GetTMMetadata(ctx context.Context, spec model.RepoSpec, tmID string) ([]model.FoundVersion, error, []*repos.RepoAccessError)

func ImportAttachment

func ImportAttachment(ctx context.Context, spec model.RepoSpec, ref model.AttachmentContainerRef, att model.Attachment, content []byte, force bool) error

Types

type ImportCommand

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

func NewImportCommand

func NewImportCommand(now Now) *ImportCommand

func (*ImportCommand) ImportFile

func (c *ImportCommand) ImportFile(ctx context.Context, raw []byte, repo repos.Repo, opts repos.ImportOptions) (repos.ImportResult, error)

ImportFile prepares file contents for importing (generates id if necessary, etc.) and imports to repo. Returns ImportResult which includes the ID that the TM has been stored under, and error. If the repo already contains the same TM, the error will be an instance of repos.ErrTMIDConflict

type Now

type Now func() time.Time

type VersionsCommand

type VersionsCommand struct {
}

func NewVersionsCommand

func NewVersionsCommand() *VersionsCommand

func (*VersionsCommand) ListVersions

func (c *VersionsCommand) ListVersions(ctx context.Context, spec model.RepoSpec, name string) ([]model.FoundVersion, error, []*repos.RepoAccessError)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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