registry

package
v0.0.0-...-2bbe97e Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const RegTypeFile = "file"

RegTypeFile is the type of this registry

View Source
const RegTypeGit = "git"

RegTypeGit is the type of the repository this file handles

View Source
const RegTypeLocal = "local"

RegTypeLocal is the type of this registry

View Source
const RegTypeURL = "url"

RegTypeURL is the type of the repository of this file

Variables

View Source
var (
	// ErrorEmptyPathGiven will be thrown if the given path is not valid
	ErrorEmptyPathGiven = errors.New("No path given... call it with 'file <path>'")
	// ErrorNoValidPathGiven will be thrown if the given path is not valid
	ErrorNoValidPathGiven = errors.New("The given path is not valid")
)
View Source
var (
	// ErrorNoValidRepositoryGiven will be thrown if the given repository is not valid
	ErrorNoValidRepositoryGiven = errors.New("Given repository is not valid")
	// ErrorNoIndexInGitRepository will be thrown when the given git repository has no index.json file
	ErrorNoIndexInGitRepository = errors.New("The given git repository has no index.json file")
)
View Source
var (
	// BucketKey is the key under which all registries are stored in the database
	BucketKey = "registries"
	// Types is a factory function to bootstrap different registries
	Types = map[string]Factory{
		RegTypeGit:   &GitFactory{},
		RegTypeLocal: &FileFactory{},
		RegTypeFile:  &FileFactory{},
		RegTypeURL:   &URLFactory{},
	}
	// ErrorNoName will be thrown if a registry has no name, which is required
	ErrorNoName = errors.New("A registry has no name")
	// ErrorAlreadyExists will be thrown if the registry already exists
	ErrorAlreadyExists = errors.New("Registry already exists")
	// ErrorRegistryNotFound will be thrown if the given registry cannot be found in the database
	ErrorRegistryNotFound = errors.New("Registry not found")
	// RegistryUpdateInterval is the interval after that a registry will automatically update their tools. This can be forced
	RegistryUpdateInterval = 24 * time.Hour
	// DefaultRegistryURL is the URL of the default registry. It will be added on the first run only.
	DefaultRegistryURL = "https://github.com/adobe/sledgehammer-registry.git"
)
View Source
var (
	// ErrorNoValidURLGiven will be thrown if the given URL is not valid
	ErrorNoValidURLGiven = errors.New("No valid URL given")
)

Functions

This section is empty.

Types

type Data

type Data struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Path        string `json:"path"`
	Maintainer  string `json:"maintainer"`
	Description string `json:"description"`
}

Data contains the base data for a registry

type Factory

type Factory interface {
	Raw() Registry
	Create(d Data, args []string) (Registry, error)
}

Factory is a factory to create registries from the db and from user input

type FileFactory

type FileFactory struct{}

FileFactory is the factory for the FileRegistry

func (*FileFactory) Create

func (g *FileFactory) Create(d Data, args []string) (Registry, error)

Create will take data and return a FileRegistry from the given arguments

func (*FileFactory) Raw

func (g *FileFactory) Raw() Registry

Raw will return a raw GitRepository struct for populating from the db

type FileRegistry

type FileRegistry struct {
	Location string `json:"location"`
	Core     Data   `json:"core"`
}

FileRegistry represents a registry where the tools are stored on a local filesystem. This is mostly useful for development of tools, registries and sledgehammer itself.

func (*FileRegistry) Data

func (r *FileRegistry) Data() *Data

Data return the data of the registry

func (*FileRegistry) Info

func (r *FileRegistry) Info(ct *out.Container)

Info will show some detailed information about the registry

func (*FileRegistry) Initialize

func (r *FileRegistry) Initialize() error

Initialize will do nothing for a file registry

func (FileRegistry) Kits

func (r FileRegistry) Kits() ([]kit.Kit, error)

Kits will return all kits that the are stated in the registry.

func (*FileRegistry) Remove

func (r *FileRegistry) Remove() error

Remove will be called when the registry should be removed. It will actually do nothing as we do not touch the original file

func (FileRegistry) Tools

func (r FileRegistry) Tools() ([]tool.Tool, error)

Tools will return all tools that are stored in the json file that this registry points to

func (*FileRegistry) Update

func (r *FileRegistry) Update() error

Update will do nothing as the file is already on the disk, we just need to read it again

type GitFactory

type GitFactory struct{}

GitFactory is the factory for the GitRegistry

func (*GitFactory) Create

