mageutil

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorBlue    = "\033[0;34m"
	ColorGreen   = "\033[0;32m"
	ColorRed     = "\033[0;31m"
	ColorYellow  = "\033[33m"
	ColorMagenta = "\033[35m"
	ColorReset   = "\033[0m"
)
View Source
const (
	MountConfigFilePath = "CONFIG_PATH"
	DeploymentType      = "DEPLOYMENT_TYPE"
	KUBERNETES          = "kubernetes"

	// Directory command constants
	ConfigDir    = "config"
	OutputDir    = "_output"
	SrcDir       = "cmd"
	ToolsDir     = "tools"
	TmpDir       = "tmp"
	ExportDir    = "export"
	ArchiveDir   = "archive"
	LogDir       = "logs"
	BinDir       = "bin"
	PlatformsDir = "platforms"
)

Path constants

View Source
const (
	StartConfigFile = "start-config.yml"
)

Variables

This section is empty.

Functions

func ArchiveProject added in v0.0.18

func ArchiveProject(archiveOptions *ArchiveOptions) error

func BatchKillExistBinaries added in v0.0.8

func BatchKillExistBinaries(binaryPaths []string) error

func Build added in v0.0.13

func Build(services []string, tools []string, pathOpts *PathOptions, buildOpt *BuildOptions) error

func CheckAndReportServicesStatus added in v0.0.18

func CheckAndReportServicesStatus() error

func CheckProcessInMap added in v0.0.9

func CheckProcessInMap(processMap map[string]int, processPath string) bool

func CheckProcessNames

func CheckProcessNames(processPath string, expectedCount int, processMap map[string]int) error

CheckProcessNames checks if the number of processes running that match the specified path equals the expected count.

func CheckServicesRunning added in v0.0.18

func CheckServicesRunning() error

CheckServicesRunning checks whether all configured services are running as expected.

func CheckServicesStopped added in v0.0.18

func CheckServicesStopped() error

CheckServicesStopped returns an error if any configured services are still running.

func CompileForPlatform

func CompileForPlatform(buildOpt *BuildOptions, platform string, serviceTargets, toolTargets []string) error

func DetectPlatform

func DetectPlatform() (string, error)

DetectPlatform detects the operating system and architecture.

func EnsureRootRelPaths added in v0.0.16

func EnsureRootRelPaths(paths ...string) (map[string]string, error)

func ExportMageLauncherArchived added in v0.0.16

func ExportMageLauncherArchived(overrideMappingPaths map[string]string, exportOpt *ExportOptions) error

func FetchProcesses added in v0.0.9

func FetchProcesses() (map[string]int, error)

FetchProcesses returns a map of executable paths to their running count.

func FindPIDsByBinaryPath

func FindPIDsByBinaryPath() (map[string][]int, error)

FindPIDsByBinaryPath returns a map of executable paths to slices of PIDs.

func GetAllRootFilesExcludeIgnore added in v0.0.16

func GetAllRootFilesExcludeIgnore() ([]string, error)

func GetDefaultExportMappingPaths added in v0.0.16

func GetDefaultExportMappingPaths(exclude []string) (map[string]string, error)

func GetSharedLogFile added in v0.0.18

func GetSharedLogFile() (*os.File, error)

func GetSharedLogFileWithoutError added in v0.0.18

func GetSharedLogFileWithoutError() *os.File

func GetStderrInnerLogWriter added in v0.0.18

func GetStderrInnerLogWriter() io.Writer

func GetStdoutInnerLogWriter added in v0.0.18

func GetStdoutInnerLogWriter() io.Writer

func KillExistBinary

func KillExistBinary(binaryPath string) error

KillExistBinary kills all processes matching the given binary file path.

func KillExistingServices added in v0.0.18

func KillExistingServices() error

KillExistingServices kills all configured service processes.

func LoadStartConfig added in v0.0.18

func LoadStartConfig() error

func OsArch

func OsArch() string

func ParseArgList added in v0.0.18

func ParseArgList(arg *string) []string

func Print added in v0.0.16

func Print(opt PrintOptions) error

func PrintBinaryPorts

func PrintBinaryPorts(binaryPath string, pidMap map[string][]int)

func PrintBlue

func PrintBlue(message string)

func PrintErr added in v0.0.18

func PrintErr(err error)

func PrintErrNoTimeStamp added in v0.0.18

func PrintErrNoTimeStamp(err error)

func PrintErrPtr added in v0.0.18

func PrintErrPtr(err *error)

func PrintGreen

func PrintGreen(message string)

func PrintListenedPortsByServices added in v0.0.18

func PrintListenedPortsByServices() error

PrintListenedPortsByServices prints the ports listened to by configured services.

func PrintYellow added in v0.0.4

func PrintYellow(message string)

func Protocol added in v0.0.14

func Protocol() error

func RefreshSpinner added in v0.0.18

func RefreshSpinner()

func RemoveOmitemptyFromFile added in v0.0.14

func RemoveOmitemptyFromFile(filePath string) error

func StartServices added in v0.0.18

func StartServices(services []string) error

StartServices starts all configured services or the specified ones.

func StartTools

func StartTools(tools []string) error

StartTools starts all tool binaries or specified ones.

func StartToolsAndServices

func StartToolsAndServices(tools []string, services []string, pathOpts *PathOptions) error

func StopAndCheckServices added in v0.0.18

func StopAndCheckServices() error

func StopServices added in v0.0.18

func StopServices() error

StopServices terminates all configured service processes.

func StopSpinner added in v0.0.16

func StopSpinner()

func UpdateGlobalPaths added in v0.0.16

