Replace logging and config with DriverContext, which allows us to expand the dependency injection without changing the interface

This commit is contained in:
Chris Bednarski
2015-09-09 18:06:23 -07:00
parent f911a24837
commit 8d4d9645d8
6 changed files with 37 additions and 31 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"log"
"net/http"
"os"
"os/exec"
@@ -21,8 +20,7 @@ import (
// JavaDriver is a simple driver to execute applications packaged in Jars.
// It literally just fork/execs tasks with the java command.
type JavaDriver struct {
logger *log.Logger
config *config.Config
DriverContext
}
// javaHandle is returned from Start/Open as a handle to the PID
@@ -33,12 +31,8 @@ type javaHandle struct {
}
// NewJavaDriver is used to create a new exec driver
func NewJavaDriver(logger *log.Logger, config *config.Config) Driver {
d := &JavaDriver{
logger: logger,
config: config,
}
return d
func NewJavaDriver(ctx *DriverContext) Driver {
return &JavaDriver{*ctx}
}
func (d *JavaDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {