Documentation
¶
Overview ¶
* Copyright 2017 Manuel Gauto (github.com/twa16) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Constants
- Variables
- func AddPublicKeysToSpace(db *gorm.DB, space Space) (error, int)
- func CreateSelfSignedCertificate(host string) (*rsa.PrivateKey, []byte, error)
- func Init()
- func RemoveSpace(db *gorm.DB, space Space) error
- func WriteCertificateToFile(certificate []byte, filePath string) error
- func WritePrivateKeyToFile(key *rsa.PrivateKey, filePath string) error
- type DockerInstance
- type OrchestratorInfo
- type ProxyInstance
- type Space
- type SpaceImage
- type SpacePortLink
- type SpaceUsageReport
- type UserPublicKey
Constants ¶
const ( ADMIN_ADD_HOST = "admin.host.add" ADMIN_READ_HOST = "admin.host.read" ADMIN_UPDATE_HOST = "admin.host.update" ADMIN_DELETE_HOST = "admin.host.delete" ADMIN_DELETE_SPACE = "admin.space.delete" USER_SPACE_CREATE = "user.space.create" )
Variables ¶
var DockerInstances []*DockerInstance
Contains running instances of docker hosts
var VERSION = "0.2A"
This should only be 4 chars or you have to change our fancy banner
Functions ¶
func CreateSelfSignedCertificate ¶
func CreateSelfSignedCertificate(host string) (*rsa.PrivateKey, []byte, error)
CreateSelfSignedCertificate Creates a self-signed certificate for a hostname
func Init ¶
func Init()
All code that would normally be in main() is put here in case we want to separate this into another package so it can be used as a library
func RemoveSpace ¶
RemoveSpace Removes a Space's container and DB entry
func WriteCertificateToFile ¶
WriteCertificateToFile Writes a certificate to a file
func WritePrivateKeyToFile ¶
func WritePrivateKeyToFile(key *rsa.PrivateKey, filePath string) error
WritePrivateKeyToFile Writes a private key to a file
Types ¶
type DockerInstance ¶
type DockerInstance struct {
ID uint `gorm:"primary_key" json:"-"` //Primary Key
CreatedAt time.Time `json:"-"` //Creation Time
UpdatedAt time.Time `json:"-"` //Last Update time
Name string `json:"name"` //Friendly name of this docker instance
ConnectionType string `json:"connection_type"` //Type of connection to use when connecting a docker instance (local,tls)
Endpoint string `json:"sock_path"` //Path to the sock if the connection type is local or remote address if the type is tls
CaCertPath string `json:"ca_cert_path"` //Path to the CA certificate if the connection type is tls
ClientCertPath string `json:"client_cert_path"` //Path to the Client certificate if the connection type is tls
ClientKeyPath string `json:"client_key_path"` //Path to the Client key if the connection type is tls
IsConnected bool `json:"is_connected"` //This is true if the daemon is reporting it is connected to the Docker host
DockerClient *docker.Client `gorm:"-" json:"-"` //Connection to the Docker instance
ExternalAddress string `json:"external_address"` //External address that the spaces will use
ExternalDisplayAddress string `json:"external_display_address"` //External addresses that users will see
}
DockerInstance Struct representing a docker instance to use for containers
type OrchestratorInfo ¶
type OrchestratorInfo struct {
SupportsCAS bool `json:"supports_cas"` //True if the daemon supports CAS authentication
CASURL string `json:"cas_url"` //Hostname that is used to connect to the CAS server
AllowsLocalLogin bool `json:"supports_local_login"` //True is the daemon supports local users
AllowsRegistration bool `json:"allows_registration"` //True if the daemon allows registration for local users
}
OrchestratorInfo This struct has the data that is sent to clients when they connect
type ProxyInstance ¶
type ProxyInstance struct {
ID uint `gorm:"primary_key" json:"-"` // Primary Key and ID of container
PublicID string `gorm:"index" json:"space_id"` // Public UUID of this Space
CreatedAt time.Time `json:"-"` // Creation time
ListenAddress string `unique_index:idx_lstnaddress"` // Address that the proxy will listen on
ListenPort int `unique_index:idx_lstnaddress"` // Port that the proxy will listen on
ConnectAddress string // Address that the proxy will connect to
ConnectPort int // Port that the proxy will connect to
SpaceID string
}
type Space ¶
type Space struct {
ID uint `gorm:"primary_key"` // Primary Key and ID of container
CreatedAt time.Time `json:"-"` // Creation time
ArchiveDate time.Time `json:"archive_date,omitempty"` // This is the timestamp of when the space was archived. This is set if the space was archived.
Archived bool `json:"archived,omitempty"` // This value is true if the space was deleted as a result of inactivity. All data is lost but metadata is preserved.
ImageID uint `json:"image_id,omitempty"` // This is the image that is used by the container that contains the space. This is a link to SpaceImage.
LastNetAccess string `json:"last_net_access,omitempty"` // The time this space was last accessed over the network but not SSH. This may be empty if the space was never accessed.
LastSSHAccess time.Time `json:"last_ssh_access,omitempty"` // The time this space was last accessed over SSH. This may be empty if the space was never accessed.
OwnerID uint `json:"owner_id,omitempty"` // Unique ID of the user that owns the Space. This is a link to User.
HostID uint `json:"host_id,omitempty"` // ID of the host that contains this space
FriendlyName string `json:"space_name,omitempty"` // Friendly name of this space
ContainerID string `json:"space_id,omitempty"` // ID of Docker container running this space
SpaceState string `json:"space_state,omitempty"` // Running State of Space (running, paused, archived, error)
SSHKeyID uint `json:"ssh_key_id,omitempty"` // ID of the SSH Key that this container is using
PortLinks []SpacePortLink `json:"port_links,omitempty"` // Shows what external ports are bound to the ports on the space
KeepAlive bool `json:"keep_alive,omitempty"` // If true, this container will be started if found to be 'exited'
}
Space Struct that represents the space
func GetSpaceArrayAssociation ¶
GetSpaceArrayAssociation Retrieves associated records for an array of Spaces. Internally, this calls GetSpaceAssociation
type SpaceImage ¶
type SpaceImage struct {
ID uint `gorm:"primary_key" json:"image_id"` //Primary Key
CreatedAt time.Time `json:"-"` //Creation time
Active bool `json:"active"` // If this is set to false, the user cannot use the image and is only kept to avoid breaking older spaces.
Description string `json:"description"` // Friendly description of this image.
DockerImage string `json:"docker_image"` // This is the full URI of the docker image.
DockerImageTag string `json:"docker_image_tag"` // Tag to use when retrieving the image
Name string `json:"name"` // Friendly name of this image.
}
SpaceImage Image that is used to create the underlying container for a space
type SpacePortLink ¶
type SpacePortLink struct {
ID uint `gorm:"primary_key" json:"-"` // Primary Key and ID of container
CreatedAt time.Time `json:"-"` //Timestamp of creation
SpacePort uint16 `json:"space_port"` //Port on the Space
ExternalPort uint16 `json:"external_port"` //Port that is exposed on the host
ExternalAddress string `json:"external_address"` //External address that clients would connect to the reach the space
DisplayAddress string `json:"external_display_address"` //Address that is displayed to clients as the external address
SpaceID uint `json:"-"` // ID of the space that this record is associated with
}
SpacePortLink A link between container port and host port
type SpaceUsageReport ¶
type SpaceUsageReport struct {
ID uint `gorm:"primary_key" json:"-"` //Primary Key
CreatedAt time.Time `json:"-"` //Creation time
ContainerID string `json:"container_id"` // ID of the container
DiskUsageBytes int64 `json:"disk_usage_bytes"` // Number of bytes that the space is taking up on disk.
NetworkInBytes int64 `json:"network_in_bytes"` // Number of bytes that the space has received over the network. This does include SSH.
NetworkOutBytes int64 `json:"network_out_bytes"` // Number of bytes that the space has sent over the network. This includes SSH.
ReportID int64 `json:"report_id"` // ID of the report
SSHSessionCount int64 `json:"ssh_session_count"` // This is the number of SSH sessions the space has received.
Timestamp time.Time `json:"timestamp"` // Time this data was recorded
}
SpaceUsageReport This object stores the metrics for a space at a specific point in time. The reports are not reset each time therefore the difference between two reports will show the increase in the time between the reports.
type UserPublicKey ¶
type UserPublicKey struct {
ID uint `gorm:"primary_key" json:"-"` // Primary Key
PublicID string `gorm:"index" json:"space_id"` // Public UUID of this Key
CreatedAt time.Time `json:"-"` // Creation time
OwnerID uint `json:"user_id"` // ID of user tha owns this key
Name string `json:"name"` // Friendly name of this key
PublicKey string `json:"public_key"` // Public key
}
UserPublicKey Represents a stored user public ssh key