types

package
v0.0.0-...-52087c1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KISARA_VM_NET_TYPE_HOST = "host"
	KISARA_VM_NET_TYPE_NAT  = "nat"
)
View Source
const (
	KISARA_VM_LIMIT_BYTES = 1
	KISARA_VM_LIMIT_KB    = 1024 * KISARA_VM_LIMIT_BYTES
	KISARA_VM_LIMIT_MB    = 1024 * KISARA_VM_LIMIT_KB
	KISARA_VM_LIMIT_GB    = 1024 * KISARA_VM_LIMIT_MB
	KISARA_VM_LIMIT_TB    = 1024 * KISARA_VM_LIMIT_GB
)
View Source
const (
	KISARA_VM_ARCH_X86_64   = "x86_64"
	KISARA_VM_ARCH_X86      = "x86"
	KISARA_VM_ARCH_ARM      = "arm"
	KISARA_VM_ARCH_ARM64    = "arm64"
	KISARA_VM_ARCH_MIPS     = "mips"
	KISARA_VM_ARCH_MIPS64   = "mips64"
	KISARA_VM_ARCH_MIPS64LE = "mips64le"
	KISARA_VM_ARCH_MIPSLE   = "mipsle"

	// based on docker
	KISARA_VM_TYPE_QEMU = "qemu"
	KISARA_VM_TYPE_KVM  = "kvm"
	KISARA_VM_TYPE_LXC  = "lxc"
	KISARA_VM_TYPE_LXD  = "lxd"
)
View Source
const (
	KISARA_VM_STATUS_RUNNING = "running"
	KISARA_VM_STATUS_STOPPED = "stopped"
)
View Source
const (
	SERVICE_STATUS_RUNNING = "running"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// ClientIp
	ClientIp string `json:"client_ip"`
	// ClientPort
	ClientPort int `json:"client_port"`
	// Token
	ClientToken string `json:"client_token"`
}

func (*Client) GenerateClientURI

func (c *Client) GenerateClientURI(path string) string

type ClientStatus

type ClientStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// CPUUsage is the CPU usage of the client
	CPUUsage float64 `json:"cpu_usage"`
	// MemoryUsage is the memory usage of the client
	MemoryUsage float64 `json:"memory_usage"`
	// DiskUsage is the disk usage of the client
	DiskUsage float64 `json:"disk_usage"`
	// NetworkUsage is the network usage of the client
	NetworkUsage float64 `json:"network_usage"`
	// ContainerNum is the number of containers of the client
	ContainerNum int `json:"container_num"`
	// ContainerUsage is the usage of containers of the client
	ContainerUsage float64 `json:"container_usage"`
}

type Container

type Container struct {
	Id       string            `json:"id"`
	Image    string            `json:"image"`
	Uuid     string            `json:"uuid"`
	Time     int               `json:"time"`
	Owner    int               `json:"owner"`
	HostPort string            `json:"host_port"`
	Labels   map[string]string `json:"labels"`
	Status   string            `json:"status"`
	CPUUsage float64           `json:"cpu_usage"`
	MemUsage float64           `json:"mem_usage"`
	Networks []Network         `json:"networks"`
}

func (*Container) IsDown

func (c *Container) IsDown() bool

func (*Container) IsRunning

func (c *Container) IsRunning() bool

type DBContainer

type DBContainer struct {
	gorm.Model
	Id            int    `gorm:"primaryKey;autoIncrement;not null"`
	ContainerName string `gorm:"type:varchar(255);not null"`
	ContainerId   string `gorm:"type:varchar(255);not null;unique;index"`
	Labels        string `gorm:"type:varchar(2048);not null"`
	Image         string `gorm:"type:varchar(255);not null"`
	Uid           int    `gorm:"type:int;not null"`
}

type DBImage

type DBImage struct {
	gorm.Model
	Id        int       `gorm:"primaryKey;autoIncrement;not null"`
	ImageName string    `gorm:"type:varchar(255);not null"`
	ImageId   string    `gorm:"type:varchar(255);not null;index"`
	LastUsage time.Time `gorm:"type:datetime;not null"`
}

func (*DBImage) IsExpired

func (c *DBImage) IsExpired(duration time.Duration) bool

type DBService

type DBService struct {
	gorm.Model
	Id          int    `gorm:"primaryKey;autoIncrement;not null"`
	ServiceName string `gorm:"type:varchar(255);not null"`
	ServiceId   string `gorm:"type:varchar(255);not null;unique;index"`
	Containers  string `gorm:"type:varchar(2048);not null"`
	Networks    string `gorm:"type:varchar(2048);not null"`
	Flags       string `gorm:"type:varchar(2048);not null"`
}

func (*DBService) GetService

func (c *DBService) GetService() (Service, error)

func (*DBService) InjectService

func (c *DBService) InjectService(service Service)

type DockerComposeFile

type DockerComposeFile struct {
	Services map[string]DockerComposeFileService `yaml:"services"`
	Networks map[string]DockerComposeFileNetwork `yaml:"networks"`
	Volumes  map[string]struct{}                 `yaml:"volumes"`
}

func (*DockerComposeFile) FromYaml

func (c *DockerComposeFile) FromYaml(text string) error

func (*DockerComposeFile) ToYaml

func (c *DockerComposeFile) ToYaml() string

type DockerComposeFileNetwork

type DockerComposeFileNetwork struct {
	IPAM DockerComposeFileNetworkIPAM `yaml:"ipam"`
}

type DockerComposeFileNetworkIPAM

type DockerComposeFileNetworkIPAM struct {
	Driver     string                               `yaml:"driver"`
	Attachable bool                                 `yaml:"attachable"`
	Internal   bool                                 `yaml:"internal"`
	Config     []DockerComposeFileNetworkIPAMConfig `yaml:"config"`
}

type DockerComposeFileNetworkIPAMConfig

type DockerComposeFileNetworkIPAMConfig struct {
	Subnet string `yaml:"subnet"`
}

type DockerComposeFileService

type DockerComposeFileService struct {
	Image    string                                     `yaml:"image"`
	Build    string                                     `yaml:"build"`
	Networks map[string]DockerComposeFileServiceNetwork `yaml:"networks"`
	Ports    []string                                   `yaml:"ports"`
}

type DockerComposeFileServiceNetwork

type DockerComposeFileServiceNetwork struct {
	Ipv4Address string `yaml:"ipv4_address"`
	Ipv6Address string `yaml:"ipv6_address"`
}

type Image

type Image struct {
	Id           int    `json:"id"`
	Uuid         string `json:"uuid"`
	Name         string `json:"name"`
	User         string `json:"user"`
	LastUpdate   int    `json:"last_update"`
	PortProtocol string `json:"port_protocol"`
	VirtualSize  int64  `json:"virtual_size"`
}

type KisaraNetworkMonitorContainer

type KisaraNetworkMonitorContainer struct {
	ContainerId string `json:"container_id"`
}

type KisaraNetworkMonitorImage

type KisaraNetworkMonitorImage struct {
	ImageName string `json:"image_name"`
}

type KisaraNetworkTest

type KisaraNetworkTest struct {
	// The container to be tested
	ContainerId string `json:"container_id"`
	// The container to test
	TestContainerId string `json:"test_container_id"`
	// The test cmd like "python3 test.py $ip", the $ip will be replaced by the container's ip
	Script string `json:"script"`
}

type KisaraNetworkTestResult

type KisaraNetworkTestResult struct {
	// The container to be tested
	ContainerId string `json:"container_id"`
	// Result of the test, bytewise
	Result []byte `json:"result"`
}

type KisaraNetworkTestResultSet

type KisaraNetworkTestResultSet struct {
	Results []KisaraNetworkTestResult `json:"results"`
}

type KisaraNetworkTestSet

type KisaraNetworkTestSet struct {
	Containers []KisaraNetworkTest `json:"containers"`
}

type KisaraResponse

