Documentation
¶
Index ¶
- Variables
- type Client
- type ClientOptions
- type File
- func (f *File) Close() error
- func (f *File) Name() string
- func (f *File) RangeReader(offset, length int64) (io.ReadCloser, error)
- func (f *File) Read(p []byte) (n int, err error)
- func (f *File) ReadAt(p []byte, off int64) (n int, err error)
- func (f *File) Readdir(count int) ([]os.FileInfo, error)
- func (f *File) ReaddirAll() ([]os.FileInfo, error)
- func (f *File) Readdirnames(count int) ([]string, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Truncate(size int64) error
- func (f *File) Write(p []byte) (int, error)
- func (f *File) WriteAt(p []byte, off int64) (int, error)
- func (f *File) WriteString(s string) (n int, err error)
- type Fs
- func (fs *Fs) Branch() string
- func (fs *Fs) Chmod(name string, mode os.FileMode) error
- func (fs *Fs) Chown(name string, uid, gid int) error
- func (fs *Fs) Chtimes(name string, atime, mtime time.Time) error
- func (fs *Fs) Create(name string) (afero.File, error)
- func (fs *Fs) Mkdir(name string, perm os.FileMode) error
- func (fs *Fs) MkdirAll(path string, perm os.FileMode) error
- func (*Fs) Name() string
- func (fs *Fs) Open(name string) (afero.File, error)
- func (fs *Fs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
- func (fs *Fs) Owner() string
- func (fs *Fs) Remove(name string) error
- func (fs *Fs) RemoveAll(path string) error
- func (fs *Fs) Rename(oldname, newname string) error
- func (fs *Fs) Repo() string
- func (fs *Fs) Stat(name string) (os.FileInfo, error)
- type GitHubFileInfo
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyOpened = errors.New("already opened")
ErrAlreadyOpened is returned when the file is already opened
var ErrExist = errors.New("already exists")
ErrExist is returned when a file or dir already exists
var ErrInvalidSeek = errors.New("invalid seek offset")
ErrInvalidSeek is returned when the seek operation is not doable
var ErrNotExist = errors.New("does not exist")
ErrNotExist is returned when a file or dir does not exist
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented is returned when this operation is not (yet) implemented
var ErrNotSupported = errors.New("git fs doesn't support this operation")
ErrNotSupported is returned when this operations is not supported by Git FS
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around the github.Client that provides additional functionality and configuration options.
type ClientOptions ¶
ClientOptions is a function type that defines the signature for configuration options that can be applied to the Client struct.
func WithGithubApplication ¶
func WithGithubApplication(clientID string, installationID int64, privateKey []byte) ClientOptions
WithGithubApplication is a ClientOption that configures the Client to use GitHub App authentication.
func WithGithubClient ¶
func WithGithubClient(githubClient *gh.Client) ClientOptions
WithGithubClient is a ClientOption that sets the github.Client directly on the Client struct.
func WithGithubToken ¶
func WithGithubToken(token string) ClientOptions
WithGithubToken is a ClientOption that configures the Client to use a personal access token for authentication with GitHub.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a file in the GitHub repository. It contains a reference to the Fs it belongs to and the name of the file.
func (*File) Close ¶
Close closes the file, flushing any dirty content to GitHub if necessary. It returns an error if the file is already closed or if the flush operation fails.
func (*File) RangeReader ¶
func (f *File) RangeReader(offset, length int64) (io.ReadCloser, error)
RangeReader returns an io.ReadCloser that reads a specific byte range from the file. It uses HTTP Range requests against the raw content endpoint to efficiently fetch only the requested portion of the file. It returns an error if the file is closed, is a directory, is not readable, or if the range parameters are invalid.
func (*File) Read ¶
Read implements the io.Reader interface for the File. It reads data from the file's reader and returns the number of bytes read and any error encountered. It returns an error if the file is closed, is a directory, or is not readable.
func (*File) ReadAt ¶
ReadAt implements the io.ReaderAt interface for the File. It reads data from the file's reader at the specified offset and returns the number of bytes read and any error encountered.
func (*File) Readdir ¶
Readdir reads the contents of the directory and returns a slice of os.FileInfo for the entries. It maintains an internal offset to allow for multiple calls to Readdir, returning subsequent entries until the end of the directory is reached.
func (*File) ReaddirAll ¶
ReaddirAll returns all the directory entries. It resets the internal offset to allow for subsequent calls to return the full listing again.
func (*File) Readdirnames ¶
Readdirnames returns a slice of the names of the directory entries. It uses Readdir to get the entries and extracts their names.
func (*File) Seek ¶
Seek implements the io.Seeker interface for the File. It changes the read/write position in the file based on the offset and whence parameters. It returns the new position and any error encountered. It returns an error if the file is closed, is a directory, or if the whence parameter is invalid.
func (*File) Stat ¶
Stat returns the FileInfo structure describing the file. It returns an error if the file is closed.
func (*File) Sync ¶
Sync flushes the file's content to GitHub if it has been modified (dirty). It returns an error if the file is closed or if the flush operation fails.
func (*File) Truncate ¶
Truncate changes the size of the file to the specified size. If the file is extended, the new bytes are zero-filled. It marks the file as dirty if it was modified. It returns an error if the file is closed or if the file is not writable.
func (*File) Write ¶
Write implements the io.Writer interface for the File. It writes data to the file's buffer and returns the number of bytes written and any error encountered. It marks the file as dirty if it was modified. It returns an error if the file is closed, is a directory, or is not writable.
func (*File) WriteAt ¶
WriteAt implements the io.WriterAt interface for the File. It writes data to the file's buffer at the specified offset and returns the number of bytes written and any error encountered. It marks the file as dirty if it was modified. It returns an error if the file is closed, is a directory, or is not writable.
func (*File) WriteString ¶
WriteString writes the string s to the file. It returns the number of bytes written and any error encountered. It marks the file as dirty if it was modified. It returns an error if the file is closed, is a directory, or is not writable.
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs is an FS object backed by a GitHub repository. It provides methods to interact with the repository's file system.
func NewFsFromClient ¶
NewFsFromClient creates a new Fs instance using the provided Client and repository name.
func (*Fs) Create ¶
Create creates a new file with the specified name. It is a wrapper around OpenFile with appropriate flags for creating a new file.
func (*Fs) Mkdir ¶
Mkdir creates a new directory with the specified name. Since GitHub doesn't have real directories, this is implemented by creating a placeholder file (".gitkeep) in the target directory.
func (*Fs) MkdirAll ¶
MkdirAll creates a directory and all necessary parents. It iteratively checks each level of the path and creates directories as needed.
func (*Fs) Open ¶
Open opens the named file for reading. It is a wrapper around OpenFile with appropriate flags for read-only access.
func (*Fs) OpenFile ¶
OpenFile opens the named file with specified flags and permissions. It handles various scenarios such as reading from cache, fetching from GitHub, and preparing files for writing.
func (*Fs) Remove ¶
Remove deletes the specified file from the GitHub repository. It first ensures that the file exists and retrieves its SHA, then it constructs a commit message and options for the GitHub API call to delete the file. If the deletion is successful, it evicts the file from the cache.
func (*Fs) RemoveAll ¶
RemoveAll deletes the specified file or directory and all its contents from the GitHub repository. If the path is a directory, it recursively deletes all child files and directories before deleting the directory itself. If the path does not exist, it returns nil.
func (*Fs) Rename ¶
Rename renames (moves) a file from oldname to newname. It reads the content of the source file, writes it to the destination path, and then deletes the source file. If any step fails, it returns an appropriate error.
func (*Fs) Stat ¶
Stat retrieves the FileInfo for the specified path. It first checks the cache for a valid entry, and if not found or invalid, it queries GitHub. It handles both file and directory responses from GitHub, populating the SHA cache as needed. If the path does not exist, it returns an os.PathError with ErrNotExist.
type GitHubFileInfo ¶
type GitHubFileInfo struct {
// contains filtered or unexported fields
}
GitHubFileInfo implements os.FileInfo.
func (*GitHubFileInfo) IsDir ¶
func (fi *GitHubFileInfo) IsDir() bool
func (*GitHubFileInfo) ModTime ¶
func (fi *GitHubFileInfo) ModTime() time.Time
func (*GitHubFileInfo) Mode ¶
func (fi *GitHubFileInfo) Mode() os.FileMode
func (*GitHubFileInfo) Name ¶
func (fi *GitHubFileInfo) Name() string
func (*GitHubFileInfo) Size ¶
func (fi *GitHubFileInfo) Size() int64
func (*GitHubFileInfo) Sys ¶
func (fi *GitHubFileInfo) Sys() any
type Option ¶
type Option func(*Fs)
Option is a functional option for GitHubFs.
func WithAPITimeout ¶
WithAPITimeout overrides the per-request timeout (15 s).
func WithCacheTTL ¶
WithCacheTTL overrides the default cache TTL (5 min).
func WithCommitAuthor ¶
WithCommitAuthor sets the author stamped on every commit.