Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateRunFile(deployContainers bool, deleteContainers bool) string
- func RemoveOneLineComments(line string) string
- func ReplaceLines(content string, replacer Replacer) string
- func ReplaceLinesSanitized(content string, replacer Replacer, sanitizer Replacer) string
- func ScanLines(content string, filters []Filter) map[Filter][]string
- func ScanLinesSanitize(content string, filters []Filter, sanitizer Replacer) map[Filter][]string
- func ScriptPathToSnakeCase(path string) string
- type CommentCleaner
- type Factory
- func (f Factory) CacheDirectory() string
- func (f Factory) ConfigCacheDirectory(config string, profile string) string
- func (f Factory) ConfigFile(config string) string
- func (f Factory) CopyToCacheWithReplacedPackage(file string, target string, newPackage string) ([]byte, error)
- func (f Factory) GenerateConfigModule(config string, profile string, deployContainers bool, deleteContainers bool, ...) (module string, cachePath string, err error)
- func (f Factory) GenerateModFile(dir string, printFunc func(string)) (string, string, error)
- func (f Factory) GenerateScriptFolder(path string, runFileFormat string, printFunc func(string)) (string, error)
- func (f Factory) GenerateTestFolder(path string, printFunc func(string)) (string, error)
- func (f Factory) MagicDirectory() string
- func (f Factory) ModuleDirectory() (string, error)
- func (f Factory) ModuleNameAndVersion() (module string, version string, err error)
- func (f Factory) PrepareFolderInCache(directory string, printFunc func(string)) (string, error)
- func (f Factory) ScriptCacheDirectory(script string) string
- func (f Factory) ScriptDirectory(script string) string
- func (f Factory) TestCacheDirectory(script string) string
- func (f Factory) TestDirectory(path string) string
- func (f Factory) UpdateCacheWorkFileVersion(version string) error
- type Filter
- type FilterGoFileFunctionParameter
- type FilterGoFileImports
- type GoPackageReplacer
- type GoVersionReplacer
- type NoReplacer
- type OneLineCommentReplacer
- type Replacer
- type Runner
Constants ¶
const DefaultEndPort uint = 60000
const DefaultStartPort uint = 10000
const PlanPrefix = "mgc:"
Variables ¶
var FilterGoFilePackageName = filterGoFilePackageName{}
Get the package name in the file
var FilterModFileGoVersion = goVersionFilter{}
A filter for getting the module name from a go.mod file
var FilterModFileModuleName = moduleNameFilter{}
A filter for getting the module name from a go.mod file
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 ¶
Generate the run file calling the runner
func RemoveOneLineComments ¶
Helper function for removing // comments in a line
func ReplaceLines ¶
Replace all results of a filter with something
func ReplaceLinesSanitized ¶
Replace all results of a filter with something
func ScanLinesSanitize ¶
Scan all lines of content using filters. First cleans the lines using the sanitizer.
Returns all of the results by filter.
func ScriptPathToSnakeCase ¶
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 ¶
Create a new factory from the magic directory.
func (Factory) ConfigCacheDirectory ¶
Get the directory of a config in the cache directory.
func (Factory) ConfigFile ¶
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 ¶
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 ¶
Generate the folder for a test
Returns the directory where the test was generated.
func (Factory) ModuleDirectory ¶
Get the directory of the module
func (Factory) ModuleNameAndVersion ¶
Get the module name and version
func (Factory) PrepareFolderInCache ¶
Prepare a new folder in the cache including creating the mod file, etc.
Returns the module name.
func (Factory) ScriptCacheDirectory ¶
Get the directory of a script in the cache directory.
func (Factory) ScriptDirectory ¶
Get a script's location as an absolute path
func (Factory) TestCacheDirectory ¶
Get the directory of a test in the cache directory.
func (Factory) TestDirectory ¶
Get a test in the original directory
func (Factory) UpdateCacheWorkFileVersion ¶
Create work file or update in case already there.
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.
type FilterGoFileImports ¶
type FilterGoFileImports struct {
// contains filtered or unexported fields
}
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 Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
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 ¶
Deploy the containers for the magic context