dockm

package
v0.0.0-...-28b0f66 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2017 License: MIT, Zlib Imports: 1 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// APIVersion is the version number of the dockm API.
	APIVersion = "1.14.0"
	// DBVersion is the version number of the dockm database.
	DBVersion = 3
	// DefaultTemplatesURL represents the default URL for the templates definitions.
	DefaultTemplatesURL = "https://raw.githubusercontent.com/Click2Cloud/templates/master/templates.json"
)
View Source
const (
	ErrUnauthorized           = Error("Unauthorized")
	ErrResourceAccessDenied   = Error("Access denied to resource")
	ErrResourceNotFound       = Error("Unable to find resource")
	ErrUnsupportedDockerAPI   = Error("Unsupported Docker API response")
	ErrMissingSecurityContext = Error("Unable to find security details in request context")
)

General errors.

View Source
const (
	ErrUserNotFound            = Error("User not found")
	ErrUserAlreadyExists       = Error("User already exists")
	ErrInvalidUsername         = Error("Invalid username. White spaces are not allowed.")
	ErrAdminAlreadyInitialized = Error("Admin user already initialized")
)

User errors.

View Source
const (
	ErrTeamNotFound      = Error("Team not found")
	ErrTeamAlreadyExists = Error("Team already exists")
)

Team errors.

View Source
const (
	ErrTeamMembershipNotFound      = Error("Team membership not found")
	ErrTeamMembershipAlreadyExists = Error("Team membership already exists for this user and team.")
)

TeamMembership errors.

View Source
const (
	ErrResourceControlNotFound      = Error("Resource control not found")
	ErrResourceControlAlreadyExists = Error("A resource control is already applied on this resource")
	ErrInvalidResourceControlType   = Error("Unsupported resource control type")
)

ResourceControl errors.

View Source
const (
	ErrEndpointNotFound     = Error("Endpoint not found")
	ErrEndpointAccessDenied = Error("Access denied to endpoint")
)

Endpoint errors.

View Source
const (
	ErrRegistryNotFound      = Error("Registry not found")
	ErrRegistryAlreadyExists = Error("A registry is already defined for this URL")
)

Registry errors.

View Source
const (
	ErrSecretGeneration   = Error("Unable to generate secret key")
	ErrInvalidJWTToken    = Error("Invalid JWT token")
	ErrMissingContextData = Error("Unable to find JWT data in request context")
)

JWT errors.

View Source
const (
	ErrCryptoHashFailure = Error("Unable to hash data")
)

Crypto errors.

View Source
const (
	ErrDBVersionNotFound = Error("DB version not found")
)

Version errors.

View Source
const (
	ErrDockerHubNotFound = Error("Dockerhub not found")
)

DockerHub errors.

View Source
const (
	ErrSettingsNotFound = Error("Settings not found")
)

Settings errors.

View Source
const (
	ErrStackNotFound = Error("Stack not found")
)

Stack errors

View Source
const (
	ErrUndefinedTLSFileTyp = Error("Undefined TLS file type")
)

ApptoContainer errors

View Source
const (
	ErrUndefinedTLSFileType = Error("Undefined TLS file type")
)

File errors.

Variables

This section is empty.

Functions

This section is empty.

Types

type AToC

type AToC struct {
	BaseImage  string `json:"BaseImage"`
	GitUrl     string `json:"GitUrl"`
	ImageName  string `json:"ImageName"`
	EndPointId int    `json:"EndPointId"`
}

type AppToContainerService

type AppToContainerService interface {
	BuildAppToContainer(atoc *AToC, endpoint *Endpoint) (error, string)
}

EndpointService represents a service for managing endpoint data.

type AuthenticationMethod

type AuthenticationMethod int

AuthenticationMethod represents the authentication method used to authenticate a user.

const (

	// AuthenticationInternal represents the internal authentication method (authentication against dockm API)
	AuthenticationInternal AuthenticationMethod
	// AuthenticationLDAP represents the LDAP authentication method (authentication against a LDAP server)
	AuthenticationLDAP
)

type CLIFlags

type CLIFlags struct {
	Addr              *string
	Assets            *string
	Data              *string
	ExternalEndpoints *string
	SyncInterval      *string
	Endpoint          *string
	NoAuth            *bool
	NoAnalytics       *bool
	TLSVerify         *bool
	TLSCacert         *string
	TLSCert           *string
	TLSKey            *string
	SSL               *bool
	SSLCert           *string
	SSLKey            *string
	AdminPassword     *string
	// Deprecated fields
	Templates *string
	Labels    *[]Pair
}

CLIFlags represents the available flags on the CLI.

type CLIService

type CLIService interface {
	ParseFlags(version string) (*CLIFlags, error)
	ValidateFlags(flags *CLIFlags) error
}

CLIService represents a service for managing CLI.

type CryptoService

type CryptoService interface {
	Hash(data string) (string, error)
	CompareHashAndData(hash string, data string) error
}

CryptoService represents a service for encrypting/hashing data.

type DataStore

type DataStore interface {
	Open() error
	Close() error
	MigrateData() error
}

DataStore defines the interface to manage the data.

type DockerHub

type DockerHub struct {
	Authentication bool   `json:"Authentication"`
	Username       string `json:"Username"`
	Password       string `json:"Password"`
}

DockerHub represents all the required information to connect and use the Docker Hub.

type DockerHubService

type DockerHubService interface {
	DockerHub() (*DockerHub, error)
	StoreDockerHub(registry *DockerHub) error
}

DockerHubService represents a service for managing the DockerHub object.

type Endpoint

type Endpoint struct {
	ID              EndpointID `json:"Id"`
	Name            string     `json:"Name"`
	URL             string     `json:"URL"`
	PublicURL       string     `json:"PublicURL"`
	TLS             bool       `json:"TLS"`
	TLSCACertPath   string     `json:"TLSCACert,omitempty"`
	TLSCertPath     string     `json:"TLSCert,omitempty"`
	TLSKeyPath      string     `json:"TLSKey,omitempty"`
	AuthorizedUsers []UserID   `json:"AuthorizedUsers"`
	AuthorizedTeams []TeamID   `json:"AuthorizedTeams"`
}

Endpoint represents a Docker endpoint with all the info required to connect to it.

type EndpointID

type EndpointID int

EndpointID represents an endpoint identifier.

type EndpointService

type EndpointService interface {
	Endpoint(ID EndpointID) (*Endpoint, error)
	Endpoints() ([]Endpoint, error)
	CreateEndpoint(endpoint *Endpoint) error
	UpdateEndpoint(ID EndpointID, endpoint *Endpoint) error
	DeleteEndpoint(ID EndpointID) error
	Synchronize(toCreate, toUpdate, toDelete []*Endpoint) error
}

EndpointService represents a service for managing endpoint data.

type EndpointWatcher

type EndpointWatcher interface {
	WatchEndpointFile(endpointFilePath string) error
}

EndpointWatcher represents a service to synchronize the endpoints via an external source.

type Error

type Error string

Error represents an application error.

func (Error) Error

func (e Error) Error() string

Error returns the error message.

type FileService

type FileService interface {
	StoreTLSFile(folder string, fileType TLSFileType, r io.Reader) error
	GetPathForTLSFile(folder string, fileType TLSFileType) (string, error)
	DeleteTLSFiles(folder string) error
	StoreComposeFile(name, composeFileContent string) (string, error)
	StoreComposeEnvFile(name, envFileContent string) error
	DeleteStackFiles(projectPath string) error
}

FileService represents a service for managing files.

type JWTService

type JWTService interface {
	GenerateToken(data *TokenData) (string, error)
	ParseAndVerifyToken(token string) (*TokenData, error)
}

JWTService represents a service for managing JWT tokens.

type LDAPSearchSettings

type LDAPSearchSettings struct {
	BaseDN            string `json:"BaseDN"`
	Filter            string `json:"Filter"`
	UserNameAttribute string `json:"UserNameAttribute"`
}

LDAPSearchSettings represents settings used to search for users in a LDAP server.

type LDAPService

type LDAPService interface {
	AuthenticateUser(username, password string, settings *LDAPSettings) error
	TestConnectivity(settings *LDAPSettings) error
}

LDAPService represents a service used to authenticate users against a LDAP/AD.

type LDAPSettings

type LDAPSettings struct {
	ReaderDN       string               `json:"ReaderDN"`
	Password       string               `json:"Password"`
	URL            string               `json:"URL"`
	TLSConfig      TLSConfiguration     `json:"TLSConfig"`
	StartTLS       bool                 `json:"StartTLS"`
	SearchSettings []LDAPSearchSettings `json:"SearchSettings"`
}

LDAPSettings represents the settings used to connect to a LDAP server.

type MembershipRole

type MembershipRole int

MembershipRole represents the role of a user within a team

const (

	// TeamLeader represents a leader role inside a team
	TeamLeader MembershipRole
	// TeamMember represents a member role inside a team
	TeamMember
)

type Pair

type Pair struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Pair defines a key/value string pair

type Registry