func (g *GitFactory) Create(d Data, args []string) (Registry, error)

Create will take data and return a GitRegistry from the given arguments

func (*GitFactory) Raw

func (g *GitFactory) Raw() Registry

Raw will return a raw GitRepository struct for populating from the db

type GitRegistry

type GitRegistry struct {
	Repository string `json:"repository"`
	Core       Data   `json:"core"`
}

GitRegistry is the base json structure for all git repositories

func (*GitRegistry) Data

func (r *GitRegistry) Data() *Data

Data return the data of the registry

func (*GitRegistry) Info

func (r *GitRegistry) Info(ct *out.Container)

Info will show some detailed information about the registry

func (*GitRegistry) Initialize

func (r *GitRegistry) Initialize() error

Initialize will do the initial clone for the repository and will verify that there is a index.json

func (*GitRegistry) Kits

func (r *GitRegistry) Kits() ([]kit.Kit, error)

Kits will return the tools currently in this registry

func (*GitRegistry) Remove

func (r *GitRegistry) Remove() error

Remove will be called when the registry should be removed. It will try to delete the path of the cloned registry

func (*GitRegistry) Tools

func (r *GitRegistry) Tools() ([]tool.Tool, error)

Tools will return the tools currently in this registry

func (*GitRegistry) Update

func (r *GitRegistry) Update() error

Update will do a git pull on the repository to update the internal state

type JSON

type JSON struct {
	Type     string          `json:"type"`
	Registry json.RawMessage `json:"registry"`
}

JSON is the base json structure that will be stored in the database. We need to append the type of the registry so that we can parse them back correctly from the database.

type Registries

type Registries struct {
	config.Database
}

Registries is the struct that can be used to access the registries registered with Sledgehammer

func New

func New(db config.Database) *Registries

New will create a new Registries struct to access the repositories registered with Sledgehammer

func (*Registries) Add

func (r *Registries) Add(registry Registry) error

Add adds the given registry to the registry files

func (*Registries) Exists

func (r *Registries) Exists(name string) (bool, error)

Exists will check if a given registry already exists

func (*Registries) Get

func (r *Registries) Get(name string) (Registry, error)

Get will return a single registry given by the name

func (*Registries) List

func (r *Registries) List() ([]Registry, error)

List will return all registries that are registered with Sledgehammer

func (*Registries) Remove

func (r *Registries) Remove(name string) error

Remove will remove the given registry and all containing tools from the database

type Registry

type Registry interface {
	Data() *Data
	// Update will be called when the registry should update their local files.
	Update() error
	// Initialize will be called when the registry should be initialized the first time.
	Initialize() error
	// Remove will be called when the registry should be removed. All cleanups should happen here.
	Remove() error
	Tools() ([]tool.Tool, error)
	Kits() ([]kit.Kit, error)
	// Info requires the registry to add their own information to the given container
	Info(ct *out.Container)
}

Registry is the base interface of a registry, can be extended

type URLFactory

type URLFactory struct{}

URLFactory is the factory for the URLRegistry

func (*URLFactory) Create

func (g *URLFactory) Create(d Data, args []string) (Registry, error)

Create will take data and return a URLRegistry from the given arguments

func (*URLFactory) Raw

func (g *URLFactory) Raw() Registry

Raw will return a raw GitRepository struct for populating from the db

type URLRegistry

type URLRegistry struct {
	URL  string `json:"url"`
	Core Data   `json:"core"`
}

URLRegistry is the JSON representation of the registry of this file

func (*URLRegistry) Data

func (r *URLRegistry) Data() *Data

Data return the data of the registry

func (*URLRegistry) Info

func (r *URLRegistry) Info(ct *out.Container)

Info will show some detailed information about the registry

func (*URLRegistry) Initialize

func (r *URLRegistry) Initialize() error

Initialize will download the registry from the URL and places it on the local file system

func (*URLRegistry) Kits

func (r *URLRegistry) Kits() ([]kit.Kit, error)

Kits will return the tools currently in this registry

func (*URLRegistry) Remove

func (r *URLRegistry) Remove() error

Remove will be called when the registry should be removed. It will do nothing as of now...

func (*URLRegistry) Tools

func (r *URLRegistry) Tools() ([]tool.Tool, error)

Tools will return the tools currently in this registry

func (*URLRegistry) Update

func (r *URLRegistry) Update() error

Update will do a git pull on the repository to update the internal state

Jump to

Keyboard shortcuts

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