Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Refactor backends in config to allow for multiple, named backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
theothertomelliott committed Mar 7, 2018
1 parent c95930f commit 2e9e228
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 224 deletions.
2 changes: 1 addition & 1 deletion builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (b *builder) Build(dirConfig *home.EdwardConfiguration, task tracker.Task,
// BuildWithTracker builds a service.
// If force is false, the build will be skipped if the service is already running.
func (b *builder) BuildWithTracker(dirConfig *home.EdwardConfiguration, task tracker.Task, service *services.ServiceConfig, force bool) error {
if !service.BackendConfig.HasBuildStep() {
if !service.Backend().HasBuildStep() {
return nil
}
if task == nil {
Expand Down
82 changes: 53 additions & 29 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ var service1 = services.ServiceConfig{
Description: "My Service 1 is magic",
Path: common.StringToStringPointer("."),
RequiresSudo: true,
BackendConfig: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd",
Launch: "launchCmd",
Stop: "stopCmd",
},
LaunchChecks: &commandline.LaunchChecks{
LogText: "startedProperty",
Backends: []*services.BackendConfig{
{
Name: "backend1",
Type: "commandline",
Config: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd",
Launch: "launchCmd",
Stop: "stopCmd",
},
LaunchChecks: &commandline.LaunchChecks{
LogText: "startedProperty",
},
},
},
},
Logger: common.NullLogger{},
Expand All @@ -43,14 +49,20 @@ var service1alias = services.ServiceConfig{
Aliases: []string{"service2"},
Path: common.StringToStringPointer("."),
RequiresSudo: true,
BackendConfig: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd",
Launch: "launchCmd",
Stop: "stopCmd",
},
LaunchChecks: &commandline.LaunchChecks{
LogText: "startedProperty",
Backends: []*services.BackendConfig{
{
Name: "backend1",
Type: "commandline",
Config: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd",
Launch: "launchCmd",
Stop: "stopCmd",
},
LaunchChecks: &commandline.LaunchChecks{
LogText: "startedProperty",
},
},
},
},
Logger: common.NullLogger{},
Expand All @@ -77,11 +89,17 @@ var group1alias = services.ServiceGroupConfig{
var service2 = services.ServiceConfig{
Name: "service2",
Path: common.StringToStringPointer("service2/path"),
BackendConfig: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd2",
Launch: "launchCmd2",
Stop: "stopCmd2",
Backends: []*services.BackendConfig{
{
Name: "backend1",
Type: "commandline",
Config: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd2",
Launch: "launchCmd2",
Stop: "stopCmd2",
},
},
},
},
Logger: common.NullLogger{},
Expand All @@ -99,14 +117,20 @@ var service3 = services.ServiceConfig{
Name: "service3",
Path: common.StringToStringPointer("."),
RequiresSudo: true,
BackendConfig: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd",
Launch: "launchCmd",
Stop: "stopCmd",
},
LaunchChecks: &commandline.LaunchChecks{
LogText: "startedProperty",
Backends: []*services.BackendConfig{
{
Name: "backend1",
Type: "commandline",
Config: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "buildCmd",
Launch: "launchCmd",
Stop: "stopCmd",
},
LaunchChecks: &commandline.LaunchChecks{
LogText: "startedProperty",
},
},
},
},
Logger: common.NullLogger{},
Expand Down
19 changes: 12 additions & 7 deletions generators/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ func (v *DockerGenerator) VisitDir(path string) (bool, error) {
Name: name,
Path: &dockerPath,
Env: []string{},
BackendConfig: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "docker build -t " + tag + " .",
Launch: "docker run " + strings.Join(portCommands, " ") + " " + tag,
},
LaunchChecks: &commandline.LaunchChecks{
Ports: expectedPorts,
Backends: []*services.BackendConfig{
{
Type: "commandline",
Config: &commandline.Backend{
Commands: commandline.ServiceConfigCommands{
Build: "docker build -t " + tag + " .",
Launch: "docker run " + strings.Join(portCommands, " ") + " " + tag,
},
LaunchChecks: &commandline.LaunchChecks{
Ports: expectedPorts,
},
},
},
},
}
Expand Down
Loading

0 comments on commit 2e9e228

Please sign in to comment.