type KisaraResponse struct {
	// Code is the code of the response
	Code int `json:"code"`
	// Message is the message of the response
	Message string `json:"message"`
	// Data is the data of the response
	Data interface{} `json:"data"`
}

func ErrorResponse

func ErrorResponse(code int, message string) KisaraResponse

func SuccessResponse

func SuccessResponse(data interface{}) KisaraResponse

type KisaraResponseWrap

type KisaraResponseWrap[T any] struct {
	// Code is the code of the response
	Code int `json:"code"`
	// Message is the message of the response
	Message string `json:"message"`
	// Data is the data of the response
	Data T `json:"data"`
}

type KisaraService

type KisaraService struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Owner       int    `json:"owner"`
	Config      string `json:"config"` // json string of service config
}

Service is not the service in docker compose, it is the service config in kisara

func (*KisaraService) GetConfig

func (c *KisaraService) GetConfig() (ServiceConfig, error)

type KisaraVMImage

type KisaraVMImage struct {
	// Id of the VM image
	Id string `json:"id"`
	// Image name
	Image string `json:"image"`
	// Image tag
	Tag string `json:"tag"`
	// architecture
	Arch string `json:"arch"`
	// Type of VM
	Type string `json:"type"`
	// Base qemu image
	BaseImage string `json:"base_image"`
	// Image size
	Size int64 `json:"size"`
	// created time
	Created int64 `json:"created"`
	// Require resource
	Limit KisaraVmLimit `json:"limit"`
	// checksum
	Checksum string `json:"checksum"` // sha256
}

type KisaraVmLimit

type KisaraVmLimit struct {
	// CPU limit
	Cpu float64 `json:"cpu"` // 0.5 means 50% of one core
	// Memory limit
	Mem int64 `json:"mem"` // bytes
	// Disk limit
	Disk int64 `json:"disk"` // bytes
	// Network limit
	Network int64 `json:"network"` // bytes
}

type KisaraVmNetwork

type KisaraVmNetwork struct {
	// Network name
	Name string `json:"name"`
	// Network type
	Type string `json:"type"`
	// Ip
	Ip string `json:"ip"`
	// Gateway
	Gateway string `json:"gateway"`
	// Subnet
	Subnet string `json:"subnet"`
	// Mac
	Mac string `json:"mac"`
}

type Network

type Network struct {
	Id       string `json:"id"`
	Subnet   string `json:"subnet"`
	Name     string `json:"name"`
	Internal bool   `json:"internal"`
	Driver   string `json:"driver"`
	Scope    string `json:"scope"`
}

type RequestCheckLaunchService

type RequestCheckLaunchService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// RequestID is the request ID of the container
	MessageResponseId string `json:"response_id" form:"response_id" binding:"required"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id" form:"finish_response_id" binding:"required"`
}

type RequestCheckLaunchStatus

type RequestCheckLaunchStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// Response Id
	ResponseId string `json:"response_id" form:"response_id" binding:"required"`
}

type RequestCheckLaunchVm

type RequestCheckLaunchVm struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// RequestID is the request ID of the container
	MessageResponseId string `json:"response_id" form:"response_id" binding:"required"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id" form:"finish_response_id" binding:"required"`
}

type RequestCheckPullImage

type RequestCheckPullImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func HandleControllerRequestCheckPullImage(request_id string)
	// RequestID is the request ID of the container
	MessageResponseId string `json:"message_resposne_id" form:"message_resposne_id" binding:"required"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id" form:"finish_response_id" binding:"required"`
}

type RequestCheckStopService

type RequestCheckStopService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// ResponseID
	ResponseID string `json:"response_id" form:"response_id" binding:"required"`
}

type RequestConnect

type RequestConnect struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// ClientIp
	ClientIp string `json:"client_ip" form:"client_ip" binding:"required"`
	// ClientPort
	ClientPort int `json:"client_port" form:"client_port" binding:"required"`
	// callback
	Callback func(ResponseConnect) `json:"-"`
}

type RequestCreateNetwork

