mirrors

package
v0.0.0-...-a806f0a Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mirrors handles managing mirrors in the running application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(k string) (bool, string, string, string)

Get retrieves information about an mirror. It returns. - bool if found - new repo location - vcs type

func Load

func Load() error

Load pulls the mirrors into memory

Types

type MirrorRepo

type MirrorRepo struct {
	Original string `yaml:"original"`
	Repo     string `yaml:"repo"`
	Base     string `yaml:"base,omitempty"`
	Vcs      string `yaml:"vcs,omitempty"`
}

MirrorRepo represents a single repo mirror

type MirrorRepos

type MirrorRepos []*MirrorRepo

MirrorRepos is a slice of Mirror pointers

func (MirrorRepos) Len

func (o MirrorRepos) Len() int

Len returns the length of the MirrorRepos. This is needed for sorting with the sort package.

func (MirrorRepos) Less

func (o MirrorRepos) Less(i, j int) bool

Less is needed for the sort interface. It compares two MirrorRepos based on their original value.

func (MirrorRepos) Swap

func (o MirrorRepos) Swap(i, j int)

Swap is needed for the sort interface. It swaps the position of two MirrorRepos.

type Mirrors

type Mirrors struct {

	// Repos contains repo mirror configuration
	Repos MirrorRepos `yaml:"repos"`
}

Mirrors contains global mirrors to local configuration

func FromYaml

func FromYaml(yml []byte) (*Mirrors, error)

FromYaml returns an instance of Mirrors from YAML

func ReadMirrorsFile

func ReadMirrorsFile(opath string) (*Mirrors, error)

ReadMirrorsFile loads the contents of an mirrors.yaml file.

func (*Mirrors) Marshal

func (ov *Mirrors) Marshal() ([]byte, error)

Marshal converts a Mirror instance to YAML

func (*Mirrors) MarshalYAML

func (ov *Mirrors) MarshalYAML() (interface{}, error)

MarshalYAML is a hook for gopkg.in/yaml.v2. It sorts mirror repos lexicographically for reproducibility.

func (*Mirrors) WriteFile

func (ov *Mirrors) WriteFile(opath string) error

WriteFile writes an mirrors.yaml file

This is a convenience function that marshals the YAML and then writes it to the given file. If the file exists, it will be clobbered.

Jump to

Keyboard shortcuts

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