Documentation
¶
Index ¶
- Constants
- type AToC
- type AppToContainerService
- type AuthenticationMethod
- type CLIFlags
- type CLIService
- type CryptoService
- type DataStore
- type DockerHub
- type DockerHubService
- type Endpoint
- type EndpointID
- type EndpointService
- type EndpointWatcher
- type Error
- type FileService
- type JWTService
- type LDAPSearchSettings
- type LDAPService
- type LDAPSettings
- type MembershipRole
- type Pair
- type Registry
- type RegistryID
- type RegistryService
- type ResourceAccessLevel
- type ResourceControl
- type ResourceControlID
- type ResourceControlService
- type ResourceControlType
- type Server
- type Settings
- type SettingsService
- type Stack
- type StackID
- type StackManager
- type StackService
- type Status
- type TLSConfiguration
- type TLSFileType
- type Team
- type TeamID
- type TeamMembership
- type TeamMembershipID
- type TeamMembershipService
- type TeamResourceAccess
- type TeamService
- type TokenData
- type User
- type UserID
- type UserResourceAccess
- type UserRole
- type UserService
- type VersionService
Constants ¶
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" )
const ( 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.
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.
const ( ErrTeamNotFound = Error("Team not found") ErrTeamAlreadyExists = Error("Team already exists") )
Team errors.
const ( ErrTeamMembershipNotFound = Error("Team membership not found") ErrTeamMembershipAlreadyExists = Error("Team membership already exists for this user and team.") )
TeamMembership errors.
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.
const ( ErrEndpointNotFound = Error("Endpoint not found") ErrEndpointAccessDenied = Error("Access denied to endpoint") )
Endpoint errors.
const ( ErrRegistryNotFound = Error("Registry not found") ErrRegistryAlreadyExists = Error("A registry is already defined for this URL") )
Registry errors.
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.
const (
ErrCryptoHashFailure = Error("Unable to hash data")
)
Crypto errors.
const (
ErrDBVersionNotFound = Error("DB version not found")
)
Version errors.
const (
ErrDockerHubNotFound = Error("Dockerhub not found")
)
DockerHub errors.
const (
ErrSettingsNotFound = Error("Settings not found")
)
Settings errors.
const (
ErrStackNotFound = Error("Stack not found")
)
Stack errors
const (
ErrUndefinedTLSFileTyp = Error("Undefined TLS file type")
)
ApptoContainer errors
const (
ErrUndefinedTLSFileType = Error("Undefined TLS file type")
)
File errors.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
Logo *string
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 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 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 ¶
EndpointWatcher represents a service to synchronize the endpoints via an external source.
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 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 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 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 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 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 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.