Making the config for drivers public
This commit is contained in:
parent
aae6047edc
commit
78a0f82bc5
|
@ -24,7 +24,7 @@ type DockerDriver struct {
|
||||||
fingerprint.StaticFingerprinter
|
fingerprint.StaticFingerprinter
|
||||||
}
|
}
|
||||||
|
|
||||||
type dockerDriverConfig struct {
|
type DockerDriverConfig struct {
|
||||||
ImageName string `mapstructure:"image"`
|
ImageName string `mapstructure:"image"`
|
||||||
Command string `mapstructure:"command"`
|
Command string `mapstructure:"command"`
|
||||||
Args string `mapstructure:"args"`
|
Args string `mapstructure:"args"`
|
||||||
|
@ -39,7 +39,7 @@ type dockerDriverConfig struct {
|
||||||
SearchDomains string `mapstructure:"search_domains"`
|
SearchDomains string `mapstructure:"search_domains"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dockerDriverConfig) Validate() error {
|
func (c *DockerDriverConfig) Validate() error {
|
||||||
if c.ImageName == "" {
|
if c.ImageName == "" {
|
||||||
return fmt.Errorf("Docker Driver needs an image name")
|
return fmt.Errorf("Docker Driver needs an image name")
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ func (d *DockerDriver) containerBinds(alloc *allocdir.AllocDir, task *structs.Ta
|
||||||
}
|
}
|
||||||
|
|
||||||
// createContainer initializes a struct needed to call docker.client.CreateContainer()
|
// createContainer initializes a struct needed to call docker.client.CreateContainer()
|
||||||
func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, driverConfig *dockerDriverConfig) (docker.CreateContainerOptions, error) {
|
func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, driverConfig *DockerDriverConfig) (docker.CreateContainerOptions, error) {
|
||||||
var c docker.CreateContainerOptions
|
var c docker.CreateContainerOptions
|
||||||
if task.Resources == nil {
|
if task.Resources == nil {
|
||||||
d.logger.Printf("[ERR] driver.docker: task.Resources is empty")
|
d.logger.Printf("[ERR] driver.docker: task.Resources is empty")
|
||||||
|
@ -320,7 +320,7 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
||||||
var driverConfig dockerDriverConfig
|
var driverConfig DockerDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ type ExecDriver struct {
|
||||||
DriverContext
|
DriverContext
|
||||||
fingerprint.StaticFingerprinter
|
fingerprint.StaticFingerprinter
|
||||||
}
|
}
|
||||||
type execDriverConfig struct {
|
type ExecDriverConfig struct {
|
||||||
ArtifactSource string `mapstructure:"artifact_source`
|
ArtifactSource string `mapstructure:"artifact_source`
|
||||||
Checksum string `mapstructure:"checksum"`
|
Checksum string `mapstructure:"checksum"`
|
||||||
Command string `mapstructure:"command"`
|
Command string `mapstructure:"command"`
|
||||||
|
@ -56,7 +56,7 @@ func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
||||||
var driverConfig execDriverConfig
|
var driverConfig ExecDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ type JavaDriver struct {
|
||||||
fingerprint.StaticFingerprinter
|
fingerprint.StaticFingerprinter
|
||||||
}
|
}
|
||||||
|
|
||||||
type javaDriverConfig struct {
|
type JavaDriverConfig struct {
|
||||||
JvmOpts string `mapstructure:"jvm_options"`
|
JvmOpts string `mapstructure:"jvm_options"`
|
||||||
ArtifactSource string `mapstructure:"artifact_source`
|
ArtifactSource string `mapstructure:"artifact_source`
|
||||||
Checksum string `mapstructure:"checksum"`
|
Checksum string `mapstructure:"checksum"`
|
||||||
|
@ -98,7 +98,7 @@ func (d *JavaDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
||||||
var driverConfig javaDriverConfig
|
var driverConfig JavaDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ type QemuDriver struct {
|
||||||
fingerprint.StaticFingerprinter
|
fingerprint.StaticFingerprinter
|
||||||
}
|
}
|
||||||
|
|
||||||
type qemuDriverConfig struct {
|
type QemuDriverConfig struct {
|
||||||
ArtifactSource string `mapstructure:"artifact_source`
|
ArtifactSource string `mapstructure:"artifact_source`
|
||||||
Checksum string `mapstructure:"checksum"`
|
Checksum string `mapstructure:"checksum"`
|
||||||
Accelerator string `mapstructure:"accelerator"`
|
Accelerator string `mapstructure:"accelerator"`
|
||||||
|
@ -77,7 +77,7 @@ func (d *QemuDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool,
|
||||||
// Run an existing Qemu image. Start() will pull down an existing, valid Qemu
|
// Run an existing Qemu image. Start() will pull down an existing, valid Qemu
|
||||||
// image and save it to the Drivers Allocation Dir
|
// image and save it to the Drivers Allocation Dir
|
||||||
func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
||||||
var driverConfig qemuDriverConfig
|
var driverConfig QemuDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ func (d *RawExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (boo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
||||||
var driverConfig execDriverConfig
|
var driverConfig ExecDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ type RktDriver struct {
|
||||||
fingerprint.StaticFingerprinter
|
fingerprint.StaticFingerprinter
|
||||||
}
|
}
|
||||||
|
|
||||||
type rktDriverConfig struct {
|
type RktDriverConfig struct {
|
||||||
ImageName string `mapstructure:"image"`
|
ImageName string `mapstructure:"image"`
|
||||||
Args string `mapstructure:"args"`
|
Args string `mapstructure:"args"`
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func (d *RktDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, e
|
||||||
|
|
||||||
// Run an existing Rkt image.
|
// Run an existing Rkt image.
|
||||||
func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, error) {
|
||||||
var driverConfig rktDriverConfig
|
var driverConfig RktDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue