github

package
v1.1013.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func (d *Driver) Close() error

Close releases resources held by the driver. The GitHub source holds no open handles, so Close always returns nil.

func (*Driver) First

func (d *Driver) First() (uint, error)

First returns the lowest migration version, or an os.ErrNotExist-wrapped error when the source has no migrations.

func (*Driver) Next

func (d *Driver) Next(version uint) (uint, error)

Next returns the migration version following version, or an os.ErrNotExist-wrapped error when none exists.

func (*Driver) Open

func (d *Driver) Open(rawURL string) (source.Driver, error)

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

func (d *Driver) Prev(version uint) (uint, error)

Prev returns the migration version preceding version, or an os.ErrNotExist-wrapped error when none exists.

func (*Driver) ReadDown

func (d *Driver) ReadDown(version uint) (io.ReadCloser, string, error)

ReadDown returns the down migration body and its identifier for version, or an os.ErrNotExist-wrapped error when no down migration exists for version. The caller owns the returned reader and must close it.

func (*Driver) ReadUp

func (d *Driver) ReadUp(version uint) (io.ReadCloser, string, error)

ReadUp returns the up migration body and its identifier for version, or an os.ErrNotExist-wrapped error when no up migration exists for version. The caller owns the returned reader and must close it.

Jump to

Keyboard shortcuts

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