adapter

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissFormField = usererror.BadRequest("miss required form field")
	ErrMissPathField = usererror.BadRequest("path field is missing")

	ErrInvalidPackageName       = usererror.BadRequest("invalid package name")
	ErrInvalidPackageVersion    = usererror.BadRequest("invalid package version")
	ErrInvalidGroupName         = usererror.BadRequest("invalid group name")
	ErrInvalidPackageContent    = usererror.BadRequest("invalid package content")
	ErrStorageFileAlreadyExists = usererror.BadRequest("storage file already exists")
	ErrStorageFileNotChanged    = usererror.BadRequest("storage file not changed")
)

Functions

func BlobPath

func BlobPath(p string) string

func GenerateSha256

func GenerateSha256() string

func NewTemporaryWriter

func NewTemporaryWriter(ctx context.Context, store storage.ContentStorage, temporaryId string, append bool) (storagedriver.FileWriter, error)

func TemporaryPath

func TemporaryPath(p string) string

Types

type ArtifactIndexUpdater

type ArtifactIndexUpdater interface {
	// UpdatePackage will be called after a new version of package is upload,
	// some format-adapter need to generate package-level index file
	UpdatePackage(ctx context.Context, p *types.ArtifactPackage, v *types.ArtifactView) error

	// UpdateRepo will be called after a new version of package is upload,
	// some format-adapter need to generate repository-level index file
	UpdateRepo(ctx context.Context, v *types.ArtifactView) error
	CommitWriter
}

ArtifactIndexUpdater is an index update interface every format-adapter should implement it

type ArtifactPackageUploader

type ArtifactPackageUploader interface {
	Serve(ctx context.Context, req *http.Request) (int64, error)
	IsValid(ctx context.Context) error
	Cancel(ctx context.Context) error
	Save(ctx context.Context) error
}

type AssetDescriptor

type AssetDescriptor struct {
	Attr ModelAttribute

	Path        string
	Ref         string
	Size        int64
	Metadata    MetadataInterface
	ContentType string
	Format      types.ArtifactFormat
	Kind        types.AssetKind

	Hash *Hash
}

type CommitWriter

type CommitWriter interface {
	Commit(ctx context.Context) error
	Cancel(ctx context.Context) error
}

type Hash

type Hash struct {
	Md5    string `json:"md5"`
	Sha1   string `json:"sha1"`
	Sha256 string `json:"sha256"`
	Sha512 string `json:"sha512"`
}

func (*Hash) String

func (h *Hash) String() string

type HashWriter

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

func NewHashWriter

func NewHashWriter() *HashWriter

func (*HashWriter) Sum

func (h *HashWriter) Sum() *Hash

func (*HashWriter) Write

func (h *HashWriter) Write(p []byte) (int, error)

type MetadataInterface

type MetadataInterface interface {
	ToJSON() (json.RawMessage, error)
}

type ModelAttribute

type ModelAttribute string
const (
	// AttrAssetNormal should be bind to a version
	AttrAssetNormal ModelAttribute = "normal"

	// AttrAssetIsolated does not bind to version nor view, used for container blobs
	AttrAssetIsolated ModelAttribute = "isolated"

	// AttrAssetExclusive require the version has only one asset, others should be removed
	AttrAssetExclusive ModelAttribute = "exclusive"

	// AttrAssetIndex only bind to view, used for generated index
	AttrAssetIndex ModelAttribute = "index"
)

type ModelManager

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

func NewModelManager

func NewModelManager(artStore store.ArtifactStore, view *ViewDescriptor, pkg *PackageDescriptor, creator *types.Principal) *ModelManager

func (*ModelManager) Sync

func (mm *ModelManager) Sync(ctx context.Context, assetDesc *AssetDescriptor) (*types.ArtifactAsset, error)

type PackageDescriptor

type PackageDescriptor struct {
	// The artifact package's name
	Name string

	Namespace string

	Version         string
	VersionMetadata MetadataInterface

	Format types.ArtifactFormat

	// Upload file info
	MainAsset *AssetDescriptor

	// auto created sub files
	SubAssets []*AssetDescriptor
}

func NewEmptyPackageDescriptor

func NewEmptyPackageDescriptor() *PackageDescriptor

func (*PackageDescriptor) AddSub

func (p *PackageDescriptor) AddSub(asset *AssetDescriptor)

type PackageMetaDescriptor

type PackageMetaDescriptor struct {
	Name string

	Format types.ArtifactFormat

	MainAsset *AssetDescriptor

	// auto created sub files
	SubAssets []*AssetDescriptor
}

func NewEmptyPackageMetaDescriptor

func NewEmptyPackageMetaDescriptor() *PackageMetaDescriptor

func (*PackageMetaDescriptor) AddSub

func (p *PackageMetaDescriptor) AddSub(asset *AssetDescriptor)

type StorageFileWriter

type StorageFileWriter struct {
	Layout StorageLayout
	Writer storagedriver.FileWriter

	Key  string
	Path string
}

func NewStorageBlobWriter

func NewStorageBlobWriter(ctx context.Context, store storage.ContentStorage, ref string, append bool) (*StorageFileWriter, error)

func NewStorageFileWriter

func NewStorageFileWriter(ctx context.Context, path string, append bool, store storage.ContentStorage) (*StorageFileWriter, error)

func (*StorageFileWriter) SetPath

func (s *StorageFileWriter) SetPath(p string)

type StorageFileWriterList

type StorageFileWriterList []*StorageFileWriter

type StorageLayout

type StorageLayout string
const (
	StorageLayoutBlob StorageLayout = "blob"
	StorageLayoutPath StorageLayout = "path"
)

type VersionMetadata

type VersionMetadata struct {
	CreatorName string `json:"creator_name"`
}

func (*VersionMetadata) ToJSON

func (m *VersionMetadata) ToJSON() (json.RawMessage, error)

type ViewDescriptor

type ViewDescriptor struct {
	ViewID    int64
	OwnerID   int64
	StorageID int64
	Store     storage.ContentStorage
	Space     *types.Space
}

Directories

Path Synopsis
gc

Jump to

Keyboard shortcuts

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