models

package
v0.0.0-...-d135f55 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAppWithInputs

func BindAppWithInputs(app *App) error

func Connect2Database

func Connect2Database() error

func Connect2SplunkServer

func Connect2SplunkServer() (*splunk.SplunkConnection, error)

func CreateDeploymentApp

func CreateDeploymentApp(deploymentApp DeploymentApp) error

func CreateDeploymentServerClass

func CreateDeploymentServerClass(dplySCs []DeploymentServerClass) error

func CreateTag

func CreateTag(user, env string, dplySCs []DeploymentServerClass) error

func DeinstallDeploymentApp

func DeinstallDeploymentApp(deploymentApp DeploymentApp) error

func DeleteAnnouncement

func DeleteAnnouncement(id string) error

func DeleteApp

func DeleteApp(appID int) error

func DeleteDeployment

func DeleteDeployment(name, user string) error

func DeleteDeploymentByAppID

func DeleteDeploymentByAppID(appID int) error

func DeleteDeploymentByIDs

func DeleteDeploymentByIDs(appID int, scIDs []int) error

func DeleteExpiredSession

func DeleteExpiredSession()

func DeleteForwarder

func DeleteForwarder(name, user string) error

func DeleteInput

func DeleteInput(inputID int, inputType string) error

func DeleteServerClass

func DeleteServerClass(name, user string) error

func DeleteServerClassByForwarderID

func DeleteServerClassByForwarderID(forwarderID int) error

func DeleteSplunkHost

func DeleteSplunkHost(name string) error

func DeleteSplunkUser

func DeleteSplunkUser(splunkUserName string) error

func DeleteUnitPrice

func DeleteUnitPrice(id int) error

func DeleteUser

func DeleteUser(userName string) error

func GetAppName

func GetAppName(appID int) (string, error)

func GetInput

func GetInput(inputID int, inputType string) (interface{}, error)

func GetInputs

func GetInputs(envUser []string, inputType string, isAdmin bool) (interface{}, error)

func GetInputsByAppID

func GetInputsByAppID(envUser []string, appID int, inputType string, isAdmin bool) (interface{}, error)

func GetServerClassIDsByAppID

func GetServerClassIDsByAppID(appID int, getForwarders bool) ([]int, error)

func GetSessionStore

func GetSessionStore() (*mysqlstore.MySQLStore, error)

func GetSplunkEndpoint

func GetSplunkEndpoint(name, param string) string

func GetSplunkHttpResponse

func GetSplunkHttpResponse(values url.Values, method, host, resource, param string) (*http.Response, error)

func IsAdmin

func IsAdmin(userName string) bool

func Migrate

func Migrate(conffile string) error

Migrate models

func ParseHttpResponse

func ParseHttpResponse(resp *http.Response, lineKeyWord, msg string) error

func ParseTemplate

func ParseTemplate(templateFileName string, data interface{}) (string, error)

func PrepareSessionStore

func PrepareSessionStore(conf settings.Configuration) error

func RemoveDeploymentApp

func RemoveDeploymentApp(deploymentApp DeploymentApp) error

func RemoveDeploymentServerClass

func RemoveDeploymentServerClass(dplySCs []DeploymentServerClass) error

func ResetUserPassword

func ResetUserPassword(user User) error

func SaveAnnouncement

func SaveAnnouncement(announcement Announcement) error

func SaveApp

func SaveApp(app App) error

func SaveDeployment

func SaveDeployment(deploymentList []Deployment) error

func SaveFileInput

func SaveFileInput(input FileInput, envUser []string) error

func SaveForwarder

func SaveForwarder(forwarders []Forwarder) error

func SaveScriptInput

func SaveScriptInput(input ScriptInput, envUser []string) error

func SaveServerClass

func SaveServerClass(sc ServerClass) error

func SaveSplunkHost

func SaveSplunkHost(splunkHost SplunkHost) error

func SaveSplunkUser

func SaveSplunkUser(splunkUser SplunkUser) error

func SaveUnitPrice

func SaveUnitPrice(unitPrice UnitPrice) error

func SaveUnixAppInput

func SaveUnixAppInput(inputs []UnixAppInput, envUser []string) error

func SaveUser

func SaveUser(user User, sendEmail bool) error

func SendEmail

func SendEmail(from, to, target, who, function, subject, link string, Data, AdditionalData interface{}) error

func SpkChangeTagPermission

func SpkChangeTagPermission(tagName, host string, forwarderWildcards []string) []string

func SpkCheckServerClassExistence

func SpkCheckServerClassExistence(env, sc string) error

func SpkCreateDeploymentServerClass

