config

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 9, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRepositories reflects an own error dedicated to the situation
	// that there are no repositories configured / defined.
	ErrNoRepositories = errors.New("No repositories defined/configured.")
)

Functions

func IsNoRepositories

func IsNoRepositories(err error) bool

IsNoRepositories returns a boolean indicating whether the error is known to report that there are no repositories.

Types

type JSONProvider

type JSONProvider struct {
	// contains filtered or unexported fields
}

JSONProvider provides the data structure for a configuration file that is defined in JSON

func NewJSONProvider

func NewJSONProvider(c []byte) (*JSONProvider, error)

NewJSONProvider will create a new provider to work with JSON content c in a convenient way

func (*JSONProvider) Get

func (p *JSONProvider) Get(key string) interface{}

Get returns key from the configuration and will not cast it

func (*JSONProvider) GetContentMap

func (p *JSONProvider) GetContentMap() map[string]interface{}

GetContentMap returns the complete content of the provider data source as a map

func (*JSONProvider) GetString

func (p *JSONProvider) GetString(key string) string

GetString returns key from the configuration as a casted String

func (*JSONProvider) GetStringSlice

func (p *JSONProvider) GetStringSlice(key string) []string

GetStringSlice returns the value associated with the key as a slice of strings.

type Medusa

type Medusa struct {
	// contains filtered or unexported fields
}

Medusa reflects the original Medusa configuration file.

func NewMedusa

func NewMedusa(c Provider) (*Medusa, error)

NewMedusa will create a new medusa configuration object. If no configuration is given, an error will be returned.

func (*Medusa) GetNamesOfRepositories

func (m *Medusa) GetNamesOfRepositories() ([]*dependency.Package, error)

GetNamesOfRepositories returns all Packages from the configuration key "repositories". A repository will only be returned when it is complete (means a name and an url exists)

func (*Medusa) GetRepositoryURLOfPackage

func (m *Medusa) GetRepositoryURLOfPackage(p *dependency.Package) (*url.URL, error)

GetRepositoryURLOfPackage will determine if package p is part of the configuration. If p is part and a url is configured and this url is valid, this url will be returned. Otherwise an error.

func (*Medusa) GetRequire

func (m *Medusa) GetRequire() []string

GetRequire returns all the configuration key "require"

func (*Medusa) GetString

func (m *Medusa) GetString(key string) string

GetString returns key from the Medusa configuration as a casted String

type Provider

type Provider interface {
	// Get returns key from the configuration and will not cast it
	Get(key string) interface{}
	// GetString returns key from the configuration as a casted String
	GetString(key string) string
	// GetStringSlice returns the value associated with the key as a slice of strings.
	GetStringSlice(key string) []string
	// GetContentMap returns the complete content of the provider data source as a map
	GetContentMap() map[string]interface{}
}

Provider represents a configuration provider. Valid provider that implement this interface

* ViperProvider (viper - https://github.com/spf13/viper) * JSONProvider

type Satis

type Satis struct {
	// contains filtered or unexported fields
}

Satis reflects the a Satis configuration file.

func NewSatis

func NewSatis(c Provider) (*Satis, error)

NewSatis will create a new satis configuration object. If no configuration is given, an error will be returned.

func (*Satis) AddRepositories

func (s *Satis) AddRepositories(u ...string)

AddRepositories will add a list of repositories u to the current satis configuration

func (*Satis) AddRepository

func (s *Satis) AddRepository(u string)

AddRepository will add repository u to the current satis configuration

func (*Satis) GetRepositoriesAsSlice

func (s *Satis) GetRepositoriesAsSlice() []SatisRepository

GetRepositoriesAsSlice returns all configured repositories from the configuration as a list.

func (*Satis) WriteFile

func (s *Satis) WriteFile(filename string, perm os.FileMode) error

WriteFile will write the satis configuration to file filename with permissions perm

type SatisRepository

type SatisRepository struct {
	// Type is the repository type, like `git` or `svn`
	Type string `json:"type"`
	// URL is the URL of the repository that contains packages
	URL string `json:"url"`
}

SatisRepository reflects a single repository entry in satis `repositories` section

type ViperProvider

type ViperProvider struct {
	// contains filtered or unexported fields
}

ViperProvider represents the structure to manage configurations based on github.com/spf13/viper

func NewViperProvider

func NewViperProvider(v *viper.Viper) (*ViperProvider, error)

NewViperProvider creates a new configuration provider based on github.com/spf13/viper

func (*ViperProvider) Get

func (p *ViperProvider) Get(key string) interface{}

Get returns key from the configuration and will not cast it

func (*ViperProvider) GetContentMap

func (p *ViperProvider) GetContentMap() map[string]interface{}

GetContentMap returns the complete content of the provider data source as a map

func (*ViperProvider) GetString

func (p *ViperProvider) GetString(key string) string

GetString returns key from the configuration as a casted String

func (*ViperProvider) GetStringSlice

func (p *ViperProvider) GetStringSlice(key string) []string

GetStringSlice returns the value associated with the key as a slice of strings.

Jump to

Keyboard shortcuts

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