Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSession ¶
CreateSession handles the POST method to create a new session.
func DeleteSession ¶
DeleteSession handles the DELETE method to remove an existing session.
func GetSession ¶
GetSession handles the GET method to fetch a session data.
func PullAvailableImages ¶
func RunCleaner ¶
func RunCleaner()
RunCleaner ticks for configured time steps for deleting older existing sessions.
Types ¶
type Container ¶
type Container struct { ID string `json:"id"` Distribution Distribution `json:"distribution"` Tag string `json:"tag"` URL string `json:"url"` CreatedAt time.Time `json:"created_at"` DeletedAt *time.Time `json:"deleted_at,omitempty"` }
func FetchSession ¶
FetchSession returns the session data for given session ID, or an error if it fails to fetch.
func NewSession ¶
func NewSession(od *OSDistribution) (*Container, *apierrors.APIError)
NewSession builds a new container instance and returns its data associated or an error if it fails.
func RemoveSession ¶
RemoveSession terminates and removes all data about given session ID. It returns its data at the delete moment or an error if the operation fails.
type DockerClient ¶
type DockerClient interface { Pull(distribution Distribution, tag string) *apierrors.APIError Create(distribution Distribution, tag string, cpus, memory int64, hostIP string, hostPort int) (*Container, *apierrors.APIError) Get(id string) (*Container, *apierrors.APIError) Destroy(id string) *apierrors.APIError List() ([]Container, *apierrors.APIError) Context() context.Context }
func NewDockerClient ¶
func NewDockerClient() DockerClient
type OSDistribution ¶
type OSDistribution struct { Distribution Distribution `json:"distribution"` Tag string `json:"tag"` }
OSDistribution responds to the required data needed to create a new session.
func (*OSDistribution) UnmarshalJSON ¶
func (od *OSDistribution) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom implementation for unmarshalling OSDistribution in order to check valid distribution name.