func SpkCreateDeploymentServerClass(sc DeploymentServerClass, host string) error

func SpkCreateOrUpdateSplunkSamlGroup

func SpkCreateOrUpdateSplunkSamlGroup(userName, host, positionIDs string) error

func SpkCreateSplunkApp

func SpkCreateSplunkApp(userName string, hosts []string) error

func SpkCreateSplunkRole

func SpkCreateSplunkRole(userName string, hosts []string) error

func SpkCreateSplunkUser

func SpkCreateSplunkUser(userName, password, email, positionID string, hosts []string) error

func SpkCreateTag

func SpkCreateTag(tagName, host string, forwarderWildcards []string) error

func SpkDeinstallDeploymentApp

func SpkDeinstallDeploymentApp(appName, host string) error

func SpkDeleteDeploymentServerClass

func SpkDeleteDeploymentServerClass(sc DeploymentServerClass, host string) error

func SpkUpdateDeploymentServerClass

func SpkUpdateDeploymentServerClass(sc DeploymentServerClass, host string) error

func SpkUpdateDistributedApp

func SpkUpdateDistributedApp(scName, appName, host string) error

func SpkVerifyTagPermission

func SpkVerifyTagPermission(tagName, host string, forwarderWildcards []string) []string

func UpdateAnnouncement

func UpdateAnnouncement(id string, newAnnouncement Announcement) error

func UpdateApp

func UpdateApp(appID int, newApp App) error

func UpdateAppFieldsByID

func UpdateAppFieldsByID(appID int, fields []string, values []interface{}, tableName string) error

func UpdateDeployment

func UpdateDeployment(user string, newDplyList []Deployment) error

func UpdateFileInput

func UpdateFileInput(inputID int, newInput FileInput) error

func UpdateForwarder

func UpdateForwarder(name, user string, newForwarder Forwarder) error

func UpdateInputFields

func UpdateInputFields(inputIDs []int, fields []string, values []interface{}, tableName string) error

func UpdateInputsFieldsByAppID

func UpdateInputsFieldsByAppID(appID int, fields []string, values []interface{}, tableName string) error

func UpdateScriptInput

func UpdateScriptInput(inputID int, newInput ScriptInput) error

func UpdateServerClass

func UpdateServerClass(name, user string, newServerClass ServerClass) error

func UpdateSplunkHost

func UpdateSplunkHost(name string, newSplunkHost SplunkHost) error

func UpdateSplunkUser

func UpdateSplunkUser(splunkUserName string, newSplunkUser SplunkUser) error

func UpdateUnitPrice

func UpdateUnitPrice(id int, newUnitPrice UnitPrice) error

func UpdateUnixAppInput

func UpdateUnixAppInput(inputID int, newInput UnixAppInput) error

func UpdateUser

func UpdateUser(userName string, newUser User, action string) error

func VerifyCredentials

func VerifyCredentials(userName, password string) error

Types

type Announcement

