Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
Update forge, update dep, refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sclevine committed Oct 27, 2017
1 parent 33d0add commit b987533
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go:
- 1.9.x
install:
- set -e
- curl -fsSLo "$GOPATH/bin/dep" "https://github.com/golang/dep/releases/download/v0.3.1/dep-linux-amd64"
- curl -fsSLo "$GOPATH/bin/dep" "https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64"
- chmod +x "$GOPATH/bin/dep"
- curl -fsSL "https://cli.run.pivotal.io/stable?release=linux64-binary" | tar -C "$GOPATH/bin" -xz cf
- bin/vendor
Expand Down
10 changes: 5 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions cf/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/sclevine/cflocal/fs"
"github.com/sclevine/cflocal/remote"
"github.com/sclevine/forge"
"github.com/sclevine/forge/app"
"github.com/sclevine/forge/engine"
"github.com/sclevine/forge/service"
)

const LatestStack = "cloudfoundry/cflinuxfs2:latest"
Expand All @@ -31,8 +31,8 @@ type RemoteApp interface {
Env(name string) (*remote.AppEnv, error)
SetEnv(name string, env map[string]string) error
Restart(name string) error
Services(name string) (service.Services, error)
Forward(name string, services service.Services) (service.Services, *service.ForwardConfig, error)
Services(name string) (forge.Services, error)
Forward(name string, services forge.Services) (forge.Services, *forge.ForwardDetails, error)
}

