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 EnsurePlugins(request EnsurePluginsRequest) (err error)
- func EnsureScripts(cfg run.Runtime) (err error)
- func EnsureVersionedPlugin(request EnsureVersionedPluginRequest) (files []run.Plugin, err error)
- func EnsureVersionedPluginCached(request EnsureVersionedPluginCachedRequest) (filename string, resource *pkgresource.Resource, err error)
- func FindPackage(cacheDir, version string) (runtime download.RuntimePackage, err error)
- func FindPackageContext(ctx context.Context, cacheDir, version string) (runtime download.RuntimePackage, err error)
- func FromCache(cacheDir, version, dir, platform string) (hit bool, err error)
- func FromCacheContext(request ServerPackageRequest) (hit bool, err error)
- func FromNet(cacheDir, version, dir, platform string) (err error)
- func FromNetContext(request ServerPackageRequest) (err error)
- func GenerateConfig(cfg *run.Runtime) error
- func GetResource(resources []pkgresource.Resource, platform string, version string) (*pkgresource.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 GetServerPackageContext(ctx context.Context, version, dir, platform string) (err error)
- func MatchesChecksum(src, platform, cacheDir, version string) (ok bool, err error)
- func PluginFromCache(meta versioning.DependencyMeta, platform string, version string, ...) (hit bool, filename string, resource *pkgresource.Resource, err error)
- func PluginFromNet(request PluginFetchRequest) (filename string, resource *pkgresource.Resource, err error)
- func PrepareRuntimeDirectory(cacheDir, version, platform, scriptfiles string) (err error)
- func Run(ctx context.Context, cfg run.Runtime, options RunOptions) error
- func RunContainer(ctx context.Context, cfg run.Runtime, options RunOptions) (err error)
- type EnsurePluginsRequest
- type EnsureVersionedPluginCachedRequest
- type EnsureVersionedPluginRequest
- type PluginFetchRequest
- type RunOptions
- type RuntimeFileInfo
- type RuntimeManifestInfo
- type ServerPackageRequest
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
func EnsurePlugins ¶
func EnsurePlugins(request EnsurePluginsRequest) (err error)
EnsurePlugins validates and downloads plugin binary files.
func EnsureScripts ¶
EnsureScripts checks that all the declared scripts are present
func EnsureVersionedPlugin ¶
func EnsureVersionedPlugin(request EnsureVersionedPluginRequest) (files []run.Plugin, err error)
EnsureVersionedPlugin automatically downloads a plugin binary from its github releases page
func EnsureVersionedPluginCached ¶
func EnsureVersionedPluginCached(request EnsureVersionedPluginCachedRequest) ( filename string, resource *pkgresource.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 FindPackageContext ¶
func FromCache ¶
FromCache tries to grab a server package from cache, `hit` indicates if it was successful
func FromCacheContext ¶
func FromCacheContext(request ServerPackageRequest) (hit bool, err error)
func FromNet ¶
FromNet downloads a server package to the cache, then calls FromCache to finish the job
func FromNetContext ¶
func FromNetContext(request ServerPackageRequest) (err error)
FromNetContext downloads a server package to the cache, then extracts it to dir.
func GenerateConfig ¶
GenerateConfig generates the runtime configuration file for cfg's effective runtime.
func GetResource ¶
func GetResource(resources []pkgresource.Resource, platform string, version string) (*pkgresource.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 GetServerPackageContext ¶
GetServerPackageContext checks if a cached package is available and if not, downloads it to dir.
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 PluginFromCache ¶
func PluginFromCache( meta versioning.DependencyMeta, platform string, version string, cacheDir string, ) (hit bool, filename string, resource *pkgresource.Resource, err error)
PluginFromCache tries to grab a plugin asset from the cache, `hit` indicates if it was successful
func PluginFromNet ¶
func PluginFromNet(request PluginFetchRequest) (filename string, resource *pkgresource.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
func RunContainer ¶
RunContainer does what Run does but inside a Linux container nolint:gocyclo
Types ¶
type EnsurePluginsRequest ¶
type EnsurePluginsRequest struct {
Context context.Context
GitHub *github.Client
Config *run.Runtime
CacheDir string
NoCache bool
}
EnsurePluginsRequest describes runtime plugin preparation.
type EnsureVersionedPluginCachedRequest ¶
type EnsureVersionedPluginCachedRequest struct {
Context context.Context
Meta versioning.DependencyMeta
Platform string
Version string
CacheDir string
NoCache bool
GitHub *github.Client
}
EnsureVersionedPluginCachedRequest describes a cache lookup for a versioned plugin asset.
type EnsureVersionedPluginRequest ¶
type EnsureVersionedPluginRequest struct {
Context context.Context
GitHub *github.Client
Meta versioning.DependencyMeta
Dir string
Platform string
Version string
CacheDir string
PluginDestDir string
Plugins bool
Includes bool
NoCache bool
IgnorePatterns []string
}
EnsureVersionedPluginRequest describes plugin acquisition and extraction.
type PluginFetchRequest ¶
type PluginFetchRequest struct {
Context context.Context
GitHub *github.Client
Meta versioning.DependencyMeta
Platform string
Version string
CacheDir string
}
PluginFetchRequest describes a plugin asset fetch from the network.
type RunOptions ¶
type RuntimeFileInfo ¶
type RuntimeManifestInfo ¶
type RuntimeManifestInfo struct {
Version string
Platform string
RuntimeType string
Files []RuntimeFileInfo
}
func EnsureBinaries ¶
func EnsureBinaries(cacheDir string, cfg run.Runtime) (*RuntimeManifestInfo, error)
EnsureBinaries ensures the dir has all the necessary files to run a server
func EnsureBinariesContext ¶
func EnsureBinariesContext(ctx context.Context, cacheDir string, cfg run.Runtime) (*RuntimeManifestInfo, error)
EnsureBinariesContext ensures the dir has all the necessary files to run a server.
func GetRuntimeManifestInfo ¶
func GetRuntimeManifestInfo(workingDir string) (*RuntimeManifestInfo, error)