core

package
v0.0.0-...-0767f33 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: MIT Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// GetHTTP é a constante usada para requisições de verbo GET
	GetHTTP = "GET"

	// PostHTTP é a constante usada para requisições de verbo POST
	PostHTTP = "POST"

	// PutHTTP é a constante usada para requisições de verbo PUT
	PutHTTP = "PUT"

	// DeleteHTTP é a constante usada para requisições de verbo DELETE
	DeleteHTTP = "DELETE"
)

Variables

View Source
var (
	// RancherAccessKey é a KEY de usuário para acessar na API do Rancher 1.6
	RancherAccessKey string

	// RancherSecretKey é a KEY de senha para acessar na API do Rancher 1.6
	RancherSecretKey string

	// RancherBaseURL é a URL base para acesso aos End-points da API do Rancher 1.6
	RancherBaseURL string

	// RancherProjectID é o ID do projeto base que será usado nas requisições
	RancherProjectID string

	// SlackBotToken é o token que será usado para ter acesso a aplicação do BOT no Slack API
	SlackBotToken string

	// SlackBotID é o ID do BOT que poderá ser usado para futuras comparações de mensagens
	SlackBotID string

	// SlackBotChannel é o canal padrão que o BOT irá escutar
	SlackBotChannel string

	// SlackBotVerificationToken é o Verification Token do BOT que será usado
	// no interactive
	SlackBotVerificationToken string

	// Port é a porta onde a API irá rodar
	Port string

	// SplunkUsername para login no Splunk
	SplunkUsername string

	// SplunkPassword para login no Splunk
	SplunkPassword string

	// SplunkBaseURL para login no Splunk
	SplunkBaseURL string

	// DatabaseUsername is a user to connect on MySQL database
	DatabaseUsername string

	// DatabasePassword is a password to connect on MySQL database
	DatabasePassword string

	// DatabaseURL is a URL to connect on MySQL database
	DatabaseURL string

	// DatabaseSchema is a schema to connect on MySQL database
	DatabaseSchema string

	// StatusCakeChannelID ::
	StatusCakeChannelID string

	// GinMode ::
	GinMode string

	RanchListener *RancherListener
)
View Source
var Commands []Command

Commands é a variável que guarda todos os comandos do BOT

View Source
var DB *gorm.DB

is a single variable to connect on DB on all project

Functions

func CheckErr

func CheckErr(message string, err error)

CheckErr : Função feita para checar os erros

func ConvertResponseToString

func ConvertResponseToString(response io.ReadCloser) (converted string)

ConvertResponseToString : Converte uma série de dados do tipo ReadCloser para String

func CreateCommands

func CreateCommands()

CreateCommands é a função que "cria" todos os comandos, essa função é chamada no main.go

func CreateHTTPClient

func CreateHTTPClient() *http.Client

CreateHTTPClient é a função responsável por retornar um client para que possam ser enviadas as requisições

func GetCommands

func GetCommands(w http.ResponseWriter, r *http.Request)

GetCommands retorna todos os comandos com todos seus atributos

func GetEnvs

func GetEnvs(w http.ResponseWriter, r *http.Request)

GetEnvs mostra todas envs

func PrintLogoOnConsole

func PrintLogoOnConsole()

PrintLogoOnConsole : prints logo on console

func RemoveLastCharacter

func RemoveLastCharacter(s string) string

RemoveLastCharacter é a função que remove o último caracter de uma string

func Start

func Start()

Start : start all proccesses

func WriteOnFile

func WriteOnFile(path string, text string)

WriteOnFile é a função que escreve o que for passado por parâmetro dentro do arquivo passado no path

Types

type Command

type Command struct {
	Cmd         string `json:"command"`
	Description string `json:"description"`
	Usage       string `json:"usage"`
	Lint        string `json:"lint"`
	IsActive    bool   `json:"isActive"`
}

Command é a struct responsável por guardar informações referentes a um comando

type Container

