utils

package
v0.0.0-...-f4a0a9e Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYSTEM_RESERVED_MEMORY = 2.5 * 1000
)

Variables

This section is empty.

Functions

func BalanceMemory

func BalanceMemory(services []ServiceConfig, totalMemory int) (map[string]*ServiceConfig, error)

func CheckCPU

func CheckCPU(cores int) error

func CheckDisk

func CheckDisk(size uint64) error

func CheckDistro

func CheckDistro(distro string) error

func CheckMem

func CheckMem(size uint64) error

func CreatePathIfNotExist

func CreatePathIfNotExist(path string) error

func GenerateCerts

func GenerateCerts(folder string) error

func GenerateConfig

func GenerateConfig(variables interface{}, text, output string) error

GenerateConfig generates a configuration file from a text template.

The `variables` argument is a map of variables to be used in the template. The `text` argument is the text of the template. The `output` argument is the path to the output file.

The function returns an error if there is any problem generating the configuration file.

func GenerateSecret

func GenerateSecret(size int) string

func GetLock

func GetLock(v int, locksDir string) bool

func GetMainIP

func GetMainIP() (string, error)

func GetMainIface

func GetMainIface(mainIP string) (string, error)

func GetOddValue

func GetOddValue(value int) int

func GetStep

func GetStep() int

func MakeDir

func MakeDir(mode os.FileMode, arg ...string) string

func Mode

func Mode(mode string, options map[string]interface{}) interface{}

func ParseTemplate

func ParseTemplate(text string, data interface{}) (*bytes.Buffer, error)

ParseTemplate parses a template and executes it with the given data.

text: The text of the template. data: The data to use to render the template.

Returns: A bytes.Buffer containing the rendered template, or an error if parsing or execution failed.

func Remove

func Remove(path string) error

func RunCmd

func RunCmd(command string, arg ...string) error

func RunEnvCmd

func RunEnvCmd(env []string, command string, arg ...string) error

func SetLock

func SetLock(v int, locksDir string) error

func Str

func Str(s string) *string

func WriteYAML

func WriteYAML(url string, data interface{}) error

Types

type ServiceConfig

type ServiceConfig struct {
	Name           string
	Priority       int
	AssignedMemory int
	MinMemory      int
	MaxMemory      int
}

Jump to

Keyboard shortcuts

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