Documentation
¶
Overview ¶
Package github provides a golang-migrate source driver that reads migration files from a GitHub repository.
It exists so Migrieren depends on a maintained go-github release (github.com/google/go-github/v89) instead of the upstream golang-migrate GitHub source driver, which pins github.com/google/go-github/v39 and transitively imports the unmaintained golang.org/x/crypto/openpgp package (advisory GO-2026-5932).
The driver registers itself under the "github" source name in an init function, so importing this package for its side effects replaces the upstream driver. Do not also import github.com/golang-migrate/migrate/v4/source/github, or source.Register will panic on the duplicate name.
Index ¶
- Variables
- type Driver
- func (d *Driver) Close() error
- func (d *Driver) First() (uint, error)
- func (d *Driver) Next(version uint) (uint, error)
- func (d *Driver) Open(rawURL string) (source.Driver, error)
- func (d *Driver) Prev(version uint) (uint, error)
- func (d *Driver) ReadDown(version uint) (io.ReadCloser, string, error)
- func (d *Driver) ReadUp(version uint) (io.ReadCloser, string, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoPassword is returned by Open when a github:// URL carries user info // but no password (personal access token). ErrNoPassword = errors.New("github source: no password provided") // ErrInvalidRepository is returned by Open when a github:// URL does not // contain a repository segment. ErrInvalidRepository = errors.New("github source: invalid repository") // ErrNotDirectory is returned by Open when the configured path resolves to a // file rather than a directory of migrations. ErrNotDirectory = errors.New("github source: path is not a directory") // ErrDuplicateMigration is returned by Open when the directory listing holds // more than one migration for the same version and direction. ErrDuplicateMigration = errors.New("github source: duplicate migration") )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is a golang-migrate source driver that reads migration files from a GitHub repository using github.com/google/go-github.
The zero value is only valid as the registration placeholder whose Open method builds usable instances; all other methods assume an instance returned by Open.
func (*Driver) Close ¶
Close releases resources held by the driver. The GitHub source holds no open handles, so Close always returns nil.
func (*Driver) First ¶
First returns the lowest migration version, or an os.ErrNotExist-wrapped error when the source has no migrations.
func (*Driver) Next ¶
Next returns the migration version following version, or an os.ErrNotExist-wrapped error when none exists.
func (*Driver) Open ¶
Open opens a GitHub migration source from a github:// URL of the form
github://[user:personal-access-token@]owner/repository[/path][#ref]
The optional user info supplies a personal access token as the password; the user name is ignored. Without a token the repository is read unauthenticated. The optional fragment selects a git ref (branch, tag, or SHA) and defaults to the repository's default branch.
Open lists the migration directory eagerly and returns ErrNoPassword when user info is present without a password, ErrInvalidRepository when no repository segment is present, ErrNotDirectory when the path resolves to a file, or the underlying go-github error when the listing fails.
Open does not accept a context and is not request-scoped; callers that need bounded validation should avoid opening GitHub sources (see github.com/alexfalkowski/migrieren/internal/migrate/source.Check).
func (*Driver) Prev ¶
Prev returns the migration version preceding version, or an os.ErrNotExist-wrapped error when none exists.