hub

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchFileOps

func BatchFileOps(fsys fs.FS, batchSize int) iter.Seq2[[]*storev1.FileOp, error]

BatchFileOps walks the given file system and produces batches of FileOp objects that can be used with the ModifyFiles RPC.

func ToMetadata

func ToMetadata(metadata map[string]any) (map[string]*structpb.Value, error)

ToMetadata creates a metadata map suitable for attaching to the uploader and/or internal source fields of the ChangeDetails object.

func Zip

func Zip(fsys fs.FS) ([]byte, error)

Zip creates zipped data from the files in the given file system. To zip a directory, use hub.Zip(os.DirFS(/path/to/dir)).

Types

type ChangeDetails

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

func NewChangeDetails

func NewChangeDetails(description string) *ChangeDetails

func (*ChangeDetails) WithOriginGit

func (cd *ChangeDetails) WithOriginGit(repo, hash string) *ChangeDetails

WithOriginGit sets the given git repo and hash as the source of the store upload operation.

func (*ChangeDetails) WithOriginGitDetails

func (cd *ChangeDetails) WithOriginGitDetails(gitInfo *storev1.ChangeDetails_Git) *ChangeDetails

WithOriginGitDetails sets the full details about the git commit that is used as the source for this store upload operation.

func (*ChangeDetails) WithOriginInternal

func (cd *ChangeDetails) WithOriginInternal(source string) *ChangeDetails

WithOriginInternal sets the source of the store upload operation as an internal, non-git source.

func (*ChangeDetails) WithOriginInternalDetails

func (cd *ChangeDetails) WithOriginInternalDetails(internalInfo *storev1.ChangeDetails_Internal) *ChangeDetails

WithOriginInternalDetails sets the full details about the internal source used for the store upload operation. Use the `ToMetadata` helper function to construct metadata.

func (*ChangeDetails) WithUploader

func (cd *ChangeDetails) WithUploader(name string) *ChangeDetails

WithUploader sets the name of the uploader for the store operation.

func (*ChangeDetails) WithUploaderDetails

func (cd *ChangeDetails) WithUploaderDetails(uploader *storev1.ChangeDetails_Uploader) *ChangeDetails

WithUploaderDetails sets the complete uploader details object for the store operation. Use the `ToMetadata` helper function to construct the metadata object for the uploader.

type FileFilter

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

func FilterPathContains added in v0.3.7

func FilterPathContains(path string) *FileFilter

FilterPathContains creates a filter that partially matches the given path.

func FilterPathEqual

func FilterPathEqual(path string) *FileFilter

Create a filter that matches the given path exactly.

func FilterPathIn

func FilterPathIn(paths ...string) *FileFilter

FilterPathIn creates a filter that matches one or more of the set of paths exactly.

func (*FileFilter) Proto

func (ff *FileFilter) Proto() *storev1.FileFilter

func (*FileFilter) Validate

func (ff *FileFilter) Validate() error

type GetCurrentVersionRequest added in v0.3.13

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

func NewGetCurrentVersionRequest added in v0.3.13

func NewGetCurrentVersionRequest(storeID string) *GetCurrentVersionRequest

func (*GetCurrentVersionRequest) Proto added in v0.3.13

func (*GetCurrentVersionRequest) Validate added in v0.3.13

func (gcvr *GetCurrentVersionRequest) Validate() error

type GetCurrentVersionResponse added in v0.3.13

type GetCurrentVersionResponse struct {
	*storev1.GetCurrentVersionResponse
}

func (*GetCurrentVersionResponse) MarshalJSON added in v0.3.13

func (gcvr *GetCurrentVersionResponse) MarshalJSON() ([]byte, error)

func (*GetCurrentVersionResponse) String added in v0.3.13

func (gcvr *GetCurrentVersionResponse) String() string

type GetFilesRequest

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

func NewGetFilesRequest

func NewGetFilesRequest(storeID string, files []string) *GetFilesRequest

func (*GetFilesRequest) Proto

func (gfr *GetFilesRequest) Proto() *storev1.GetFilesRequest

func (*GetFilesRequest) Validate

func (gfr *GetFilesRequest) Validate() error

type GetFilesResponse

type GetFilesResponse struct {
	*storev1.GetFilesResponse
}

func (*GetFilesResponse) AsMap

func (gfr *GetFilesResponse) AsMap() map[string][]byte

func (*GetFilesResponse) MarshalJSON

func (gfr *GetFilesResponse) MarshalJSON() ([]byte, error)

func (*GetFilesResponse) String

func (gfr *GetFilesResponse) String() string

type InvalidRequestError

type InvalidRequestError struct {
	Violations []*protovalidate.Violation
	// contains filtered or unexported fields
}

func (InvalidRequestError) Error

func (ire InvalidRequestError) Error() string

func (InvalidRequestError) Unwrap

func (ire InvalidRequestError) Unwrap() error

type ListFilesRequest

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

func NewListFilesRequest

func NewListFilesRequest(storeID string) *ListFilesRequest

func (*ListFilesRequest) Proto

func (*ListFilesRequest) Validate

func (lfr *ListFilesRequest) Validate() error

func (*ListFilesRequest) WithFileFilter

func (lfr *ListFilesRequest) WithFileFilter(filter *FileFilter) *ListFilesRequest

type ListFilesResponse