type Container struct {
	ID          string `json:"id"`
	ImageUUID   string `json:"imageUuid"`
	Name        string `json:"name"`
	State       string `json:"state"`
	HealthState string `json:"healthState"`
	HostID      string `json:"hostId"`
}

Container é uma estrutura que é usada para mostrar informações ao usuário

type Env

type Env struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Env usado para retornar o objeto env

type Kanye

type Kanye struct {
	Quote string `json:"quote"`
}

type LoadBalancer

type LoadBalancer struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

LoadBalancer é a estrutura que tem como objetivo representar um LoadBalancer do Rancher de forma um pouco mais resumida (é usado na função GetLoadBalancers())

type RancherListener

type RancherListener struct {
	ID uint
	// contains filtered or unexported fields
}

RancherListener é uma estrutura onde ficam armazenados os dados de acesso ao Rancher API

func (*RancherListener) DeleteContainer

func (ranchListener *RancherListener) DeleteContainer(ID string) string

func (*RancherListener) DisableCanary

func (ranchListener *RancherListener) DisableCanary(ID string) string

DisableCanary é a função que envia a requisição para a API do Rancher com a intenção de comentar todas as linhas do haproxy.cfg

func (*RancherListener) EnableCanary

func (ranchListener *RancherListener) EnableCanary(ID string) string

EnableCanary é a função que retira os "#" de todo o haproxy.cfg depois envia como PUT para a API do Rancher

func (*RancherListener) GetAllEnvironmentsFromRancher

func (RanchListener *RancherListener) GetAllEnvironmentsFromRancher() string

GetAllEnvironmentsFromRancher : get all projects from Rancher

func (*RancherListener) GetHaproxyCfg

func (ranchListener *RancherListener) GetHaproxyCfg(containerID string) string

GetHaproxyCfg Busca a Custom haproxy.cfg do LoadBalancer enviado como parâmetro

func (*RancherListener) GetHostInfo

func (ranchListener *RancherListener) GetHostInfo(ID string) string

func (*RancherListener) GetInstances

func (ranchListener *RancherListener) GetInstances(serviceID string) string

GetInstances é uma função que retornará uma lista de todas as instâncias de um serviço

func (*RancherListener) GetLoadBalancers

func (ranchListener *RancherListener) GetLoadBalancers() []*LoadBalancer

GetLoadBalancers é a função responsável por trazer um slice de LoadBalancer, que pode ser usado para selects na interface do BOT do Slack

func (*RancherListener) GetService

func (ranchListener *RancherListener) GetService(ID string) string

GetService é uma função que retorna o JSON de uma requisição que busca informações de um único serviço

func (*RancherListener) GetServiceStack

func (ranchListener *RancherListener) GetServiceStack(ID string) string

GetServiceStack é uma função que retorna o JSON de uma requisição que busca informações da stack de um serviço em específico

func (*RancherListener) GetServicesFromStack

func (ranchListener *RancherListener) GetServicesFromStack(ID string) string

GetServicesFromStack é uma função que retorna o JSON de uma requisição que busca todos os serviços de uma stack especificada

func (*RancherListener) GetStacks

func (ranchListener *RancherListener) GetStacks() string

GetStacks é uma função que retorna o JSON de uma requisição que busca todas as stacks do environment

func (*RancherListener) HTTPSendRancherRequest

func (rancherListener *RancherListener) HTTPSendRancherRequest(url string, method string, data string) string

HTTPSendRancherRequest é a função que envia a requisição para a API do Rancher e retorna o body do response já convertido em String

func (*RancherListener) ListContainers

func (ranchListener *RancherListener) ListContainers() string

ListContainers é uma função que retornará uma lista de todos os containers de um projeto/environment

func (*RancherListener) ListServices

func (ranchListener *RancherListener) ListServices() string

ListServices é uma função que retorna o JSON (em string) de uma requisição que tem como objetivo buscar todos os serviços do Environment

func (*RancherListener) LogsContainer