type RequestCreateNetwork struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func (c *Docker) CreateNetwork(subnet string, name string, host_join bool) error
	// Subnet is the subnet of the container
	Subnet string `json:"subnet" form:"subnet" binding:"required"`
	// Name is the name of the container
	Name string `json:"name" form:"name" binding:"required"`
	// Internal is the host join of the container
	Internal bool `json:"internal" form:"internal" binding:"required"`
	// Driver
	Driver string `json:"driver" form:"driver" binding:"required"`
}

type RequestDeleteImage

type RequestDeleteImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func (c *Docker) DeleteImage(image_id string) error
	// ImageID is the image ID of the container
	ImageID string `json:"image_id" form:"image_id" binding:"required"`
}

type RequestDisconnect

type RequestDisconnect struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestExecContainer

type RequestExecContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func (c *Docker) Exec(container_id string, cmd string) error
	// ContainerID is the container ID of the container
	ContainerID string `json:"container_id" form:"container_id" binding:"required"`
	// Cmd is the cmd of the container
	Cmd string `json:"cmd" form:"cmd" binding:"required"`
}

type RequestHeartBeat

type RequestHeartBeat struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestInspectContainer

type RequestInspectContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func (c *Docker) InspectContainer(container_id string, has_state ...bool) (*kisara_types.Container, error)
	// ContainerID is the container ID of the container
	ContainerIDs []string `json:"container_id" form:"container_id" binding:"required"`
	// HasState is the has state of the container
	HasState bool `json:"has_state" form:"has_state" binding:"required"`
}

type RequestLaunchContainer

type RequestLaunchContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func (c *Docker) CreateContainer(image *Image, uid int, port_protocol string, subnet_name string, module string, env_mount ...map[string]string) (*Container, error)
	// Image is the image of the container
	Image string `json:"image" form:"image" binding:"required"`
	// UID is the uid of the container
	UID int `json:"uid" form:"uid"`
	// PortProtocol is the port protocol of the container
	PortProtocol string `json:"port_protocol" form:"port_protocol"`
	// SubnetName is the subnet name of the container
	SubnetName string `json:"subnet_name" form:"subnet_name" binding:"required"`
	// Module is the module of the container
	Module string `json:"module" form:"module"`
	// EnvMount is the env mount of the container
	EnvMount []map[string]string `json:"env_mount" form:"env_mount"`
}

type RequestLaunchService

type RequestLaunchService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// ServiceConfig
	ServiceConfig KisaraService `json:"service_config" form:"service_config" binding:"required"`
}

type RequestLaunchVm

type RequestLaunchVm struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// Vm id
	ImageId string `json:"image_id" form:"image_id" binding:"required"`
	// Cpu limit
	CpuLimit int `json:"cpu_limit" form:"cpu_limit" binding:"required"`
	// Memory limit
	MemoryLimit int `json:"memory_limit" form:"memory_limit" binding:"required"`
	// Disk limit
	DiskLimit int `json:"disk_limit" form:"disk_limit" binding:"required"`
	// Network limit
	NetworkLimit int `json:"network_limit" form:"network_limit" binding:"required"`
	// NetworkNames is the network names of the container, vm will be connected to these networks if they exist, otherwise, error will be returned
	NetworkNames []string `json:"network_names" form:"network_names" binding:"required"`
}

request to launch a vm, with the vm image id, cpu limit, memory limit, disk limit, network limit if limit is 0, it's unlimited

type RequestListContainer

type RequestListContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestListImage

type RequestListImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestListNetwork

type RequestListNetwork struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestListService

type RequestListService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestListVm

type RequestListVm struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
}

type RequestNetworkMonitorCheck

type RequestNetworkMonitorCheck struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// Response Id
	ResponseId string `json:"response_id" form:"response_id" binding:"required"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id" form:"finish_response_id" binding:"required"`
}

type RequestNetworkMonitorRun

type RequestNetworkMonitorRun struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// context
	Context io.Reader `json:"context" form:"context"`
	// NetworkName
	NetworkName string `json:"network_name" form:"network_name" binding:"required"`
}

