file

package
v0.0.0-...-36c55c0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package file provides file management API handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(
	logger *slog.Logger,
	objStore ObjectStoreManager,
	stateKV StateKeyValue,
	signingKey string,
	customRoles map[string][]string,
) []func(e *echo.Echo)

Handler returns file route registration functions.

Types

type File

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

File implementation of the File APIs operations.

func New

func New(
	logger *slog.Logger,
	objStore ObjectStoreManager,
	stateKV StateKeyValue,
) *File

New factory to create a new instance.

func (*File) DeleteFileByName

DeleteFileByName delete a file from the Object Store.

func (*File) GetFileByName

GetFileByName get metadata for a specific file in the Object Store.

func (*File) GetFileStale

GetFileStale returns deployments where the source object has been updated since the file was last deployed.

func (*File) GetFiles

GetFiles list all files stored in the Object Store.

func (*File) PostFile

func (f *File) PostFile(
	ctx context.Context,
	request gen.PostFileRequestObject,
) (gen.PostFileResponseObject, error)

PostFile upload a file to the Object Store via multipart/form-data.

type ObjectStoreManager

type ObjectStoreManager interface {
	// Put stores data from a reader under the given metadata.
	Put(
		ctx context.Context,
		meta jetstream.ObjectMeta,
		reader io.Reader,
	) (*jetstream.ObjectInfo, error)

	// PutBytes stores data under the given name.
	PutBytes(ctx context.Context, name string, data []byte) (*jetstream.ObjectInfo, error)

	// GetBytes retrieves the content stored under the given name.
	GetBytes(ctx context.Context, name string, opts ...jetstream.GetObjectOpt) ([]byte, error)

	// GetInfo retrieves metadata for the named object.
	GetInfo(
		ctx context.Context,
		name string,
		opts ...jetstream.GetObjectInfoOpt,
	) (*jetstream.ObjectInfo, error)

	// Delete removes the named object.
	Delete(ctx context.Context, name string) error

	// List returns metadata for all objects in the store.
	List(ctx context.Context, opts ...jetstream.ListObjectsOpt) ([]*jetstream.ObjectInfo, error)
}

ObjectStoreManager wraps the subset of jetstream.ObjectStore methods needed by the file API handlers. This minimal interface enables straightforward mocking in tests.

type StateKeyValue

type StateKeyValue interface {
	Keys(ctx context.Context, opts ...jetstream.WatchOpt) ([]string, error)
	Get(ctx context.Context, key string) (jetstream.KeyValueEntry, error)
}

StateKeyValue wraps the subset of jetstream.KeyValue methods needed by the file stale check.

Directories

Path Synopsis
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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