Documentation ¶
Index ¶
- func CopyFileToRuntime(cacheDir, version, filePath string) (err error)
- func Ensure(ctx context.Context, gh *github.Client, cfg *run.Runtime, noCache bool) (err error)
- func EnsureBinaries(cacheDir string, cfg run.Runtime) (err error)
- func EnsurePlugins(ctx context.Context, gh *github.Client, cfg *run.Runtime, cacheDir string, ...) (err error)
- func EnsureScripts(cfg run.Runtime) (err error)
- func EnsureVersionedPlugin(ctx context.Context, gh *github.Client, meta versioning.DependencyMeta, ...) (files []run.Plugin, err error)
- func EnsureVersionedPluginCached(ctx context.Context, meta versioning.DependencyMeta, ...) (filename string, resource *resource.Resource, err error)
- func FindPackage(cacheDir, version string) (runtime download.RuntimePackage, err error)
- func FromCache(cacheDir, version, dir, platform string) (hit bool, err error)
- func FromNet(cacheDir, version, dir, platform string) (err error)
- func GenerateServerCfg(cfg *run.Runtime) (err error)
- func GetResource(resources []resource.Resource, platform string, version string) (*resource.Resource, error)
- func GetResourcePath(meta versioning.DependencyMeta) (path string)
- func GetRuntimePath(cacheDir, version string) (runtimeDir string)
- func GetServerPackage(version, dir, platform string) (err error)
- func InitialiseServer(version, dir, platform string) (err error)
- func LoadEnvironmentVariables(cfg *run.Runtime)
- func MatchesChecksum(src, platform, cacheDir, version string) (ok bool, err error)
- func NewConfigFromEnvironment(dir string) (cfg run.Runtime, err error)
- func PluginFromCache(meta versioning.DependencyMeta, platform string, version string, ...) (hit bool, filename string, resource *resource.Resource, err error)
- func PluginFromNet(ctx context.Context, gh *github.Client, meta versioning.DependencyMeta, ...) (filename string, resource *resource.Resource, err error)
- func PrepareRuntimeDirectory(cacheDir, version, platform, scriptfiles string) (err error)
- func Run(ctx context.Context, cfg run.Runtime, cacheDir string, passArgs, recover bool, ...) (err error)
- func RunContainer(ctx context.Context, cfg run.Runtime, cacheDir string, passArgs bool, ...) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFileToRuntime ¶
CopyFileToRuntime copies a specific file to execute to the specified version's runtime directory
func Ensure ¶
Ensure will make sure a Config's dir is representative of the held configuration. If any of the following are missing or mismatching, they will be automatically downloaded: - Server binaries (server, announce, npc) - Plugin binaries - Scripts: gamemodes and filterscripts and a `server.cfg` is generated based on the contents of the Config fields.
func EnsureBinaries ¶
EnsureBinaries ensures the dir has all the necessary files to run a server
func EnsurePlugins ¶
func EnsurePlugins( ctx context.Context, gh *github.Client, cfg *run.Runtime, cacheDir string, noCache bool, ) (err error)
EnsurePlugins validates and downloads plugin binary files
func EnsureScripts ¶
EnsureScripts checks that all the declared scripts are present
func EnsureVersionedPlugin ¶
func EnsureVersionedPlugin( ctx context.Context, gh *github.Client, meta versioning.DependencyMeta, dir string, platform string, version string, cacheDir string, plugins bool, includes bool, noCache bool, ) (files []run.Plugin, err error)
EnsureVersionedPlugin automatically downloads a plugin binary from its github releases page
func EnsureVersionedPluginCached ¶
func EnsureVersionedPluginCached( ctx context.Context, meta versioning.DependencyMeta, platform, version, cacheDir string, noCache bool, gh *github.Client, ) ( filename string, resource *resource.Resource, err error, )
EnsureVersionedPluginCached ensures that a plugin exists in the cache
func FindPackage ¶
func FindPackage(cacheDir, version string) (runtime download.RuntimePackage, err error)
FindPackage returns a server resource package for the given version or nil if it's invalid
func FromCache ¶
FromCache tries to grab a server package from cache, `hit` indicates if it was successful
func FromNet ¶
FromNet downloads a server package to the cache, then calls FromCache to finish the job
func GenerateServerCfg ¶
GenerateServerCfg creates a settings file in the SA:MP "server.cfg" format at the specified location nolint:gocyclo
func GetResource ¶
func GetResource(resources []resource.Resource, platform string, version string) (*resource.Resource, error)
GetResource searches a list of resources for one that matches the given platform
func GetResourcePath ¶
func GetResourcePath(meta versioning.DependencyMeta) (path string)
GetResourcePath returns a path where a resource should be stored given the metadata
func GetRuntimePath ¶
GetRuntimePath returns the path from the cache directory where the runtime for a specific version of the server should exist.
func GetServerPackage ¶
GetServerPackage checks if a cached package is available and if not, downloads it to dir
func InitialiseServer ¶
InitialiseServer creates a samp.json by asking the user a series of questions nolint:gocyclo
func LoadEnvironmentVariables ¶
LoadEnvironmentVariables loads Config fields from environment variables - the variable names are simply the `json` tag names uppercased and prefixed with `SAMP_` nolint:gocyclo
func MatchesChecksum ¶
MatchesChecksum checks if the file at the given path src is the correct file for the specified runtime package via MD5 sum
func NewConfigFromEnvironment ¶
NewConfigFromEnvironment creates a Config from the given environment which includes a directory which is searched for either `samp.json` or `samp.yaml` and environment variable versions of the config parameters.
func PluginFromCache ¶
func PluginFromCache( meta versioning.DependencyMeta, platform string, version string, cacheDir string, ) (hit bool, filename string, resource *resource.Resource, err error)
PluginFromCache tries to grab a plugin asset from the cache, `hit` indicates if it was successful
func PluginFromNet ¶
func PluginFromNet( ctx context.Context, gh *github.Client, meta versioning.DependencyMeta, platform string, version string, cacheDir string, ) (filename string, resource *resource.Resource, err error)
PluginFromNet downloads a plugin from the given metadata to the cache directory
func PrepareRuntimeDirectory ¶
PrepareRuntimeDirectory sets up a directory in ~/.samp that contains the server runtime
Types ¶
This section is empty.