server

package
v0.0.0-...-487a084 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package server contains a full server for Pop to control and manage a Docker daemon. See cmd/docker-popd in the root of the project for a daemon executable.

Index

Constants

View Source
const (
	// TokenBytes specifies how long a token is.
	TokenBytes = 32
)

Variables

View Source
var (
	DefaultConfig = Config{
		PopName:       "docker-popd",
		Proto:         pop.DefaultListenProtocol,
		Netaddr:       pop.DefaultListenAddress,
		Users:         Users{},
		DockerdHost:   client.DefaultDockerHost,
		LogLevel:      log.DebugLevel,
		LogTimestamps: false,
		AutoRemove:    true,
	}

	ErrMalformedAuthVar = errors.New("invalid POPD_AUTH variable (must be formatted like `user:pass,user2,pass2,[...]`)")
)

DefaultConfig is a sane template config for a local server.

View Source
var (
	ErrAddrTaken        = grpc.Errorf(codes.AlreadyExists, "ip is not available")
	ErrIPExhausted      = grpc.Errorf(codes.ResourceExhausted, "no more IP available for this network")
	ErrSubnetsExhausted = grpc.Errorf(codes.ResourceExhausted, "no more subnets available for this host")
)
View Source
var (
	ErrAlreadyStarted  = grpc.Errorf(codes.AlreadyExists, "container already started")
	ErrAlreadyStopped  = grpc.Errorf(codes.Unavailable, "container already stopped")
	ErrInvalidArgument = grpc.Errorf(codes.InvalidArgument, "invalid argument provided")
	ErrInvalidState    = grpc.Errorf(codes.FailedPrecondition, "container is in an invalid state")
	ErrNoSuchContainer = grpc.Errorf(codes.NotFound, "no container for the given filter")
	ErrNoSuchFlavour   = grpc.Errorf(codes.NotFound, "no flavour for the given filter")
	ErrNoSuchNetwork   = grpc.Errorf(codes.NotFound, "no network for the given filter")
	ErrNotStarted      = grpc.Errorf(codes.Unavailable, "container not started yet")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	PopName       string
	Proto         string
	Netaddr       string
	Users         Users
	DockerdHost   string
	LogLevel      log.Level
	LogTimestamps bool
	AutoRemove    bool

	TLSCertPath string
	TLSKeyPath  string
}

Config for the PoP service.

func LoadConfig

func LoadConfig() (cfg Config, err error)

LoadConfig either reads a config file through viper, or it initialialises a new config bases on the DefaultConfig template, using the POPD_AUTH config variable to fill the authentication data. If neither of these options suits you, just fill a Config structure by yourself and create a Server instance using it.

func (Config) Store

func (cfg Config) Store(w io.Writer) error

Store stores a config into a Writer.

func (Config) StoreFile

func (cfg Config) StoreFile(fileName string, overwrite bool) error

StoreFile stores a config into a file. It won't replace an existing file if overwrite is false.

type Server

type Server struct {
	*log.Logger
	Config     Config
	GRPCServer *grpc.Server
	// contains filtered or unexported fields
}

Server represents the PoP service.

func New

func New() (*Server, error)

New initialises a new Server from viper.

func (*Server) Close

func (s *Server) Close() error

Close shuts down the Server.

func (*Server) Serve

func (s *Server) Serve() error

Serve spawns the service.

type User

type User struct {
	Name           string
	HashedPassword []byte
}

User represents an user. Each user is identified by an username and a bcrypt hashed password.

func NewUser

func NewUser(name, pass string) (User, error)

NewUser creates a new User with the given username and an hashed password.

type Users

type Users map[string]User

Users represents a collection of users.

Jump to

Keyboard shortcuts

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