type ListFilesResponse struct {
	*storev1.ListFilesResponse
}

func (*ListFilesResponse) MarshalJSON

func (lfr *ListFilesResponse) MarshalJSON() ([]byte, error)

func (*ListFilesResponse) String

func (lfr *ListFilesResponse) String() string

type ModifyFilesRequest

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

func NewModifyFilesRequest

func NewModifyFilesRequest(storeID, message string) *ModifyFilesRequest

func (*ModifyFilesRequest) AddOps

func (mfr *ModifyFilesRequest) AddOps(ops ...*storev1.FileOp) *ModifyFilesRequest

func (*ModifyFilesRequest) AddOrUpdateFile

func (mfr *ModifyFilesRequest) AddOrUpdateFile(path string, contents []byte) *ModifyFilesRequest

func (*ModifyFilesRequest) DeleteFile

func (mfr *ModifyFilesRequest) DeleteFile(path string) *ModifyFilesRequest

func (*ModifyFilesRequest) OnlyIfVersionEquals

func (mfr *ModifyFilesRequest) OnlyIfVersionEquals(version int64) *ModifyFilesRequest

func (*ModifyFilesRequest) Proto

func (*ModifyFilesRequest) Validate

func (mfr *ModifyFilesRequest) Validate() error

func (*ModifyFilesRequest) WithChangeDetails

func (mfr *ModifyFilesRequest) WithChangeDetails(cd *ChangeDetails) *ModifyFilesRequest

type ModifyFilesResponse

type ModifyFilesResponse struct {
	*storev1.ModifyFilesResponse
}

func (*ModifyFilesResponse) MarshalJSON

func (mfr *ModifyFilesResponse) MarshalJSON() ([]byte, error)

func (*ModifyFilesResponse) String

func (mfr *ModifyFilesResponse) String() string

type ReplaceFilesRequest

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

func NewReplaceFilesRequest

func NewReplaceFilesRequest(storeID, message string) *ReplaceFilesRequest

func (*ReplaceFilesRequest) OnlyIfVersionEquals

func (rfr *ReplaceFilesRequest) OnlyIfVersionEquals(version int64) *ReplaceFilesRequest

func (*ReplaceFilesRequest) Proto

func (*ReplaceFilesRequest) Validate

func (rfr *ReplaceFilesRequest) Validate() error

func (*ReplaceFilesRequest) WithChangeDetails

func (rfr *ReplaceFilesRequest) WithChangeDetails(cd *ChangeDetails) *ReplaceFilesRequest

func (*ReplaceFilesRequest) WithFiles added in v0.3.5

func (rfr *ReplaceFilesRequest) WithFiles(files ...*storev1.File) *ReplaceFilesRequest

func (*ReplaceFilesRequest) WithZippedContents added in v0.3.5

func (rfr *ReplaceFilesRequest) WithZippedContents(zippedContents []byte) *ReplaceFilesRequest

type ReplaceFilesResponse

type ReplaceFilesResponse struct {
	*storev1.ReplaceFilesResponse
}

func (*ReplaceFilesResponse) MarshalJSON

func (rfr *ReplaceFilesResponse) MarshalJSON() ([]byte, error)

func (*ReplaceFilesResponse) String

func (rfr *ReplaceFilesResponse) String() string

type StoreClient

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

func NewStoreClient

func NewStoreClient(client *store.Client) *StoreClient

func (*StoreClient) GetCurrentVersion added in v0.3.13

func (*StoreClient) GetFiles

func (sc *StoreClient) GetFiles(ctx context.Context, req *GetFilesRequest) (*GetFilesResponse, error)

func (*StoreClient) ListFiles

func (sc *StoreClient) ListFiles(ctx context.Context, req *ListFilesRequest) (*ListFilesResponse, error)

ListFiles returns the list of file paths currently available in the store.

func (*StoreClient) ModifyFiles

func (sc *StoreClient) ModifyFiles(ctx context.Context, req *ModifyFilesRequest) (*ModifyFilesResponse, error)

ModifyFiles applies the given set of file modifications to the remote store. If the call doesn't modify the remote store (e.g. if the same request was sent twice in a row), it returns an error indicating that the operation was discarded.

func (*StoreClient) ModifyFilesLenient

func (sc *StoreClient) ModifyFilesLenient(ctx context.Context, req *ModifyFilesRequest) (*ModifyFilesResponse, error)

ModifyFilesLenient applies the given set of file modifications to the remote store. This method ignores the error from the backend when the call doesn't make a discernible change to the store to create a new version.

func (*StoreClient) ReplaceFiles

func (sc *StoreClient) ReplaceFiles(ctx context.Context, req *ReplaceFilesRequest) (*ReplaceFilesResponse, error)

ReplaceFiles overwrites the store so that it only contains the valid files included in the request. If the call doesn't modify the remote store (e.g. if the same request was sent twice in a row), it returns an error indicating that the operation was discarded.

func (*StoreClient) ReplaceFilesLenient

func (sc *StoreClient) ReplaceFilesLenient(ctx context.Context, req *ReplaceFilesRequest) (*ReplaceFilesResponse, error)

ReplaceFilesLenient overwrites the store so that it only contains the valid files included in the request. This method ignores the error from the backend when the call doesn't make a discernible change to the store to create a new version.

type StoreRPCError

type StoreRPCError = store.RPCError

Jump to

Keyboard shortcuts

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