Documentation
¶
Index ¶
- Constants
- func AdoptRuntimeOwnership(ctx context.Context, root string, previous *lockfile.LockedRuntime) (adopted bool, err error)
- 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 RecoverRuntime(ctx context.Context, root 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)
- func VerifyInstalledRuntime(root string) error
- type EnsurePluginsRequest
- type EnsureVersionedPluginCachedRequest
- type EnsureVersionedPluginRequest
- type PluginFetchRequest
- type PluginResourceNotFoundError
- type RunOptions
- type RuntimeFileInfo
- type RuntimeInstallError
- type RuntimeManifestInfo
- type RuntimeRecoveryStatus
- type ServerPackageRequest
Constants ¶
const (
RuntimeRecoveryFilename = ".sampctl-runtime-recovery.json"
)
Variables ¶
This section is empty.
Functions ¶
func AdoptRuntimeOwnership ¶
func AdoptRuntimeOwnership(ctx context.Context, root string, previous *lockfile.LockedRuntime) (adopted bool, err error)
AdoptRuntimeOwnership recovers pending runtime work when previous is supplied, even if no ownership is adopted. It records legacy ownership only when every file matches the previous lockfile and no ownership record exists.
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 RecoverRuntime ¶
RecoverRuntime restores an interrupted update or finishes committed cleanup.
func RunContainer ¶
RunContainer does what Run does but inside a Linux container nolint:gocyclo
func VerifyInstalledRuntime ¶
VerifyInstalledRuntime verifies tracked runtime files without changing them.
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
RestrictFilesToDir bool
}
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 PluginResourceNotFoundError ¶
type PluginResourceNotFoundError struct {
Meta versioning.DependencyMeta
Platform string
Version string
}
PluginResourceNotFoundError identifies a plugin without a matching runtime resource.
func (*PluginResourceNotFoundError) Error ¶
func (e *PluginResourceNotFoundError) Error() string
Error describes the plugin and the requested platform and runtime version.
type RunOptions ¶
type RunOptions struct {
CacheDir string
ProjectDir string
Args []string
Recover bool
Output io.Writer
// PassArgs forwards os.Args[3:] to the container, excluding exact
// --container and --mountCache tokens, only when Args is nil.
//
// Deprecated: use Args. A non-nil empty slice disables legacy forwarding.
PassArgs bool
// Input remains caller-owned and must not be read concurrently with Run.
// POSIX PTY forwarding of *os.File input stops before Run returns. Other
// readers can retain a blocked Read after return; their owner must release
// it before reusing the reader for another execution.
Input io.Reader
}
type RuntimeFileInfo ¶
type RuntimeInstallError ¶
type RuntimeInstallError struct {
Runtime string
Restored bool
Committed bool
RecoveryPending bool
Err error
}
RuntimeInstallError reports the verified outcome of a runtime update.
func (*RuntimeInstallError) Error ¶
func (e *RuntimeInstallError) Error() string
func (*RuntimeInstallError) Unwrap ¶
func (e *RuntimeInstallError) Unwrap() error
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, err error)
EnsureBinariesContext ensures the dir has all the necessary files to run a server.
func GetRuntimeManifestInfo ¶
func GetRuntimeManifestInfo(workingDir string) (*RuntimeManifestInfo, error)
type RuntimeRecoveryStatus ¶
type RuntimeRecoveryStatus struct {
Pending bool
Active bool
Committed bool
Restored bool
CanRecover bool
Runtime string
Path string
}
RuntimeRecoveryStatus describes an interrupted update without changing files.
func InspectRuntimeRecovery ¶
func InspectRuntimeRecovery(ctx context.Context, root string) (status RuntimeRecoveryStatus, err error)
InspectRuntimeRecovery checks pending recovery without creating files.