func UpdateGlobalPaths(opts *PathOptions) error

UpdateGlobalPaths updates the global Paths variable with new options

func WithSpinner added in v0.0.16

func WithSpinner(message string, fn func())

func WithSpinnerR added in v0.0.18

func WithSpinnerR[R any](message string, fn func() R) R

Types

type ArchiveOptions added in v0.0.18

type ArchiveOptions struct {
	ProjectName *string
}

func (*ArchiveOptions) GetProjectName added in v0.0.18

func (opt *ArchiveOptions) GetProjectName() string

type BuildOptions added in v0.0.16

type BuildOptions struct {
	CgoEnabled *string
	Release    *bool
	Compress   *bool
	Platforms  *[]string
}

func ResolveBuildOptions added in v0.0.16

func ResolveBuildOptions(codeOpt *BuildOptions, envOpt *BuildOptions) *BuildOptions

func (*BuildOptions) GetCgoEnabled added in v0.0.16

func (opt *BuildOptions) GetCgoEnabled() string

func (*BuildOptions) GetCompress added in v0.0.16

func (opt *BuildOptions) GetCompress() bool

func (*BuildOptions) GetPlatforms added in v0.0.16

func (opt *BuildOptions) GetPlatforms() []string

func (*BuildOptions) GetRelease added in v0.0.16

func (opt *BuildOptions) GetRelease() bool

type Cmd added in v0.0.18

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

func NewCmd added in v0.0.18

func NewCmd(command string) *Cmd

func (*Cmd) CombinedOutput added in v0.0.18

func (c *Cmd) CombinedOutput() ([]byte, error)

func (*Cmd) Output added in v0.0.18

func (c *Cmd) Output() ([]byte, error)

func (*Cmd) Run added in v0.0.18

func (c *Cmd) Run() error

func (*Cmd) Start added in v0.0.18

func (c *Cmd) Start() error

func (*Cmd) String added in v0.0.18

func (c *Cmd) String() string

func (*Cmd) Wait added in v0.0.18

func (c *Cmd) Wait() error

func (*Cmd) WithArgs added in v0.0.18

func (c *Cmd) WithArgs(args ...string) *Cmd

func (*Cmd) WithDir added in v0.0.18

func (c *Cmd) WithDir(dir string) *Cmd

func (*Cmd) WithEnv added in v0.0.18

func (c *Cmd) WithEnv(env map[string]string) *Cmd

func (*Cmd) WithPriority added in v0.0.18

func (c *Cmd) WithPriority(priority priority.Level) *Cmd

func (*Cmd) WithStderr added in v0.0.18

func (c *Cmd) WithStderr(stderr io.Writer) *Cmd

func (*Cmd) WithStdin added in v0.0.18

func (c *Cmd) WithStdin(stdin io.Reader) *Cmd

func (*Cmd) WithStdout added in v0.0.18

func (c *Cmd) WithStdout(stdout io.Writer) *Cmd

type ExportOptions added in v0.0.16

type ExportOptions struct {
	ProjectName *string
	BuildOpt    *BuildOptions
}

func (*ExportOptions) GetBuildOpt added in v0.0.16

func (opt *ExportOptions) GetBuildOpt() *BuildOptions

func (*ExportOptions) GetProjectName added in v0.0.16

func (opt *ExportOptions) GetProjectName() string

type PathConfig added in v0.0.16

type PathConfig struct {
	Root                 string
	Config               string
	K8sConfig            string
	Output               string
	OutputTools          string
	OutputTmp            string
	OutputExport         string
	OutputArchive        string
	OutputLog            string
	OutputBin            string
	OutputBinServicePath string
	OutputBinToolPath    string
	OutputHostBinService string
	OutputHostBinTool    string

	Cmd   string // Source cmd directory
	Tools string // Source tools directory
}

PathConfig represents the path configuration structure

var Paths *PathConfig

func NewPathConfig added in v0.0.16

func NewPathConfig(opts *PathOptions) (*PathConfig, error)

NewPathConfig creates a new path configuration with optional settings

func (*PathConfig) GetBinServiceFullPath added in v0.0.18

func (p *PathConfig) GetBinServiceFullPath(binName string) string

GetBinServiceFullPath returns the full path for a binary file

func (*PathConfig) GetBinToolFullPath added in v0.0.18

func (p *PathConfig) GetBinToolFullPath(toolName string) string

GetBinToolFullPath GetToolFullPath returns the full path for a tool

type PathOptions added in v0.0.16

type PathOptions struct {
	RootDir   *string // Custom root directory, default is current working directory(./)
	OutputDir *string // Custom output directory command, default is "_output"
	ConfigDir *string // Custom config directory command, default is "config"

	SrcDir   *string // Custom cmd source directory command, default is "cmd"
	ToolsDir *string // Custom tools source directory command, default is "tools"
}

type PrintOptions added in v0.0.16

type PrintOptions struct {
	Writer    io.Writer
	Color     string
	Message   string
	WithTime  bool
	TwoLine   bool
	NoNewLine bool
	TimeFmt   string
}

type Spinner added in v0.0.16

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

func NewSpinner added in v0.0.16

func NewSpinner(message string) *Spinner

func (*Spinner) Refresh added in v0.0.18

func (s *Spinner) Refresh()

func (*Spinner) Stop added in v0.0.16

func (s *Spinner) Stop()

type StartConfig added in v0.0.18

type StartConfig struct {
	Services           map[string]int `yaml:"services"`
	Tools              []string       `yaml:"tools"`
	MaxFileDescriptors int            `yaml:"maxFileDescriptors"`
}

Jump to

Keyboard shortcuts

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