send request

type RequestNetworkMonitorRunScript

type RequestNetworkMonitorRunScript struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// Containers to be tested
	Containers KisaraNetworkTestSet `json:"containers" form:"containers" binding:"required"`
}

type RequestNetworkMonitorRunToByRecieved

type RequestNetworkMonitorRunToByRecieved struct {
	// ClientID is the unique ID of the client
	ClientID string `form:"client_id" binding:"required"`
	// context
	Context *multipart.FileHeader `form:"file" binding:"required"`
	// NetworkName
	NetworkName string `form:"network_name" binding:"required"`
}

parsed request

type RequestNetworkMonitorStop

type RequestNetworkMonitorStop struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// NetworkMonitor Container Id
	NetworkMonitorContainerId string `json:"network_monitor_container_id" form:"network_monitor_container_id" binding:"required"`
}

type RequestPullImage

type RequestPullImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func HandleControllerRequestPullImage(request_id string, image_name string, port_protocol string, user string)
	// ImageName is the image name of the container
	ImageName string `json:"image_name" form:"image_name" binding:"required"`
	// PortProtocol is the port protocol of the container
	PortProtocol string `json:"port_protocol" form:"port_protocol" binding:"required"`
	// User is the user of the container
	User string `json:"user" form:"user" binding:"required"`
}

type RequestRemoveContainer

type RequestRemoveContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// ContainerID is the container ID of the container
	ContainerID string `json:"container_id" form:"container_id" binding:"required"`
}

type RequestRemoveNetwork

type RequestRemoveNetwork struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// func (c *Docker) RemoveNetwork(network_id string) error
	// NetworkID is the network ID of the container
	NetworkID string `json:"network_id" form:"network_id" binding:"required"`
}

type RequestStatus

type RequestStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// CPUUsage is the CPU usage of the client
	CPUUsage float64 `json:"cpu_usage" form:"cpu_usage" binding:"required"`
	// MemoryUsage is the memory usage of the client
	MemoryUsage float64 `json:"memory_usage" form:"memory_usage" binding:"required"`
	// DiskUsage is the disk usage of the client
	DiskUsage float64 `json:"disk_usage" form:"disk_usage" binding:"required"`
	// NetworkUsage is the network usage of the client
	NetworkUsage float64 `json:"network_usage" form:"network_usage" binding:"required"`
	// ContainerNum is the number of containers of the client
	ContainerNum int `json:"container_num" form:"container_num" binding:"required"`
	// ContainerUsage is the usage of containers of the client
	ContainerUsage float64 `json:"container_usage" form:"container_usage" binding:"required"`
}

type RequestStopContainer

type RequestStopContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// ContainerID is the container ID of the container
	ContainerID string `json:"container_id" form:"container_id" binding:"required"`
}

type RequestStopService

type RequestStopService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// ServiceID
	ServiceID string `json:"service_id" form:"service_id" binding:"required"`
}

type ResponseCheckLaunchService

type ResponseCheckLaunchService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// Finished is the finished of the container
	Finished bool `json:"finished"`
	// Message
	Message string `json:"message"`
	// Service
	Service Service `json:"service"`
}

type ResponseCheckLaunchStatus

type ResponseCheckLaunchStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// ContainerID is the container ID of the container
	Container Container
	// Error is the error of the container
	Error string `json:"error"`
	// Finished
	Finished bool `json:"finished"`
}

type ResponseCheckLaunchVm

type ResponseCheckLaunchVm struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the vm
	Error string `json:"error"`
	// Finished is the finished of the vm
	Finished bool `json:"finished"`
	// Message
	Message string `json:"message"`
}

type ResponseCheckPullImage

type ResponseCheckPullImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// Finished is the finished of the container
	Finished bool `json:"finished"`
	// RequestID is the request ID of the container
	Message string `json:"message"`
}

type ResponseCheckStopService

type ResponseCheckStopService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// Finished is the finished of the container
	Finished bool `json:"finished"`
}