//go:generate mockgen -package mocks -destination mocks/local_app.go github.com/sclevine/cflocal/cf/cmd LocalApp
Expand Down Expand Up @@ -74,8 +74,8 @@ type Help interface {

//go:generate mockgen -package mocks -destination mocks/config.go github.com/sclevine/cflocal/cf/cmd Config
type Config interface {
Load() (*forge.LocalYML, error)
Save(localYML *forge.LocalYML) error
Load() (*app.LocalYML, error)
Save(localYML *app.LocalYML) error
}

func parseOptions(args []string, f func(name string, set *flag.FlagSet)) error {
Expand All @@ -94,7 +94,7 @@ func parseOptions(args []string, f func(name string, set *flag.FlagSet)) error {
return nil
}

func getAppConfig(name string, localYML *forge.LocalYML) *forge.AppConfig {
func getAppConfig(name string, localYML *app.LocalYML) *forge.AppConfig {
var app *forge.AppConfig
for _, appConfig := range localYML.Applications {
if appConfig.Name == name {
Expand All @@ -108,8 +108,8 @@ func getAppConfig(name string, localYML *forge.LocalYML) *forge.AppConfig {
return app
}

func getRemoteServices(app RemoteApp, serviceApp, forwardApp string) (service.Services, *service.ForwardConfig, error) {
var services service.Services
func getRemoteServices(app RemoteApp, serviceApp, forwardApp string) (forge.Services, *forge.ForwardDetails, error) {
var services forge.Services

if serviceApp == "" {
serviceApp = forwardApp
Expand Down
8 changes: 4 additions & 4 deletions cf/cmd/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/sclevine/cflocal/cf/cmd/mocks"
sharedmocks "github.com/sclevine/cflocal/mocks"
"github.com/sclevine/forge"
"github.com/sclevine/forge/app"
"github.com/sclevine/forge/engine"
"github.com/sclevine/forge/service"
)

var _ = Describe("Export", func() {
Expand Down Expand Up @@ -63,13 +63,13 @@ var _ = Describe("Export", func() {
It("should export a droplet as a Docker image", func() {
droplet := sharedmocks.NewMockBuffer("some-droplet")
launcher := sharedmocks.NewMockBuffer("some-launcher")
localYML := &forge.LocalYML{
localYML := &app.LocalYML{
Applications: []*forge.AppConfig{
{Name: "some-other-app"},
{
Name: "some-app",
Env: map[string]string{"a": "b"},
Services: service.Services{"some": {{Name: "services"}}},
Services: forge.Services{"some": {{Name: "services"}}},
},
},
}
Expand All @@ -85,7 +85,7 @@ var _ = Describe("Export", func() {
Expect(config.AppConfig).To(Equal(&forge.AppConfig{
Name: "some-app",
Env: map[string]string{"a": "b"},
Services: service.Services{"some": {{Name: "services"}}},
Services: forge.Services{"some": {{Name: "services"}}},
}))
},
).Return("some-id", nil)
Expand Down
8 changes: 4 additions & 4 deletions cf/cmd/mocks/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions cf/cmd/mocks/remote_app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions cf/cmd/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
sharedmocks "github.com/sclevine/cflocal/mocks"
"github.com/sclevine/cflocal/remote"
"github.com/sclevine/forge"
"github.com/sclevine/forge/app"
)

var _ = Describe("Pull", func() {
Expand Down Expand Up @@ -62,7 +63,7 @@ var _ = Describe("Pull", func() {
Running: map[string]string{"c": "d"},
App: map[string]string{"e": "f"},
}
oldLocalYML := &forge.LocalYML{
oldLocalYML := &app.LocalYML{
Applications: []*forge.AppConfig{
{Name: "some-other-app"},
{
Expand All @@ -74,7 +75,7 @@ var _ = Describe("Pull", func() {
},
},
}
newLocalYML := &forge.LocalYML{
newLocalYML := &app.LocalYML{
Applications: []*forge.AppConfig{
{Name: "some-other-app"},
{
Expand Down
3 changes: 2 additions & 1 deletion cf/cmd/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/sclevine/cflocal/cf/cmd/mocks"
sharedmocks "github.com/sclevine/cflocal/mocks"
"github.com/sclevine/forge"
"github.com/sclevine/forge/app"
)

var _ = Describe("Push", func() {
Expand Down Expand Up @@ -58,7 +59,7 @@ var _ = Describe("Push", func() {
Describe("#Run", func() {
It("should replace an app's droplet and env vars, then restart it", func() {
droplet := sharedmocks.NewMockBuffer("some-droplet")
localYML := &forge.LocalYML{
localYML := &app.LocalYML{
Applications: []*forge.AppConfig{
{Name: "some-other-app"},
{
Expand Down
19 changes: 9 additions & 10 deletions cf/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/docker/docker/api/types"
"github.com/sclevine/forge"
"github.com/sclevine/forge/engine"
"github.com/sclevine/forge/wait"
)

type Run struct {
Expand Down Expand Up @@ -109,17 +108,17 @@ func (r *Run) Run(args []string) error {
return err
}
defer sshpass.Close()
waiter, waiterDone := wait.New(5 * time.Second)
waiter, waiterDone := newWaiter(5 * time.Second)
defer waiterDone()
health, done, id, err := r.Forwarder.Forward(&forge.ForwardConfig{
AppName: appConfig.Name,
Stack: LatestStack,
SSHPass: sshpass,
Color: color.GreenString,
ForwardConfig: forwardConfig,
HostIP: netConfig.HostIP,
HostPort: netConfig.HostPort,
Wait: waiter,
AppName: appConfig.Name,
Stack: LatestStack,
SSHPass: sshpass,
Color: color.GreenString,
Details: forwardConfig,
HostIP: netConfig.HostIP,
HostPort: netConfig.HostPort,
Wait: waiter,
})
if err != nil {
return err
Expand Down
14 changes: 7 additions & 7 deletions cf/cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/sclevine/cflocal/cf/cmd/mocks"
sharedmocks "github.com/sclevine/cflocal/mocks"
"github.com/sclevine/forge"
"github.com/sclevine/forge/app"
"github.com/sclevine/forge/engine"
"github.com/sclevine/forge/service"
)

var _ = Describe("Run", func() {
Expand Down Expand Up @@ -73,23 +73,23 @@ var _ = Describe("Run", func() {
droplet := sharedmocks.NewMockBuffer("some-droplet")
launcher := sharedmocks.NewMockBuffer("some-launcher")
sshpass := sharedmocks.NewMockBuffer("some-sshpass")
services := service.Services{"some": {{Name: "services"}}}
forwardedServices := service.Services{"some": {{Name: "forwarded-services"}}}
services := forge.Services{"some": {{Name: "services"}}}
forwardedServices := forge.Services{"some": {{Name: "forwarded-services"}}}
restart := make(<-chan time.Time)
watchDone := make(chan struct{})
health := make(chan string, 3)
forwardDone, forwardDoneCalls := sharedmocks.NewMockFunc()

forwardConfig := &service.ForwardConfig{
forwardConfig := &forge.ForwardDetails{
Host: "some-ssh-host",
}
localYML := &forge.LocalYML{
localYML := &app.LocalYML{
Applications: []*forge.AppConfig{
{Name: "some-other-app"},
{
Name: "some-app",
Env: map[string]string{"a": "b"},
Services: service.Services{"some": {{Name: "overwritten-services"}}},
Services: forge.Services{"some": {{Name: "overwritten-services"}}},
},
},
}
Expand All @@ -110,7 +110,7 @@ var _ = Describe("Run", func() {
Expect(config.AppName).To(Equal("some-app"))
Expect(config.Stack).To(Equal(LatestStack))
Expect(config.Color("some-text")).To(Equal(color.GreenString("some-text")))
Expect(config.ForwardConfig).To(Equal(forwardConfig))
Expect(config.Details).To(Equal(forwardConfig))
Expect(config.HostIP).To(Equal("0.0.0.0"))
Expect(config.HostPort).To(Equal("3000"))
Eventually(config.Wait).Should(Receive())
Expand Down
6 changes: 3 additions & 3 deletions cf/cmd/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"crypto/md5"
"flag"
"fmt"
"io"

"github.com/fatih/color"

"github.com/sclevine/forge"
"github.com/sclevine/forge/engine"
)
Expand All @@ -15,7 +15,7 @@ type Stage struct {
UI UI
Stager Stager
RemoteApp RemoteApp
LocalApp LocalApp
TarApp func(string) (io.ReadCloser, error)
FS FS
Help Help
Config Config
Expand Down Expand Up @@ -51,7 +51,7 @@ func (s *Stage) Run(args []string) error {
return err
}

appTar, err := s.LocalApp.Tar(options.app)
appTar, err := s.TarApp(options.app)
if err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions cf/cmd/stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/sclevine/cflocal/cf/cmd/mocks"
sharedmocks "github.com/sclevine/cflocal/mocks"
"github.com/sclevine/forge"
"github.com/sclevine/forge/app"
"github.com/sclevine/forge/engine"
"github.com/sclevine/forge/service"
)

var _ = Describe("Stage", func() {
Expand Down Expand Up @@ -45,7 +45,7 @@ var _ = Describe("Stage", func() {
UI: mockUI,
Stager: mockStager,
RemoteApp: mockRemoteApp,
LocalApp: mockLocalApp,
TarApp: mockLocalApp.Tar,
FS: mockFS,
Help: mockHelp,
Config: mockConfig,
Expand Down Expand Up @@ -74,13 +74,13 @@ var _ = Describe("Stage", func() {
droplet := sharedmocks.NewMockBuffer("some-droplet")
dropletFile := sharedmocks.NewMockBuffer("")

services := service.Services{"some": {{Name: "services"}}}
forwardedServices := service.Services{"some": {{Name: "forwarded-services"}}}
forwardConfig := &service.ForwardConfig{
services := forge.Services{"some": {{Name: "services"}}}
forwardedServices := forge.Services{"some": {{Name: "forwarded-services"}}}
forwardConfig := &forge.ForwardDetails{
Host: "some-ssh-host",
}

localYML := &forge.LocalYML{
localYML := &app.LocalYML{
Applications: []*forge.AppConfig{
{
Name: "some-other-app",
Expand All @@ -93,7 +93,7 @@ var _ = Describe("Stage", func() {
"some-other-buildpack-two",
},
Env: map[string]string{"a": "b"},
Services: service.Services{"some": {{Name: "overwritten-services"}}},
Services: forge.Services{"some": {{Name: "overwritten-services"}}},
},
},
}
Expand Down
Loading

0 comments on commit b987533

Please sign in to comment.