Documentation ¶
Index ¶
- Variables
- func ChangeMOTD(domain string) error
- func CheckCommands(app, command string) error
- func ConvertBool(in string) (bool, error)
- func Dev() error
- func EmailPrompt() (string, error)
- func GetAppLogs(input string, followFlag bool) error
- func GetConfigPath() (string, error)
- func GetCurrentDirectory() string
- func GetDockerComposeDir() (string, error)
- func GetDockersInfo() (string, error)
- func GetHosstedEnv(env string) string
- func GetHosstedUUID(path string) (string, error)
- func GetSoftwarePath() (string, error)
- func GetUUIDPath() (string, error)
- func HasContainerRunning() bool
- func Import(env string, authorization string, kluster KCluster) error
- func ImportRequest(env, authorization, kluster, klusterJson string) (importResponse, error)
- func Init(env, authorization, image string, instance Instance) error
- func InitRequest(env, authorization, image, instancejson string) (initResponse, error)
- func ListAppPS(input string) error
- func ListCommands() error
- func Ping(env string) error
- func PingRequest(dockers, uuid, env string) (pingResponse, error)
- func PrettyPrint(i interface{}) string
- func RegisterUsers(env string) error
- func Scan(env string) error
- func ScanRequest(imageName, fileName, containerId, imageID, env string) (scanResponse, error)
- func Schedule(env string) error
- func SetAuth(env, app string, flag bool) error
- func SetDomain(env, app, domain string) error
- func SetMonitoring(env string, flag bool) error
- func SetRemoteAccess(env string, flag bool) error
- func SetUpdates(env string, flag bool) error
- func Shell(appDir string, commands []string) (error, string, string)
- func Update(env string) error
- func WriteConfig(w io.Writer, config Config) error
- func WriteConfigWrapper(config Config) error
- type App
- type AvailableCommand
- type AvailableCommandMap
- type Command
- type Config
- type ConfigApplication
- type Docker
- type HosstedRequest
- type Instance
- type KCluster
- type NameSpace
- type RegisterResponse
- type YamlSetting
Constants ¶
This section is empty.
Variables ¶
var AUTHORIZED_KEY_PATH = "/root/.ssh/authorized_keys"
var AVAILABLE = `
apps:
- app: demo
group:
commands: [abc, def]
values: [abc, def]
`
Available commands in yaml format. If a new set of apps/commands needs to be supported, need to append the values here TODO: Handle logic for command group
var GAVAILABLE = `` /* 265-byte string literal not displayed */
Generall available commands, for all apps
Functions ¶
func ChangeMOTD ¶
ChangeMOTD changes the content of the MOTD file, to match the set domain changes TODO: print status TODO: Allow domain to be something other than .com by changing the regex patten
func CheckCommands ¶
CheckCommands check whether the app, and corresponding commands/subcommands are supported. Return error if the provided values are not in the pre-defined list
func ConvertBool ¶
ConvertBool converts the string input to boolean, return error if the input is not true/false
func GetAppLogs ¶
GetAppLogs goes to the app directory, then calls docker-compose logs Similar to ListAppPS func
func GetConfigPath ¶
GetConfigPath gets the pre-defined config path. ~/.hossted/config.yaml
func GetDockerComposeDir ¶
GetDockerComposeDir gets the docker compose directory
func GetDockersInfo ¶
func GetHosstedEnv ¶
GetHosstedEnv determines which env. Support dev/prod only. If it is not set, default as dev
func GetHosstedUUID ¶
GetHosstedUUID gets the uuid from the file /opt/linnovate/run/uuid.txt Return error if it's empty or file not exists TODO: Ask whether it's a request to get the uuid or somewhat being saved to the VM during creation
func GetSoftwarePath ¶
GetSoftwarePath gets the software related path, it could either be /opt/hossted/run/software.txt (Preferred) or /opt/linnovate/run/software.txt If neither of that exists, return error
func HasContainerRunning ¶
func HasContainerRunning() bool
HasContainerRunning checks if there is a container with the name "trafik" in the list of containers
func ImportRequest ¶
func InitRequest ¶
PingRequest sends dockers request
func ListAppPS ¶
ListAppPS goes to the app directory, then calls docker-compose ps if input is "", call prompt to get user input, otherwise look up the application in the config
func ListCommands ¶
func ListCommands() error
ListCommands lists the available services and general commands on the virtual machine. The available application is defined under the file /opt/linoovate/run/uuid.txt. Also it would depends on whether the "action" is predefined as available of the certain app.
func PingRequest ¶
PingRequest sends dockers request
func PrettyPrint ¶
func PrettyPrint(i interface{}) string
PrettyPrint to print struct in a readable way
func RegisterUsers ¶
RegisterUsers updates email, organization in the yaml file, if successful. Also it will get the uuid of the machine, and environment from $HOSSTED_ENV. It will then send an request to the API server, to get the JWT sessin token. TODO: Use the original values as default.
func ScanRequest ¶
ScanRequest sends security request
func SetDomain ¶
SetDomain set the domain for different apps TODO: check whether the function is generic for different apps. Divide to different cases if not. TODO: check error for sed command
func SetMonitoring ¶
func SetRemoteAccess ¶
SetRemoteAccess set the remote access by comment/uncomment the hossted public key in the ~/.ssh/authorized_keys file
func SetUpdates ¶
func WriteConfig ¶
WriteConfig writes the config to the config file (~/.hossted/config.yaml)
func WriteConfigWrapper ¶
WriteConfigWrapper is a wrapper function to call the underlying io.Writer function
Types ¶
type App ¶
type App struct { App string `yaml:"app"` CommandGroup string `yaml:"group"` Commands []string `yaml:"commands"` Values []string `yaml:"values"` }
App is a struct to save the available commands for a particular application The length of Commands and Values is expected to be the same, to give additional information or examples to users, on to call the command
type AvailableCommand ¶
type AvailableCommand struct {
Apps []App `yaml:"apps"`
}
AvailableCommand is the predefined app/command mapping. Maintained with the command.go file
type AvailableCommandMap ¶
AvailableCommandMap saves the map for available commands e.g. map["app.command"] -> [{app command value} {prometheus url example.com} ]
type Config ¶
type Config struct { Email string `yaml:"email"` UserToken string `yaml:"userToken"` SessionToken string `yaml:"sessionToken"` EndPoint string `yaml:"endPoint"` UUIDPath string `yaml:"uuidPath"` HostUUID string `yaml:"hostUuid"` Update bool `yaml:"update"` Monitoring bool `yaml:"monitoring"` Applications []ConfigApplication `yaml:"applications"` }
Config is a struct to parse config.yaml file
func (*Config) GetAppConfig ¶
func (c *Config) GetAppConfig(in string) (ConfigApplication, error)
GetAppConfig finds the specific Application Config with the application name e.g. Find the config for prometheus -> ConfigApplication{prometheus /opt/prometheus}
type ConfigApplication ¶
ConfigApplication is the applications installled in the vm. Currently it will look up the values from /opt/hossted/run/software.txt (Preferred) or /opt/linnovate/run/software.txt Supporting multiple values for future enhancement.
func GetAppInfo ¶
func GetAppInfo() ([]ConfigApplication, error)
GetAppInfo gets the application related information from predefined path /opt/hossted/run/software.txt or /opt/linnovate/run/software.txt Returns the App name, and the corresponding path. e.g. Linnovate-AWS-wikijs -> wikijs TODO Assume single application for now TODO Remove dummy app (for dropdown select demo)
type Docker ¶
type Docker struct { ID string `json:"docker_id"` Image string `json:"image"` ImageID string `json:"image_id"` CreatedAt int64 `json:"created_at"` Ports []types.Port `json:"ports"` Status string `json:"status"` Size int64 `json:"size"` Names []string `json:"names"` Mounts []types.MountPoint `json:"mounts"` Networks string `json:"networks"` Tag string `json:"tag"` }
type HosstedRequest ¶
type HosstedRequest struct { EndPoint string // Request end point Environment string // environment, dev or prod Params map[string]string // kv pairs for param BearToken string // Authorization token SessionToken string // Session token. JWT TypeRequest string // Request type, GET, POST, PUT, DELETE ContentType string // Content type, application/json, multipart/form-data Body io.Reader // Request body }
HosstedRequest is a struct to construct neccessary information to send the request to hossted backend
func (*HosstedRequest) SendRequest ¶
func (h *HosstedRequest) SendRequest() (string, error)
SendRequest sends a request to hossted API server with parameters TODO: This is insecure; use only in dev environments. TODO: Add timeout context TODO: Check all params is not null TODO: Check response status
type Instance ¶
type Instance struct { Uuid string `json:"uuid,omitempty"` Ip string `json:"ip,omitempty"` User string `json:"user,omitempty"` Url string `json:"url,omitempty"` Product string `json:"product,omitempty"` Cpunum string `json:"cpunum,omitempty"` Mem string `json:"mem,omitempty"` Rootsize string `json:"rootsize,omitempty"` Cloud string `json:"cloud,omitempty"` Status string `json:"status,omitempty"` Test_mode string `json:"test_mode,omitempty"` Comment string `json:"comment,omitempty"` }
type KCluster ¶
type KCluster struct { Uuid string `json:"uuid,omitempty"` Namespaces []string `json:"namespaces"` Name string `json:"name,omitempty"` User string `json:"user,omitempty"` Cloud string `json:"cloud,omitempty"` Status string `json:"status,omitempty"` Test_mode string `json:"test_mode,omitempty"` Comment string `json:"comment,omitempty"` }
type RegisterResponse ¶
type RegisterResponse struct { StatusCode int `json:"status"` Message string `json:"msg"` JWT string `json:"jwt"` URL string `json:"url"` }
RegisterResponse is the return response from the register api