type ResponseConnect

type ResponseConnect struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Token is the token of the client
	ClientToken string `json:"client_token"`
}

type ResponseCreateNetwork

type ResponseCreateNetwork struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseDeleteImage

type ResponseDeleteImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseDisconnect

type ResponseDisconnect struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
}

type ResponseExecContainer

type ResponseExecContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseFinalLaunchServiceStatus

type ResponseFinalLaunchServiceStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// Service
	Service Service `json:"service"`
}

type ResponseFinalLaunchStatus

type ResponseFinalLaunchStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// ContainerID is the container ID of the container
	Container Container
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseFinalLaunchVmStatus

type ResponseFinalLaunchVmStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the vm
	Error string `json:"error"`
	// Vm
	Vm VM `json:"vm"`
}

type ResponseFinalNetworkMonitorStatus

type ResponseFinalNetworkMonitorStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the run
	Error string `json:"error"`
	// NetworkMonitor Container Id
	NetworkMonitorContainerId string `json:"network_monitor_container_id"`
}

type ResponseFinalPullImageStatus

type ResponseFinalPullImageStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseHeartBeat

type ResponseHeartBeat struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Timestamp is the timestamp of the client, used to check the connection, if the timestamp is not updated for a long time, the client should reconnect
	Timestamp int64 `json:"timestamp"`
}

type ResponseInspectContainer

type ResponseInspectContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Container is the container of the container
	Containers []Container `json:"container"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseLaunchContainer

type ResponseLaunchContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id" form:"client_id" binding:"required"`
	// Response Id
	ResponseId string `json:"response_id" form:"response_id" binding:"required"`
}

type ResponseLaunchService

type ResponseLaunchService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// Service
	MessageResponseId string `json:"response_id"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id"`
}

type ResponseLaunchVm

type ResponseLaunchVm struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the vm
	Error string `json:"error"`
	// Vm
	MessageResponseId string `json:"response_id"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id"`
}

type ResponseListContainer

type ResponseListContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Containers is the containers of the container
	Containers []Container `json:"containers"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseListImage

type ResponseListImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Images is the images of the container
	Images []Image `json:"images"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseListNetwork

type ResponseListNetwork struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Networks is the networks of the container
	Networks []Network `json:"networks"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseListService

type ResponseListService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Services is the services of the container
	Services []Service `json:"services"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseListVm

type ResponseListVm struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Vms is the vms of the container
	Vms []VM `json:"vms"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseNetworkMonitorCheck

type ResponseNetworkMonitorCheck struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the run
	Error string `json:"error"`
	// Finished is the finished of the run
	Finished bool `json:"finished"`
	// Message
	Message string `json:"message"`
	// NetworkMonitor Container Id
	NetworkMonitorContainerId string `json:"network_monitor_container_id"`
}

type ResponseNetworkMonitorRun

type ResponseNetworkMonitorRun struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the vm
	Error string `json:"error"`
	// Response Id
	ResponseId string `json:"response_id"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id"`
}

type ResponseNetworkMonitorRunScript

type ResponseNetworkMonitorRunScript struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the run
	Error string `json:"error"`
	// Containers to be tested
	Result KisaraNetworkTestResultSet `json:"result"`
}

type ResponseNetworkMonitorStop

type ResponseNetworkMonitorStop struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the run
	Error string `json:"error"`
}

type ResponsePullImage

type ResponsePullImage struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// RequestID is the request ID of the container
	MessageResponseId string `json:"message_resposne_id"`
	// FinishResponseID is the finish response ID of the container
	FinishResponseID string `json:"finish_response_id"`
}

type ResponseRemoveContainer

type ResponseRemoveContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseRemoveNetwork

type ResponseRemoveNetwork struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseStatus

type ResponseStatus struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
}

type ResponseStopContainer

type ResponseStopContainer struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
}

type ResponseStopService

