Documentation ¶
Index ¶
- Variables
- func IsNoResultsError(e error) bool
- type Bind
- type Build
- type BuildState
- type BuildTable
- type Community
- type CommunityTable
- type ConnectionID
- type ConnectionTable
- type ContainerID
- type Db
- func (d *Db) AddBuild(newBuild Build) error
- func (d *Db) AddCmd(service Service) error
- func (d *Db) AddCommunity(name, description string, addDefaultRoles bool) (Community, error)
- func (d *Db) AddConnection(userID int64, connection def.DockerConfig) (ConnectionID, error)
- func (d *Db) AddIOPort(service Service) error
- func (d *Db) AddJob(userID int64, job Job) error
- func (d *Db) AddJobTask(id JobID, taskName string, taskContainer string, taskSwarmService string, ...) error
- func (d *Db) AddJobVolume(id JobID, volume VolumeID, isInput bool, portName string, content string) error
- func (d *Db) AddRole(name string, communityID int64, description string) (Role, error)
- func (d *Db) AddRoleToUser(userID, roleID int64) error
- func (d *Db) AddService(userID int64, service Service) error
- func (d *Db) AddUser(user User) (User, error)
- func (d *Db) Close()
- func (d *Db) CountRunningJobs() int64
- func (d *Db) CountUserRunningJobs(userID int64) int64
- func (d *Db) DeleteRoleFromUser(userID, roleID int64) error
- func (d *Db) DeleteUserToken(userID, tokenID int64) error
- func (d *Db) GetBuild(id string) (Build, error)
- func (d *Db) GetCommunityByID(communityID int64) (Community, error)
- func (d *Db) GetCommunityByName(name string) (Community, error)
- func (d *Db) GetConnectionOwners(connectionID ConnectionID) ([]int64, error)
- func (d *Db) GetConnections() (map[ConnectionID]def.DockerConfig, error)
- func (d *Db) GetFirstConnectionID() (ConnectionID, error)
- func (d *Db) GetJob(id JobID) (Job, error)
- func (d *Db) GetJobOwningVolume(volumeID string) (Job, error)
- func (d *Db) GetRoleByName(name string, communityID int64) (Role, error)
- func (d *Db) GetRoleUsers(roleID int64) ([]User, error)
- func (d *Db) GetService(id ServiceID) (Service, error)
- func (d *Db) GetTokenByID(tokenID int64) (Token, error)
- func (d *Db) GetTokenBySecret(accessToken string) (Token, error)
- func (d *Db) GetUserByEmail(email string) (*User, error)
- func (d *Db) GetUserByID(id int64) (*User, error)
- func (d *Db) GetUserRoles(userID int64) ([]Role, error)
- func (d *Db) GetUserTokens(userID int64) ([]Token, error)
- func (d *Db) HasSuperAdminRole(userID int64) bool
- func (d *Db) IsConnectionOwner(userID int64, connectionID ConnectionID) bool
- func (d *Db) IsJobOwner(userID int64, jobID JobID) bool
- func (d *Db) IsServiceOwner(userID int64, serviceID ServiceID) bool
- func (d *Db) ListCommunities() ([]Community, error)
- func (d *Db) ListJobs() ([]Job, error)
- func (d *Db) ListRoles() ([]Role, error)
- func (d *Db) ListServices() ([]Service, error)
- func (d *Db) NewUserToken(userID int64, name string, expire time.Time) (Token, error)
- func (d *Db) RemoveBuild(id string) error
- func (d *Db) RemoveConnection(connectionID ConnectionID) error
- func (d *Db) RemoveJob(id JobID) error
- func (d *Db) RemoveJobTask(taskID string) error
- func (d *Db) RemoveService(id ServiceID) error
- func (d *Db) SetBuildServiceID(id string, serviceID ServiceID) error
- func (d *Db) SetBuildState(id string, state BuildState) error
- func (d *Db) SetJobDurationTime(id JobID, duration int64) error
- func (d *Db) SetJobState(id JobID, state JobState) error
- func (d *Db) UpdateUser(user User) error
- type IOPort
- type IOPortTable
- type ImageID
- type Job
- type JobID
- type JobState
- type JobTable
- type JobVolume
- type LatestOutput
- type OwnerTable
- type Role
- type RoleTable
- type Service
- type ServiceCmdTable
- type ServiceID
- type ServiceTable
- type Task
- type TaskTable
- type Token
- type TokenTable
- type User
- type UserRoleTable
- type UserTable
- type VolumeID
- type VolumeTable
Constants ¶
This section is empty.
Variables ¶
var ( SuperAdminRoleName = "SuperAdministrator" CommunityAdminRoleName = "Administrator" CommunityMemberRoleName = "Member" )
Functions ¶
Types ¶
type Build ¶
type Build struct { ID string ServiceID ServiceID ConnectionID ConnectionID Started time.Time Duration int64 State *BuildState }
Build describes status information about an image being built for a GEF service
type BuildState ¶
type BuildState struct { Status string Error string Code int // 0 - finished successfully, -1 - build in progress, 1 - there is an error }
BuildState keeps information about a build state
func NewBuildStateError ¶
func NewBuildStateError(err string, code int) BuildState
NewBuildStateError creates a new BuildState with specified error
func NewBuildStateOk ¶
func NewBuildStateOk(status string, code int) BuildState
NewBuildStateOk creates a new BuildState with no error
type BuildTable ¶
type BuildTable struct { ID string ServiceID string ConnectionID int Started time.Time Duration int64 // duration time in seconds Error string Status string Code int Revision int }
BuildTable stores the information about an image build process
type CommunityTable ¶
CommunityTable stores the communities in the db
type ConnectionID ¶
type ConnectionID int
ConnectionID is the type used to identify a docker connection
type ConnectionTable ¶
type ConnectionTable struct { ID int Endpoint string // unique key Description string TLSVerify bool CertPath string KeyPath string CAPath string Revision int }
ConnectionTable stores the information about a docker connection (used to store data in a database)
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
Db is used to keep DbMap
func InitDbForTesting ¶
InitDbForTesting must only be used for tests
func (*Db) AddCommunity ¶
AddCommunity adds a community to the database, with checks
func (*Db) AddConnection ¶
func (d *Db) AddConnection(userID int64, connection def.DockerConfig) (ConnectionID, error)
AddConnection adds a connection to the database
func (*Db) AddJobTask ¶
func (d *Db) AddJobTask(id JobID, taskName string, taskContainer string, taskSwarmService string, taskError string, taskExitCode int, taskConsoleOutput *bytes.Buffer) error
AddJobTask adds a task to a job
func (*Db) AddJobVolume ¶
func (d *Db) AddJobVolume(id JobID, volume VolumeID, isInput bool, portName string, content string) error
AddJobVolume sets a job input/output volume
func (*Db) AddRole ¶
AddRole adds a role to the database, but only if it's not already present For roles that have no associated community use communityID: 0
func (*Db) AddService ¶
AddService creates a new service in the database
func (*Db) CountRunningJobs ¶
CountRunningJobs returns a number of jobs currently running
func (*Db) CountUserRunningJobs ¶
CountUserRunningJobs returns a number of running jobs owned by a specific user
func (*Db) DeleteRoleFromUser ¶
DeleteRoleFromUser
func (*Db) DeleteUserToken ¶
DeleteUserToken deletes the token from the database
func (*Db) GetCommunityByID ¶
GetCommunityByID gets a community from the database
func (*Db) GetCommunityByName ¶
GetCommunityByName gets a community from the database
func (*Db) GetConnectionOwners ¶
func (d *Db) GetConnectionOwners(connectionID ConnectionID) ([]int64, error)
GetConnectionOwners does what it says
func (*Db) GetConnections ¶
func (d *Db) GetConnections() (map[ConnectionID]def.DockerConfig, error)
GetConnections returns a map of all connections ready to be converted into JSON
func (*Db) GetFirstConnectionID ¶
func (d *Db) GetFirstConnectionID() (ConnectionID, error)
GetFirstConnectionID returns the default (first) connection id
func (*Db) GetJobOwningVolume ¶
GetJobOwningVolume returns a service ready to be converted into JSON
func (*Db) GetRoleByName ¶
GetRoleByName gets a named role from the database
func (*Db) GetRoleUsers ¶
GetRoleByID gets a role from the database
func (*Db) GetService ¶
GetService returns a service ready to be converted into JSON
func (*Db) GetTokenByID ¶
GetTokenByID returns a token by its ID
func (*Db) GetTokenBySecret ¶
GetTokenBySecret returns a token by its Secret
func (*Db) GetUserByEmail ¶
GetUserByEmail searches for a user in the database
func (*Db) GetUserByID ¶
GetUserByID searches for a user in the database
func (*Db) GetUserTokens ¶
GetUserTokens returns the user's tokens
func (*Db) HasSuperAdminRole ¶
HasSuperAdminRole checks if a a user has super admin privileges
func (*Db) IsConnectionOwner ¶
func (d *Db) IsConnectionOwner(userID int64, connectionID ConnectionID) bool
IsConnectionOwner checks if a certain user owns a certain connection
func (*Db) IsJobOwner ¶
IsJobOwner checks if a certain user owns a certain job
func (*Db) IsServiceOwner ¶
IsServiceOwner checks if a certain user owns a certain service
func (*Db) ListCommunities ¶
ListCommunities gets the list of all the communities
func (*Db) ListServices ¶
ListServices produces a list of all services ready to be converted into JSON
func (*Db) NewUserToken ¶
NewUserToken creates a new user access token
func (*Db) RemoveBuild ¶
RemoveBuild removes a build from the database
func (*Db) RemoveConnection ¶
func (d *Db) RemoveConnection(connectionID ConnectionID) error
RemoveConnection removes a connection to the database
func (*Db) RemoveJobTask ¶
RemoveJobTask removes a task from the database
func (*Db) RemoveService ¶
RemoveService removes a service and the corresponding IOPorts from the database
func (*Db) SetBuildServiceID ¶
SetBuildServiceID sets a service ID for a given build
func (*Db) SetBuildState ¶
func (d *Db) SetBuildState(id string, state BuildState) error
SetBuildState sets a build state
func (*Db) SetJobDurationTime ¶
SetJobDurationTime sets job finish time
func (*Db) SetJobState ¶
SetJobState sets a job state
func (*Db) UpdateUser ¶
UpdateUser updates user information in the database
type IOPort ¶
IOPort is an i/o specification for a service The service can only read data from volumes and write to a single volume Path specifies where the volumes are mounted
type IOPortTable ¶
type IOPortTable struct { ID string Name string Path string IsInput bool ServiceID string Type string FileName string Revision int }
IOPortTable is used to store info about service inputs and outputs in a database
type Job ¶
type Job struct { ID JobID ConnectionID ConnectionID ServiceID ServiceID Created time.Time Duration int64 State *JobState InputVolume []JobVolume OutputVolume []JobVolume Tasks []Task }
Job stores the information about a service execution (used to serialize JSON)
type JobState ¶
JobState keeps information about a job state
func NewJobStateError ¶
NewJobStateError creates a new JobState with specified error
func NewJobStateOk ¶
NewJobStateOk creates a new JobState with no error
type JobTable ¶
type JobTable struct { ID string ConnectionID int ServiceID string Created time.Time Duration int64 // duration time in seconds Error string Status string Code int Revision int }
JobTable stores the information about a service execution (used to store data in a database)
type LatestOutput ¶
LatestOutput used to serialize console output to JSON
type OwnerTable ¶
OwnerTable stores object ownerships
type RoleTable ¶
type RoleTable struct { ID int64 Name string CommunityID int64 // most roles are per community Description string Revision int }
RoleTable stores user roles in the db
type Service ¶
type Service struct { ID ServiceID ConnectionID ConnectionID ImageID ImageID Name string RepoTag string Description string Version string Cmd []string Created time.Time Deleted bool Size int64 Input []IOPort Output []IOPort }
Service describes metadata for a GEF service (used to serialize JSON)
type ServiceCmdTable ¶
ServiceCmdTable stores CMD options for services
type ServiceTable ¶
type ServiceTable struct { ID string ConnectionID int ImageID string Name string RepoTag string Description string Version string Created time.Time Deleted bool Size int64 Revision int }
ServiceTable describes metadata for a GEF service (used to store data in a database)
type Task ¶
type Task struct { ID string Name string ContainerID ContainerID SwarmServiceID string Error string ExitCode int ConsoleOutput string }
Task contains tasks related to a specific job (used to serialize JSON)
type TaskTable ¶
type TaskTable struct { ID string Name string ContainerID string SwarmServiceID string Error string ExitCode int ConsoleOutput string JobID string Revision int }
TaskTable contains tasks related to a specific job (used to store data in a database)
type TokenTable ¶
type TokenTable struct { ID int64 Name string // token name, user defined Secret string // token secret, a random string UserID int64 Expire time.Time Revision int }
TokenTable stores user tokens in the db
type UserRoleTable ¶
UserRoleTable stores user mapping to roles in the db