type Registry struct {
	ID              RegistryID `json:"Id"`
	Name            string     `json:"Name"`
	URL             string     `json:"URL"`
	Authentication  bool       `json:"Authentication"`
	Username        string     `json:"Username"`
	Password        string     `json:"Password"`
	AuthorizedUsers []UserID   `json:"AuthorizedUsers"`
	AuthorizedTeams []TeamID   `json:"AuthorizedTeams"`
}

Registry represents a Docker registry with all the info required to connect to it.

type RegistryID

type RegistryID int

RegistryID represents a registry identifier.

type RegistryService

type RegistryService interface {
	Registry(ID RegistryID) (*Registry, error)
	Registries() ([]Registry, error)
	CreateRegistry(registry *Registry) error
	UpdateRegistry(ID RegistryID, registry *Registry) error
	DeleteRegistry(ID RegistryID) error
}

RegistryService represents a service for managing registry data.

type ResourceAccessLevel

type ResourceAccessLevel int

ResourceAccessLevel represents the level of control associated to a resource.

const (

	// ReadWriteAccessLevel represents an access level with read-write permissions on a resource
	ReadWriteAccessLevel ResourceAccessLevel
)

type ResourceControl

type ResourceControl struct {
	ID                 ResourceControlID   `json:"Id"`
	ResourceID         string              `json:"ResourceId"`
	SubResourceIDs     []string            `json:"SubResourceIds"`
	Type               ResourceControlType `json:"Type"`
	AdministratorsOnly bool                `json:"AdministratorsOnly"`

	UserAccesses []UserResourceAccess `json:"UserAccesses"`
	TeamAccesses []TeamResourceAccess `json:"TeamAccesses"`

	// Deprecated fields
	// Deprecated: OwnerID field is deprecated in DBVersion == 2
	OwnerID UserID `json:"OwnerId"`
	// Deprecated: AccessLevel field is deprecated in DBVersion == 2
	AccessLevel ResourceAccessLevel `json:"AccessLevel"`
}

ResourceControl represent a reference to a Docker resource with specific access controls

type ResourceControlID

type ResourceControlID int

ResourceControlID represents a resource control identifier.

type ResourceControlService

type ResourceControlService interface {
	ResourceControl(ID ResourceControlID) (*ResourceControl, error)
	ResourceControlByResourceID(resourceID string) (*ResourceControl, error)
	ResourceControls() ([]ResourceControl, error)
	CreateResourceControl(rc *ResourceControl) error
	UpdateResourceControl(ID ResourceControlID, resourceControl *ResourceControl) error
	DeleteResourceControl(ID ResourceControlID) error
}

ResourceControlService represents a service for managing resource control data.

type ResourceControlType

type ResourceControlType int

ResourceControlType represents the type of resource associated to the resource control (volume, container, service).

const (

	// ContainerResourceControl represents a resource control associated to a Docker container
	ContainerResourceControl ResourceControlType
	// ServiceResourceControl represents a resource control associated to a Docker service
	ServiceResourceControl
	// VolumeResourceControl represents a resource control associated to a Docker volume
	VolumeResourceControl
)

type Server

type Server interface {
	Start() error
}

Server defines the interface to serve the API.

type Settings

type Settings struct {
	TemplatesURL                string               `json:"TemplatesURL"`
	LogoURL                     string               `json:"LogoURL"`
	BlackListedLabels           []Pair               `json:"BlackListedLabels"`
	DisplayExternalContributors bool                 `json:"DisplayExternalContributors"`
	AuthenticationMethod        AuthenticationMethod `json:"AuthenticationMethod"`
	LDAPSettings                LDAPSettings         `json:"LDAPSettings"`
}

Settings represents the application settings.

type SettingsService

type SettingsService interface {
	Settings() (*Settings, error)
	StoreSettings(settings *Settings) error
}

SettingsService represents a service for managing application settings.

type Stack

type Stack struct {
	ID          StackID `json:"Id"`
	Name        string  `json:"Name"`
	EndpointID  EndpointID
	ProjectPath string
}

Stack represents a Docker stack created via docker-compose.

type StackID

type StackID int

StackID represents a stack identifier.

type StackManager

type StackManager interface {
	Up(stack *Stack, endpoint *Endpoint) error
	Down(stack *Stack, endpoint *Endpoint) error
	Scale(stack *Stack, endpoint *Endpoint, service string, scale int) error
}

StackManager represents a service to manage stacks.

type StackService

type StackService interface {
	Stack(ID StackID) (*Stack, error)
	Stacks() ([]Stack, error)
	StacksByEndpointID(ID EndpointID) ([]Stack, error)
	CreateStack(stack *Stack) error
	UpdateStack(ID StackID, stack *Stack) error
	DeleteStack(ID StackID) error
}

StackService represents a service for managing stack data.

type Status