type ResponseStopService struct {
	// ClientID is the unique ID of the client
	ClientID string `json:"client_id"`
	// Error is the error of the container
	Error string `json:"error"`
	// ResponseID
	ResponseID string `json:"response_id"`
}

type Server

type Server struct {
	ServerIp   string `json:"server_ip"`
	ServerPort string `json:"server_port"`
}

type Service

type Service struct {
	Id         string        `json:"id"`
	Name       string        `json:"name"`
	Containers []Container   `json:"containers"`
	Networks   []Network     `json:"networks"`
	Flags      []ServiceFlag `json:"flags"`
	Status     string        `json:"status"`
}

Service is the service kisara generated for the user

type ServiceConfig

type ServiceConfig struct {
	Containers     []ServiceConfigContainer `json:"containers" yaml:"containers"`
	TotalScore     int                      `json:"total_score" yaml:"total_score"`
	NetworkCount   int                      `json:"network_count" yaml:"network_count"`
	ContainerCount int                      `json:"container_count" yaml:"container_count"`
}

func (*ServiceConfig) FromYaml

func (c *ServiceConfig) FromYaml(text_config string) error

func (*ServiceConfig) GetFlagCount

func (c *ServiceConfig) GetFlagCount() int

func (*ServiceConfig) GetNetworks

func (c *ServiceConfig) GetNetworks() []ServiceConfigContainerNetwork

func (*ServiceConfig) RandomCIDRCount

func (c *ServiceConfig) RandomCIDRCount() int

func (*ServiceConfig) ToYaml

func (c *ServiceConfig) ToYaml() string

type ServiceConfigContainer

type ServiceConfigContainer struct {
	Image    string                              `json:"image" yaml:"image"`
	Ports    []ServiceConfigContainerPortMapping `json:"ports" yaml:"ports"`
	Networks []ServiceConfigContainerNetwork     `json:"networks" yaml:"networks"`
	Flags    []ServiceConfigContainerFlag        `json:"flags" yaml:"flags"`
	Env      map[string]string                   `json:"env" yaml:"env"`
}

func (*ServiceConfigContainer) GetPortProtocol

func (c *ServiceConfigContainer) GetPortProtocol() map[int]string

func (*ServiceConfigContainer) GetPortProtocolText

func (c *ServiceConfigContainer) GetPortProtocolText() string

type ServiceConfigContainerFlag

type ServiceConfigContainerFlag struct {
	FlagCommand string `json:"flag_command" yaml:"flag_command"`
	FlagScore   int    `json:"flag_score" yaml:"flag_score"`
	FlagUuid    string `json:"flag_uuid" yaml:"flag_uuid"` // uuid of flag
}

type ServiceConfigContainerNetwork

type ServiceConfigContainerNetwork struct {
	Network    string `json:"network" yaml:"network"`        // network to be used, if random_network is true, this field should be a string of network name
	RandomCIDR bool   `json:"random_cidr" yaml:"RandomCIDR"` // whether to generate random container
}

type ServiceConfigContainerPortMapping

type ServiceConfigContainerPortMapping struct {
	Port     int    `json:"port" yaml:"port"`         // port in container to be mapped
	Protocol string `json:"protocol" yaml:"protocol"` // protocol of port
}

type ServiceFlag

type ServiceFlag struct {
	FlagUuid string `json:"flag_uuid"`
	Flag     string `json:"flag"`
}

ServiceFlag Contains the flag kisara generated for the service, it's not the part of service config

type VM

type VM struct {
	// VM name
	Name string `json:"name"`
	// base image
	ImageId string `json:"image_id"`
	// VM type
	Type string `json:"type"`
	// VM arch
	Arch string `json:"arch"`
	// VM status
	Status string `json:"status"`
	// VM created time
	Created int64 `json:"created"`
	// Base  container id
	BaseContainerId string `json:"base_container_id"`
	// VM id
	Id string `json:"id"`
	// Limit of VM
	Limit KisaraVmLimit `json:"limit"`
	// Network
	Network []KisaraVmNetwork `json:"network"`
}

Jump to

Keyboard shortcuts

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