Fix some typos and run gofmt on all .go files
This commit is contained in:
@@ -17,4 +17,4 @@ func (c Console) Write(b []byte) (int, error) {
|
||||
}
|
||||
|
||||
return len(b), nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ func (e *Environment) Attach() error {
|
||||
e.SetStream(nil)
|
||||
}()
|
||||
|
||||
// Poll resources in a seperate thread since this will block the copy call below
|
||||
// from being reached until it is completed if not run in a seperate process. However,
|
||||
// Poll resources in a separate thread since this will block the copy call below
|
||||
// from being reached until it is completed if not run in a separate process. However,
|
||||
// we still want it to be stopped when the copy operation below is finished running which
|
||||
// indicates that the container is no longer running.
|
||||
go func(ctx context.Context) {
|
||||
@@ -167,13 +167,13 @@ func (e *Environment) Create() error {
|
||||
PortBindings: a.Bindings(),
|
||||
|
||||
// Configure the mounts for this container. First mount the server data directory
|
||||
// into the container as a r/w bine.
|
||||
// into the container as a r/w bind.
|
||||
Mounts: e.convertMounts(),
|
||||
|
||||
// Configure the /tmp folder mapping in containers. This is necessary for some
|
||||
// games that need to make use of it for downloads and other installation processes.
|
||||
Tmpfs: map[string]string{
|
||||
"/tmp": "rw,exec,nosuid,size="+tmpfsSize+"M",
|
||||
"/tmp": "rw,exec,nosuid,size=" + tmpfsSize + "M",
|
||||
},
|
||||
|
||||
// Define resource limits for the container based on the data passed through
|
||||
@@ -228,7 +228,7 @@ func (e *Environment) convertMounts() []mount.Mount {
|
||||
// Remove the Docker container from the machine. If the container is currently running
|
||||
// it will be forcibly stopped by Docker.
|
||||
func (e *Environment) Destroy() error {
|
||||
// We set it to stopping than offline to prevent crash detection from being triggeree.
|
||||
// We set it to stopping than offline to prevent crash detection from being triggered.
|
||||
e.setState(environment.ProcessStoppingState)
|
||||
|
||||
err := e.client.ContainerRemove(context.Background(), e.Id, types.ContainerRemoveOptions{
|
||||
@@ -250,7 +250,7 @@ func (e *Environment) Destroy() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Attaches to the log for the container. This avoids us missing cruicial output that
|
||||
// Attaches to the log for the container. This avoids us missing crucial output that
|
||||
// happens in the split seconds before the code moves from 'Starting' to 'Attaching'
|
||||
// on the process.
|
||||
func (e *Environment) followOutput() error {
|
||||
@@ -296,7 +296,7 @@ func (e *Environment) followOutput() error {
|
||||
// cases an outage shouldn't affect users too badly. It'll at least keep existing servers working
|
||||
// correctly if anything.
|
||||
//
|
||||
// TODO: handle authorization & local images
|
||||
// TODO: local images
|
||||
func (e *Environment) ensureImageExists(image string) error {
|
||||
// Give it up to 15 minutes to pull the image. I think this should cover 99.8% of cases where an
|
||||
// image pull might fail. I can't imagine it will ever take more than 15 minutes to fully pull
|
||||
@@ -362,7 +362,7 @@ func (e *Environment) ensureImageExists(image string) error {
|
||||
log.WithField("image", image).Debug("pulling docker image... this could take a bit of time")
|
||||
|
||||
// I'm not sure what the best approach here is, but this will block execution until the image
|
||||
// is done being pulled, which is what we neee.
|
||||
// is done being pulled, which is what we need.
|
||||
scanner := bufio.NewScanner(out)
|
||||
for scanner.Scan() {
|
||||
continue
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
)
|
||||
|
||||
type Metadata struct {
|
||||
Image string
|
||||
Stop *api.ProcessStopConfiguration
|
||||
Image string
|
||||
Stop *api.ProcessStopConfiguration
|
||||
}
|
||||
|
||||
// Ensure that the Docker environment is always implementing all of the methods
|
||||
@@ -103,7 +103,7 @@ func (e *Environment) Events() *events.EventBus {
|
||||
// Determines if the container exists in this environment. The ID passed through should be the
|
||||
// server UUID since containers are created utilizing the server UUID as the name and docker
|
||||
// will work fine when using the container name as the lookup parameter in addition to the longer
|
||||
// ID auto-assigned when the container is createe.
|
||||
// ID auto-assigned when the container is created.
|
||||
func (e *Environment) Exists() (bool, error) {
|
||||
_, err := e.client.ContainerInspect(context.Background(), e.Id)
|
||||
|
||||
@@ -137,7 +137,7 @@ func (e *Environment) IsRunning() (bool, error) {
|
||||
return c.State.Running, nil
|
||||
}
|
||||
|
||||
// Determine the container exit state and return the exit code and wether or not
|
||||
// Determine the container exit state and return the exit code and whether or not
|
||||
// the container was killed by the OOM killer.
|
||||
func (e *Environment) ExitState() (uint32, bool, error) {
|
||||
c, err := e.client.ContainerInspect(context.Background(), e.Id)
|
||||
@@ -148,7 +148,7 @@ func (e *Environment) ExitState() (uint32, bool, error) {
|
||||
//
|
||||
// However, someone reported an error in Discord about this scenario happening,
|
||||
// so I guess this should prevent it? They didn't tell me how they caused it though
|
||||
// so that's a mystery that will have to go unsolvee.
|
||||
// so that's a mystery that will have to go unsolved.
|
||||
//
|
||||
// @see https://github.com/pterodactyl/panel/issues/2003
|
||||
if client.IsErrNotFound(err) {
|
||||
@@ -175,4 +175,4 @@ func (e *Environment) SetStopConfiguration(c *api.ProcessStopConfiguration) {
|
||||
e.mu.Lock()
|
||||
e.meta.Stop = c
|
||||
e.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (e *Environment) OnBeforeStart() error {
|
||||
// container and data storage directory.
|
||||
//
|
||||
// This won't actually run an installation process however, it is just here to ensure the
|
||||
// environment gets created properly if it is missing and the server is startee. We're making
|
||||
// environment gets created properly if it is missing and the server is started. We're making
|
||||
// an assumption that all of the files will still exist at this point.
|
||||
if err := e.Create(); err != nil {
|
||||
return err
|
||||
@@ -64,7 +64,7 @@ func (e *Environment) Start() error {
|
||||
|
||||
if c, err := e.client.ContainerInspect(context.Background(), e.Id); err != nil {
|
||||
// Do nothing if the container is not found, we just don't want to continue
|
||||
// to the next block of code here. This check was inlined here to guard againt
|
||||
// to the next block of code here. This check was inlined here to guard against
|
||||
// a nil-pointer when checking c.State below.
|
||||
//
|
||||
// @see https://github.com/pterodactyl/panel/issues/2000
|
||||
@@ -128,7 +128,7 @@ func (e *Environment) Stop() error {
|
||||
|
||||
if s == nil || s.Type == api.ProcessStopSignal {
|
||||
if s == nil {
|
||||
log.WithField("container_id", e.Id).Warn("no stop configuration detected for environment, using termination proceedure")
|
||||
log.WithField("container_id", e.Id).Warn("no stop configuration detected for environment, using termination procedure")
|
||||
}
|
||||
|
||||
return e.Terminate(os.Kill)
|
||||
@@ -217,7 +217,7 @@ func (e *Environment) Terminate(signal os.Signal) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// We set it to stopping than offline to prevent crash detection from being triggeree.
|
||||
// We set it to stopping than offline to prevent crash detection from being triggered.
|
||||
e.setState(environment.ProcessStoppingState)
|
||||
|
||||
sig := strings.TrimSuffix(strings.TrimPrefix(signal.String(), "signal "), "ed")
|
||||
|
||||
@@ -27,7 +27,7 @@ func (e *Environment) setState(state string) error {
|
||||
// Get the current state of the environment before changing it.
|
||||
prevState := e.State()
|
||||
|
||||
// Emit the event to any listeners that are currently registeree.
|
||||
// Emit the event to any listeners that are currently registered.
|
||||
if prevState != state {
|
||||
// If the state changed make sure we update the internal tracking to note that.
|
||||
e.stMu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user