type Status struct {
	Authentication     bool   `json:"Authentication"`
	EndpointManagement bool   `json:"EndpointManagement"`
	Analytics          bool   `json:"Analytics"`
	Version            string `json:"Version"`
}

Status represents the application status.

type TLSConfiguration

type TLSConfiguration struct {
	TLS           bool   `json:"TLS"`
	TLSSkipVerify bool   `json:"TLSSkipVerify"`
	TLSCACertPath string `json:"TLSCACert,omitempty"`
	TLSCertPath   string `json:"TLSCert,omitempty"`
	TLSKeyPath    string `json:"TLSKey,omitempty"`
}

TLSConfiguration represents a TLS configuration.

type TLSFileType

type TLSFileType int

TLSFileType represents a type of TLS file required to connect to a Docker endpoint. It can be either a TLS CA file, a TLS certificate file or a TLS key file.

const (
	// TLSFileCA represents a TLS CA certificate file.
	TLSFileCA TLSFileType = iota
	// TLSFileCert represents a TLS certificate file.
	TLSFileCert
	// TLSFileKey represents a TLS key file.
	TLSFileKey
)

type Team

type Team struct {
	ID   TeamID `json:"Id"`
	Name string `json:"Name"`
}

Team represents a list of user accounts.

type TeamID

type TeamID int

TeamID represents a team identifier

type TeamMembership

type TeamMembership struct {
	ID     TeamMembershipID `json:"Id"`
	UserID UserID           `json:"UserID"`
	TeamID TeamID           `json:"TeamID"`
	Role   MembershipRole   `json:"Role"`
}

TeamMembership represents a membership association between a user and a team

type TeamMembershipID

type TeamMembershipID int

TeamMembershipID represents a team membership identifier

type TeamMembershipService

type TeamMembershipService interface {
	TeamMembership(ID TeamMembershipID) (*TeamMembership, error)
	TeamMemberships() ([]TeamMembership, error)
	TeamMembershipsByUserID(userID UserID) ([]TeamMembership, error)
	TeamMembershipsByTeamID(teamID TeamID) ([]TeamMembership, error)
	CreateTeamMembership(membership *TeamMembership) error
	UpdateTeamMembership(ID TeamMembershipID, membership *TeamMembership) error
	DeleteTeamMembership(ID TeamMembershipID) error
	DeleteTeamMembershipByUserID(userID UserID) error
	DeleteTeamMembershipByTeamID(teamID TeamID) error
}

TeamMembershipService represents a service for managing team membership data.

type TeamResourceAccess

type TeamResourceAccess struct {
	TeamID      TeamID              `json:"TeamId"`
	AccessLevel ResourceAccessLevel `json:"AccessLevel"`
}

TeamResourceAccess represents the level of control on a resource for a specific team.

type TeamService

type TeamService interface {
	Team(ID TeamID) (*Team, error)
	TeamByName(name string) (*Team, error)
	Teams() ([]Team, error)
	CreateTeam(team *Team) error
	UpdateTeam(ID TeamID, team *Team) error
	DeleteTeam(ID TeamID) error
}

TeamService represents a service for managing user data.

type TokenData

type TokenData struct {
	ID       UserID
	Username string
	Role     UserRole
}

TokenData represents the data embedded in a JWT token.

type User

type User struct {
	ID       UserID   `json:"Id"`
	Username string   `json:"Username"`
	Password string   `json:"Password,omitempty"`
	Role     UserRole `json:"Role"`
}

User represents a user account.

type UserID

type UserID int

UserID represents a user identifier

type UserResourceAccess

type UserResourceAccess struct {
	UserID      UserID              `json:"UserId"`
	AccessLevel ResourceAccessLevel `json:"AccessLevel"`
}

UserResourceAccess represents the level of control on a resource for a specific user.

type UserRole

type UserRole int

UserRole represents the role of a user. It can be either an administrator or a regular user

const (

	// AdministratorRole represents an administrator user role
	AdministratorRole UserRole
	// StandardUserRole represents a regular user role
	StandardUserRole
)

type UserService

type UserService interface {
	User(ID UserID) (*User, error)
	UserByUsername(username string) (*User, error)
	Users() ([]User, error)
	UsersByRole(role UserRole) ([]User, error)
	CreateUser(user *User) error
	UpdateUser(ID UserID, user *User) error
	DeleteUser(ID UserID) error
}

UserService represents a service for managing user data.

type VersionService

type VersionService interface {
	DBVersion() (int, error)
	StoreDBVersion(version int) error
}

VersionService represents a service for managing version data.

Directories

Path Synopsis
cmd
dockm command

Jump to

Keyboard shortcuts

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