func (ranchListener *RancherListener) LogsContainer(containerID string) string

LogsContainer : Função responsável retornar os logs do container

func (*RancherListener) RancherAuthAdd

func (rancherListener *RancherListener) RancherAuthAdd(request *http.Request)

RancherAuthAdd é a função que adiciona as credenciais na requisição que será feita para a API do Rancher

func (*RancherListener) RestartContainer

func (ranchListener *RancherListener) RestartContainer(containerID string)

RestartContainer : Função responsável por dar restart no container recebido por parâmetro

func (*RancherListener) SearchForLbPercent

func (ranchListener *RancherListener) SearchForLbPercent(ID string) (new string, old string)

SearchForLbPercent : Procura pelo percentual atual do LB dentro do lbConfig.config

func (*RancherListener) StartService

func (ranchListener *RancherListener) StartService(ID string)

StartService : Função responsável por dar start no container recebido por parâmetro

func (*RancherListener) StopService

func (ranchListener *RancherListener) StopService(ID string)

StopService : Função responsável por dar stop no container recebido por parâmetro

func (*RancherListener) UpdateCustomHaproxyCfg

func (ranchListener *RancherListener) UpdateCustomHaproxyCfg(ID string, newPercent string, oldPercent string) string

UpdateCustomHaproxyCfg Edita o lbConfig.config do LB

func (*RancherListener) UpgradeService

func (ranchListener *RancherListener) UpgradeService(ID string, newImage string) string

UpgradeService é a função que faz o upgrade da imagem do serviço, recebendo como parâmetro o ID do serviço e o nome da nova imagem do serviço

type ResultSearch

type ResultSearch struct {
	Timestamp  string `json:"@timestamp"`
	Version    int    `json:"@version"`
	Message    string `json:"message"`
	LoggerName string `json:"logger_name"`
	ThreadName string `json:"thread_name"`
	Level      string `json:"level"`
	LevelValue int    `json:"level_value"`
	AppName    string `json:"app_name"`
	AppVersion string `json:"app_version"`
	AppProfile string `json:"app_profile"`
	Trace      struct {
		UUIDRequest         string    `json:"uuidRequest"`
		InsertedOnDate      time.Time `json:"insertedOnDate"`
		DurationMillis      int       `json:"durationMillis"`
		Host                string    `json:"host"`
		Verb                string    `json:"verb"`
		URL                 string    `json:"url"`
		Pattern             string    `json:"pattern"`
		Method              string    `json:"method"`
		ResultStatus        int       `json:"resultStatus"`
		App                 string    `json:"app"`
		IDEmissor           int       `json:"idEmissor"`
		Base                string    `json:"base"`
		ReceivedFromAddress string    `json:"receivedFromAddress"`
		StackTrace          struct {
			Clazz   string `json:"clazz"`
			Message string `json:"message"`
			Stack   string `json:"stack"`
		} `json:"stackTrace"`
		Logs []struct {
			Ts      time.Time `json:"ts"`
			Level   string    `json:"level"`
			Logger  string    `json:"logger"`
			Thread  string    `json:"thread"`
			Content string    `json:"content"`
		} `json:"logs"`
	} `json:"trace"`
}

ResultSearch ::

type SlackListener

type SlackListener struct {
	// contains filtered or unexported fields
}

SlackListener é a struct que armazena dados do BOT

func (*SlackListener) StartBot

func (s *SlackListener) StartBot(rList *RancherListener)

StartBot é a função que inicia o BOT e o prepara para receber eventos de mensagens

type SplunkListener

type SplunkListener struct {
	Username string
	Password string
	APIURL   string
}

SplunkListener é uma struct que armazena as credenciais e URL do Splunk

func (*SplunkListener) ConnectSplunk

func (s *SplunkListener) ConnectSplunk(query string) ResultSearch

ConnectSplunk é uma função feita com objetivo fazer uma consulta no Splunk

Jump to

Keyboard shortcuts

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