type Announcement struct {
	ID        int       `json:"id"`
	Content   string    `json:"content" gorm:"size:1000"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetAnnouncement

func GetAnnouncement(id string) (Announcement, error)

func GetAnnouncements

func GetAnnouncements() ([]Announcement, error)

type App

type App struct {
	ID           int    `json:"id"`
	Name         string `json:"name"`
	Env          string `json:"env"`
	UserName     string `json:"user_name"` //added later
	DeployStatus int    `json:"deploy_status"`
	// UserID          int            `json:"user_id"`        //to remove
	// SplunkHostID    int            `json:"splunk_host_id"` //to remove
	UnixApp         bool           `json:"unix_app"`
	FileInputIDs    []IDStruct     `json:"file_input_ids" gorm:"-"`     //add, update
	ScriptInputIDs  []IDStruct     `json:"script_input_ids" gorm:"-"`   //add, update
	UnixAppInputIDs []IDStruct     `json:"unix_app_input_ids" gorm:"-"` //add, update
	ServerClass     []ServerClass  `json:"server_classes" gorm:"-"`     //for display in deployment
	ServerClassIDs  []IDStruct     `json:"server_class_ids" gorm:"-"`   //for update in deployment
	FileInputs      []FileInput    `json:"file_inputs" gorm:"-"`        //display
	ScriptInputs    []ScriptInput  `json:"script_inputs" gorm:"-"`      //display
	UnixAppInputs   []UnixAppInput `json:"unix_app_inputs" gorm:"-"`    //display
	CreatedAt       time.Time      `json:"created_at"`
	UpdatedAt       time.Time      `json:"updated_at"`
}

func GetApp

func GetApp(envUser []string, appID int, getInputs bool, isAdmin bool) (App, error)

func GetApps

func GetApps(envUser []string, getInputs bool, getServerClasses bool, getForwarders bool, isAdmin bool) ([]App, error)

type Deployment

type Deployment struct {
	ID            int       `json:"id"`
	AppID         int       `json:"app_id"`
	ServerClassID int       `json:"server_class_id"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

func GetDeployment

func GetDeployment(name, user string) (Deployment, error)

func GetDeploymentList

func GetDeploymentList(envUserFrom []string) ([]Deployment, error)

type DeploymentApp

type DeploymentApp struct {
	AppID      int        `json:"app_id" gorm:"-"`
	FolderName string     `json:"folder_name" gorm:"-"`
	InputsConf string     `json:"inputs_conf" gorm:"-"`
	ScriptIDs  []IDStruct `json:"script_ids" gorm:"-"`
	AppType    string     `json:"app_type" gorm:"-"`
	Env        string     `json:"env" gorm:"-"`
}

type DeploymentInfo

type DeploymentInfo struct {
	User     string
	Env      string
	App      string
	Success  string
	Error    string
	Link4Tag string
}

type DeploymentServerClass

type DeploymentServerClass struct {
	ServerClassName string       `json:"server_class_name" gorm:"-"`
	AppName         string       `json:"app_name" gorm:"-"`
	AppID           int          `json:"app_id" gorm:"-"`
	ForwarderNames  []NameStruct `json:"forwarder_names" gorm:"-"`
	User            string       `json:"user" gorm:"-"`
	Env             string       `json:"env" gorm:"-"`
}

type FileInput

type FileInput struct {
	ID                  int    `json:"id"`
	LogFilePath         string `json:"log_file_path"`
	Sourcetype          string `json:"sourcetype"`
	LogFileSize         string `json:"log_file_size"`
	DataRetentionPeriod string `json:"data_retention_period"`
	Memo                string `json:"memo"`
	// Status              int       `json:"status"`         // to remove
	Env      string `json:"env"`       //added later
	UserName string `json:"user_name"` //added later
	// SplunkUserID int       `json:"splunk_user_id"` // to remove
	AppID     int       `json:"app_id"`
	AppName   string    `json:"app_name" gorm:"-"` //for display
	Blacklist string    `json:"blacklist"`
	Crcsalt   string    `json:"crcsalt"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Forwarder

type Forwarder struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	UserName  string    `json:"user_name"`
	Env       string    `json:"env"`
	Share     string    `json:"share"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetForwarder

func GetForwarder(name, user string) (Forwarder, error)

func GetForwarders

func GetForwarders(envUserFrom []string, isAdmin bool) ([]Forwarder, error)

func GetForwardersByIDs

func GetForwardersByIDs(fwdrIDs []string) ([]Forwarder, error)

func SpkGetForwarders

func SpkGetForwarders(env, user string) ([]Forwarder, error)

type ID

type ID struct {
	ID int
}

type IDStruct

type IDStruct struct {
	ID int `json:"id"`
}

type LogSize

type LogSize struct {
	ServiceID string `json:"service_id"`
	Host      string `json:"host"`
	SizeMB    int    `json:"size_mb"`
}

func GetLogSize

func GetLogSize(month, serviceID string) ([]LogSize, error)

type NameStruct

type NameStruct struct {
	Name string `json:"name"`
}

type SamlGroup

type SamlGroup struct {
	Name  string   `json:"name"`
	Roles []string `json:"roles"`
}

func SpkGetSamlRoles

func SpkGetSamlRoles(groupName, host string) SamlGroup

type ScriptInput

type ScriptInput struct {
	ID                  int    `json:"id"`
	Sourcetype          string `json:"sourcetype"`
	LogFileSize         string `json:"log_file_size"`
	DataRetentionPeriod string `json:"data_retention_period"`
	Env                 string `json:"env"` //added later
	// Memo                string    `json:"memo"`
	// Status       int       `json:"status"`         // to remove
	UserName string `json:"user_name"` //added later
	// SplunkUserID int       `json:"splunk_user_id"` // to remove
	AppID      int       `json:"app_id"`
	AppName    string    `json:"app_name" gorm:"-"` //for display
	OS         string    `json:"os"`
	Interval   string    `json:"interval"`
	ScriptName string    `json:"script_name"`
	Script     []byte    `json:"script" gorm:"size:10240"`
	ScriptCode string    `json:"script_code" gorm:"-"`
	Option     string    `json:"option"`
	Exefile    bool      `json:"exefile"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type ServerClass

type ServerClass struct {
	ID           int       `json:"id"`
	Name         string    `json:"name"`
	UserName     string    `json:"user_name"`
	Env          string    `json:"env"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	ForwarderIDs []int     `json:"forwarder_ids" gorm:"-"` // for add, update, delete
	Forwarders   []string  `json:"forwarders" gorm:"-"`    // for display
}

func GetServerClass

func GetServerClass(name, user string) (ServerClass, error)

func GetServerClasses

func GetServerClasses(envUser []string, isAdmin bool) ([]ServerClass, error)

func GetServerClassesByIDs

func GetServerClassesByIDs(scIDs []int, getForwarders bool) ([]ServerClass, error)

type ServerClassForwarder

type ServerClassForwarder struct {
	ID            int       `json:"id"`
	ServerClassID int       `json:"server_class_id"`
	ForwarderID   int       `json:"forwarder_id"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

type SplunkHost

type SplunkHost struct {
	ID        int       `json:"id"`
	Name      string    `json:"name" sql:"unique_index"`
	Role      string    `json:"role"`
	Env       string    `json:"env"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetSplunkHost

func GetSplunkHost(name string) (SplunkHost, error)

func GetSplunkHostByEnvRole

func GetSplunkHostByEnvRole(envAndRole []string) (SplunkHost, error)

func GetSplunkHosts

func GetSplunkHosts(envAndRole []string) ([]SplunkHost, error)

type SplunkUser

type SplunkUser struct {
	ID            int       `json:"id"`
	UserName      string    `json:"user_name"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	RpaasUserName string    `json:"rpaas_user_name"`
	Env           string    `json:"env"`
	Memo          string    `json:"memo"`
	SearchHead    string    `json:"search_head"`
	Email         string    `json:"email"`
	PositionIDs   string    `json:"position_ids"`
	Password      string    `gorm:"-"`
}

func GetSplunkUser

func GetSplunkUser(splunkUserName string, env string) (SplunkUser, error)

func GetSplunkUsers

func GetSplunkUsers() ([]SplunkUser, error)

type StorageSize

type StorageSize struct {
	ServiceID string `json:"service_id"`
	IndexName string `json:"index_name"`
	SizeMB    int    `json:"size_mb"`
}

func GetStorageSize

func GetStorageSize(month, serviceID string) ([]StorageSize, error)

type Tag

type Tag struct {
	Name        string   `json:"name"`
	Hosts       []string `json:"hosts"`
	SourceTypes []string `json:"source_types"`
	Sources     []string `json:"sources"`
	GUIDs       []string `json:"guids"`
}

func SpkGetTagFields

func SpkGetTagFields(tagName, host string) (Tag, error)

type TemplateData

type TemplateData struct {
	To             string
	Who            string
	Subject        string
	Body           string
	Link           string
	AdminEmail     string
	Data           interface{}
	AdditionalData interface{}
}

type UnitPrice

type UnitPrice struct {
	ID           int       `json:"id"`
	ServicePrice int       `json:"service_price"`
	StoragePrice int       `json:"storage_price"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func GetUnitPrice

func GetUnitPrice(id int) (UnitPrice, error)

func GetUnitPrices

func GetUnitPrices() ([]UnitPrice, error)

type UnixAppInput

type UnixAppInput struct {
	ID int `json:"id"`
	// Sourcetype          string `json:"sourcetype"`
	DataRetentionPeriod string `json:"data_retention_period"`
	// Status              int       `json:"status"`         // to remove
	Env      string `json:"env"`       // added later
	UserName string `json:"user_name"` //added later
	// SplunkUserID int       `json:"splunk_user_id"` //to remove
	AppID      int       `json:"app_id"`
	AppName    string    `json:"app_name" gorm:"-"` //for display
	Interval   string    `json:"interval"`
	ScriptName string    `json:"script_name"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type User

type User struct {
	ID                int       `json:"id"`
	Admin             bool      `json:"admin"`
	UserName          string    `json:"user_name" sql:"unique_index"`
	Email             string    `json:"email"`
	EmailForEmergency string    `json:"email_for_emergency"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
	LastLoginAt       time.Time `json:"last_login_at"`
	Password          string    `json:"password"`
	GroupName         string    `json:"group_name"`
	AppTeamName       string    `json:"app_team_name"`
	// ServiceID         int       `json:"service_id"`
	ServiceID string `json:"service_id"`
	Status    string `json:"status"`
}

func GetUser

func GetUser(userName string) (User, error)

func GetUsers

func GetUsers() ([]User, error)

Jump to

Keyboard shortcuts

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