mrunner

package module
v0.0.0-...-bbfa983 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultEndPort uint = 60000
View Source
const DefaultStartPort uint = 10000
View Source
const PlanPrefix = "mgc:"

Variables

View Source
var FilterGoFilePackageName = filterGoFilePackageName{}

Get the package name in the file

View Source
var FilterModFileGoVersion = goVersionFilter{}

A filter for getting the module name from a go.mod file

View Source
var FilterModFileModuleName = moduleNameFilter{}

A filter for getting the module name from a go.mod file

View Source
var FilterModFileReplacers = replacerFilter{}

A filter for getting all replacers and where they point (separated by ;).

Replacers can also contain versions (e.g. github.com/Liphium/chat v1.0.0;github.com/Liphium/magic v1.1.1).

Functions

func GenerateRunFile

func GenerateRunFile(deployContainers bool, deleteContainers bool) string

Generate the run file calling the runner

func RemoveOneLineComments

func RemoveOneLineComments(line string) string

Helper function for removing // comments in a line

func ReplaceLines

func ReplaceLines(content string, replacer Replacer) string

Replace all results of a filter with something

func ReplaceLinesSanitized

func ReplaceLinesSanitized(content string, replacer Replacer, sanitizer Replacer) string

Replace all results of a filter with something

func ScanLines

func ScanLines(content string, filters []Filter) map[Filter][]string

Scan all lines of content using filters.

Returns all of the results by filter.

func ScanLinesSanitize

func ScanLinesSanitize(content string, filters []Filter, sanitizer Replacer) map[Filter][]string

Scan all lines of content using filters. First cleans the lines using the sanitizer.

Returns all of the results by filter.

func ScriptPathToSnakeCase

func ScriptPathToSnakeCase(path string) string

Convert a script path to its snake case name (script/dir/script1.go to script_dir_script1).

Types

type CommentCleaner

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

Removes all block comments and one line comments (/* */ and //)

func (*CommentCleaner) Replace

func (r *CommentCleaner) Replace(old string) string

type Factory

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

func NewFactory

func NewFactory(mDir string) Factory

Create a new factory from the magic directory.

func (Factory) CacheDirectory

func (f Factory) CacheDirectory() string

Get the cache directory

func (Factory) ConfigCacheDirectory

func (f Factory) ConfigCacheDirectory(config string, profile string) string

Get the directory of a config in the cache directory.

func (Factory) ConfigFile

func (f Factory) ConfigFile(config string) string

Get the file path of a config file by name

func (Factory) CopyToCacheWithReplacedPackage

func (f Factory) CopyToCacheWithReplacedPackage(file string, target string, newPackage string) ([]byte, error)

Copy a file to the target directory and replace its package

target should be the full path including the file name

func (Factory) GenerateConfigModule

func (f Factory) GenerateConfigModule(config string, profile string, deployContainers bool, deleteContainers bool, printFunc func(string)) (module string, cachePath string, err error)

Run a config using the runner (returns the path the go module was generated at)

func (Factory) GenerateModFile

func (f Factory) GenerateModFile(dir string, printFunc func(string)) (string, string, error)

Generate the default mod file for any script, test or config.

Returns go version and error.

func (Factory) GenerateScriptFolder

func (f Factory) GenerateScriptFolder(path string, runFileFormat string, printFunc func(string)) (string, error)

Generate a folder for a script

runFileFormat should have one %s in it that will be replaced with the run function of the script.

func (Factory) GenerateTestFolder

func (f Factory) GenerateTestFolder(path string, printFunc func(string)) (string, error)

Generate the folder for a test

Returns the directory where the test was generated.

func (Factory) MagicDirectory

func (f Factory) MagicDirectory() string

Get the magic directory

func (Factory) ModuleDirectory

func (f Factory) ModuleDirectory() (string, error)

Get the directory of the module

func (Factory) ModuleNameAndVersion

func (f Factory) ModuleNameAndVersion() (module string, version string, err error)

Get the module name and version

func (Factory) PrepareFolderInCache

func (f Factory) PrepareFolderInCache(directory string, printFunc func(string)) (string, error)

Prepare a new folder in the cache including creating the mod file, etc.

Returns the module name.

func (Factory) ScriptCacheDirectory

func (f Factory) ScriptCacheDirectory(script string) string

Get the directory of a script in the cache directory.

func (Factory) ScriptDirectory

func (f Factory) ScriptDirectory(script string) string

Get a script's location as an absolute path

func (Factory) TestCacheDirectory

func (f Factory) TestCacheDirectory(script string) string

Get the directory of a test in the cache directory.

func (Factory) TestDirectory

func (f Factory) TestDirectory(path string) string

Get a test in the original directory

func (Factory) UpdateCacheWorkFileVersion

func (f Factory) UpdateCacheWorkFileVersion(version string) error

Create work file or update in case already there.

type Filter

type Filter interface {
	Scan(content string) (bool, string)
}

type FilterGoFileFunctionParameter

type FilterGoFileFunctionParameter struct {
	Parameters []string // The parameter types you want to look for (e.g. string, string)
}

A filter for searching function names by the parameters the function takes in.

func (*FilterGoFileFunctionParameter) Scan

func (f *FilterGoFileFunctionParameter) Scan(content string) (bool, string)

type FilterGoFileImports

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

func (*FilterGoFileImports) Scan

func (f *FilterGoFileImports) Scan(content string) (bool, string)

type GoPackageReplacer

type GoPackageReplacer struct {
	NewPackage string // New package name instead of the old one
}

func (GoPackageReplacer) Replace

func (r GoPackageReplacer) Replace(old string) string

type GoVersionReplacer

type GoVersionReplacer struct {
	Version string // Version to replace the go version with
}

Replace the go version in a go.mod or go.work file

func (*GoVersionReplacer) Replace

func (r *GoVersionReplacer) Replace(old string) string

type NoReplacer

type NoReplacer struct{}

Empty replacer that doesn't do anything. Useful for streamlining code.

func (NoReplacer) Replace

func (r NoReplacer) Replace(old string) string

type OneLineCommentReplacer

type OneLineCommentReplacer struct{}

Removes all one line comments in a file (with //)

func (OneLineCommentReplacer) Replace

func (r OneLineCommentReplacer) Replace(old string) string

type Replacer

type Replacer interface {
	Replace(old string) string
}

type Runner

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

func NewRunner

func NewRunner(ctx *mconfig.Context) (*Runner, error)

Create a new runner

func (*Runner) Clear

func (r *Runner) Clear()

Delete all containers and reset all state

func (*Runner) Deploy

func (r *Runner) Deploy()

Deploy all the containers nessecary for the application

func (*Runner) Environment

func (r *Runner) Environment() *mconfig.Environment

func (*Runner) GeneratePlan

func (r *Runner) GeneratePlan() string

Deploy the containers for the magic context

Jump to

Keyboard shortcuts

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