mog

package module
v0.0.0-...-e855e9e Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

README

mog

Mog is a tool to easily upload Go module metadata to GCS based on local Git repositories.

This is useful if you host your own Go module metadata.

Install

This tool requires the gsutil binary.

Using Go tooling:

go install ./mog
Fast checksum

Install crcmod to speed up checksuming in gsutil:

sudo pip install -U crcmod

Usage

Mog
# make changes to the repo
# from root directory containing .git:
$ mog
+v0.0.0-20200516000000-f0e6e3aa032b  # all commits are added as package versions
...
List
# list local versions (stored in $MOG_DIR):
$ tree $(mog env MOG_DIR)

# push changes to a GCP bucket:
$ mog push gs://bucket/path
Cleanup
rm -r $(mog env MOG_DIR)
Push
mog push gs://path/to/remote/mog

This is the same as gsutil -m rsync -r $MOG_DIR $URL, but with additional safety checks.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(key string) string

Getenv gets the environ value or default used by the mog command line tool.

func WriteDir

func WriteDir(dir string, mog Mog) error

WriteDir writes the mog to the given local mog directory.

Types

type Diff

type Diff struct {
	DiffType DiffType
	Key      Key
}

Diff describes whether Key was added or removed between mogs.

func (Diff) String

func (d Diff) String() string

type DiffResult

type DiffResult []Diff

DiffResult is the result of comparing two mogs.

func GetDiff

func GetDiff(m1, m2 Mog) DiffResult

GetDiff computes the diff between the mogs. A diff is excluded from the result if the package name is not present in both m1 and m2.

func (DiffResult) Len

func (d DiffResult) Len() int

func (DiffResult) Less

func (d DiffResult) Less(i, j int) bool

func (DiffResult) Swap

func (d DiffResult) Swap(i, j int)

type DiffType

type DiffType int

DiffType describes the type of a Diff.

const (
	DiffRemove DiffType = iota
	DiffAdd
)

DiffType constants.

type Key

type Key struct {
	Name    string `json:"-"`       // path/to/package (case encoded)
	Version string `json:"Version"` // v0.0.0-MMDDYYhhmmss-shortsha1
}

Key contains name and version information needed to fully qualify a package.

func (Key) String

func (k Key) String() string

type Mog

type Mog []Package

Mog is a slice of versioned Packages.

func ReadDir

func ReadDir(dir string) (Mog, error)

ReadDir reads the mog in the given local mog directory. dir must be set to an existing Mog root.

func (*Mog) Add

func (m *Mog) Add(pkg Package)

Add adds the given single package to the mog m.

func (*Mog) AddGit

func (m *Mog) AddGit(dir string) error

AddGit adds all package versions from the git repository at dir to the mog m.

func (Mog) Len

func (m Mog) Len() int

func (Mog) Less

func (m Mog) Less(i, j int) bool

func (Mog) Swap

func (m Mog) Swap(i, j int)

type Package

type Package struct {
	Key
	Time time.Time `json:"Time"`
	// contains filtered or unexported fields
}

Package represents a versioned, hermetic mog package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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