From 95bb2b4114934dffb05c43629ce3dec6ae951754 Mon Sep 17 00:00:00 2001 From: henderjm Date: Tue, 6 Mar 2018 15:36:44 +0000 Subject: [PATCH] Add Jumpbox support provided by BBL Newer versions of BoshBootLoader create directors private to the world and the only way to connect to them is through a provided Jumpbox * Rename package names to reflect repository. This is very confusing having references to old repository name. * Add Jumpbox url, ssh key and username to source configuration * Update dependency calls where function definitions have changed * Update README --- Dockerfile | 2 +- README.md | 8 ++- bosh/boshfakes/fake_director.go | 2 +- bosh/boshfakes/fake_runner.go | 65 +++++++++++++++--- bosh/cli_coordinator.go | 75 ++++++++++++++++----- bosh/command_runner.go | 23 +++++-- bosh/deployment_manifest_test.go | 2 +- bosh/director.go | 4 +- bosh/director_test.go | 10 +-- bosh/release.go | 2 +- bosh/release_test.go | 2 +- bosh/stemcell.go | 2 +- bosh/stemcell_test.go | 2 +- check/check_command.go | 4 +- check/check_command_test.go | 6 +- check/check_suite_test.go | 0 ci/tasks/build.sh | 2 +- ci/tasks/build.yml | 2 +- ci/tasks/unit-test.sh | 2 +- ci/tasks/unit-test.yml | 2 +- cmd/check/main.go | 12 ++-- cmd/in/main.go | 12 ++-- cmd/out/main.go | 14 ++-- concourse/in_request_test.go | 2 +- concourse/out_request_test.go | 2 +- concourse/source.go | 15 +++-- concourse/source_test.go | 16 +++-- concourse/version_test.go | 2 +- in/in_command.go | 4 +- in/in_command_test.go | 6 +- out/out_command.go | 6 +- out/out_command_test.go | 6 +- out/out_suite_test.go | 0 storage/storage_client.go | 4 +- storage/storage_client_test.go | 6 +- storage/storagefakes/fake_storage_client.go | 2 +- tools/glob_unfurler_test.go | 2 +- tools/tgz_file_detective_test.go | 2 +- 38 files changed, 226 insertions(+), 104 deletions(-) mode change 100644 => 100755 check/check_command.go mode change 100644 => 100755 check/check_command_test.go mode change 100644 => 100755 check/check_suite_test.go mode change 100644 => 100755 out/out_command.go mode change 100644 => 100755 out/out_command_test.go mode change 100644 => 100755 out/out_suite_test.go diff --git a/Dockerfile b/Dockerfile index eacc67a73..e2da57238 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM concourse/buildroot:base -MAINTAINER https://github.com/starkandwayne/bosh2-errand-resource +MAINTAINER https://github.com/cloudfoundry-community/bosh2-errand-resource ADD check /opt/resource/check ADD in /opt/resource/in diff --git a/README.md b/README.md index 28d69390b..a8e85e76c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A resource that will run an errand using the [BOSH CLI v2](https://bosh.io/docs/ ## Differences from original BOSH Deployment Resource -The original [BOSH Errand Resource](https://github.com/starkandwayne/bosh-errand-resource) +The original [BOSH Errand Resource](https://github.com/cloudfoundry-community/bosh-errand-resource) uses the Ruby CLI and does not support newer BOSH features (for example UAA auth). ### Breaking Changes @@ -21,7 +21,7 @@ resource_types: - name: bosh-errand type: docker-image source: - repository: starkandwayne/bosh2-errand-resource + repository: cloudfoundry-community/bosh2-errand-resource ``` ## Source Configuration @@ -33,6 +33,10 @@ resource_types: * `client_secret`: *Required.* The password or UAA client secret for the BOSH director. * `ca_cert`: *Optional.* CA certificate used to validate SSL connections to Director and UAA. If omitted, the director's certificate must be already trusted. +* `jumpbox_url`: *Optional.* The URL, including port, of the jumpbox. If set, `jumpbox_ssh_key` must also be set. If omitted, + the BOSH director will be dialed directly. +* `jumpbox_ssh_key`: *Optional.* The private key of the jumpbox. If set, `jumpbox_url` must also be set. +* `jumpbox_username`: *Optional.* The username for the jumpbox. If not set, will default to `jumpbox`. ### Example diff --git a/bosh/boshfakes/fake_director.go b/bosh/boshfakes/fake_director.go index c1ae207ce..52e05fb6b 100644 --- a/bosh/boshfakes/fake_director.go +++ b/bosh/boshfakes/fake_director.go @@ -4,7 +4,7 @@ package boshfakes import ( "sync" - "github.com/starkandwayne/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" ) type FakeDirector struct { diff --git a/bosh/boshfakes/fake_runner.go b/bosh/boshfakes/fake_runner.go index 4a6039ce8..548ef6849 100644 --- a/bosh/boshfakes/fake_runner.go +++ b/bosh/boshfakes/fake_runner.go @@ -1,10 +1,11 @@ -// This file was generated by counterfeiter +// Code generated by counterfeiter. DO NOT EDIT. package boshfakes import ( + "io" "sync" - "github.com/starkandwayne/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" ) type FakeRunner struct { @@ -16,21 +17,29 @@ type FakeRunner struct { executeReturns struct { result1 error } - ExecuteWithDefaultOverrideStub func(commandOpts interface{}, override func(interface{}) (interface{}, error)) error + executeReturnsOnCall map[int]struct { + result1 error + } + ExecuteWithDefaultOverrideStub func(commandOpts interface{}, override func(interface{}) (interface{}, error), writer io.Writer) error executeWithDefaultOverrideMutex sync.RWMutex executeWithDefaultOverrideArgsForCall []struct { commandOpts interface{} override func(interface{}) (interface{}, error) + writer io.Writer } executeWithDefaultOverrideReturns struct { result1 error } + executeWithDefaultOverrideReturnsOnCall map[int]struct { + result1 error + } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } func (fake *FakeRunner) Execute(commandOpts interface{}) error { fake.executeMutex.Lock() + ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] fake.executeArgsForCall = append(fake.executeArgsForCall, struct { commandOpts interface{} }{commandOpts}) @@ -39,6 +48,9 @@ func (fake *FakeRunner) Execute(commandOpts interface{}) error { if fake.ExecuteStub != nil { return fake.ExecuteStub(commandOpts) } + if specificReturn { + return ret.result1 + } return fake.executeReturns.result1 } @@ -61,16 +73,33 @@ func (fake *FakeRunner) ExecuteReturns(result1 error) { }{result1} } -func (fake *FakeRunner) ExecuteWithDefaultOverride(commandOpts interface{}, override func(interface{}) (interface{}, error)) error { +func (fake *FakeRunner) ExecuteReturnsOnCall(i int, result1 error) { + fake.ExecuteStub = nil + if fake.executeReturnsOnCall == nil { + fake.executeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.executeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeRunner) ExecuteWithDefaultOverride(commandOpts interface{}, override func(interface{}) (interface{}, error), writer io.Writer) error { fake.executeWithDefaultOverrideMutex.Lock() + ret, specificReturn := fake.executeWithDefaultOverrideReturnsOnCall[len(fake.executeWithDefaultOverrideArgsForCall)] fake.executeWithDefaultOverrideArgsForCall = append(fake.executeWithDefaultOverrideArgsForCall, struct { commandOpts interface{} override func(interface{}) (interface{}, error) - }{commandOpts, override}) - fake.recordInvocation("ExecuteWithDefaultOverride", []interface{}{commandOpts, override}) + writer io.Writer + }{commandOpts, override, writer}) + fake.recordInvocation("ExecuteWithDefaultOverride", []interface{}{commandOpts, override, writer}) fake.executeWithDefaultOverrideMutex.Unlock() if fake.ExecuteWithDefaultOverrideStub != nil { - return fake.ExecuteWithDefaultOverrideStub(commandOpts, override) + return fake.ExecuteWithDefaultOverrideStub(commandOpts, override, writer) + } + if specificReturn { + return ret.result1 } return fake.executeWithDefaultOverrideReturns.result1 } @@ -81,10 +110,10 @@ func (fake *FakeRunner) ExecuteWithDefaultOverrideCallCount() int { return len(fake.executeWithDefaultOverrideArgsForCall) } -func (fake *FakeRunner) ExecuteWithDefaultOverrideArgsForCall(i int) (interface{}, func(interface{}) (interface{}, error)) { +func (fake *FakeRunner) ExecuteWithDefaultOverrideArgsForCall(i int) (interface{}, func(interface{}) (interface{}, error), io.Writer) { fake.executeWithDefaultOverrideMutex.RLock() defer fake.executeWithDefaultOverrideMutex.RUnlock() - return fake.executeWithDefaultOverrideArgsForCall[i].commandOpts, fake.executeWithDefaultOverrideArgsForCall[i].override + return fake.executeWithDefaultOverrideArgsForCall[i].commandOpts, fake.executeWithDefaultOverrideArgsForCall[i].override, fake.executeWithDefaultOverrideArgsForCall[i].writer } func (fake *FakeRunner) ExecuteWithDefaultOverrideReturns(result1 error) { @@ -94,6 +123,18 @@ func (fake *FakeRunner) ExecuteWithDefaultOverrideReturns(result1 error) { }{result1} } +func (fake *FakeRunner) ExecuteWithDefaultOverrideReturnsOnCall(i int, result1 error) { + fake.ExecuteWithDefaultOverrideStub = nil + if fake.executeWithDefaultOverrideReturnsOnCall == nil { + fake.executeWithDefaultOverrideReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.executeWithDefaultOverrideReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeRunner) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() @@ -101,7 +142,11 @@ func (fake *FakeRunner) Invocations() map[string][][]interface{} { defer fake.executeMutex.RUnlock() fake.executeWithDefaultOverrideMutex.RLock() defer fake.executeWithDefaultOverrideMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeRunner) recordInvocation(key string, args []interface{}) { diff --git a/bosh/cli_coordinator.go b/bosh/cli_coordinator.go index dc49aced6..0ed7da043 100644 --- a/bosh/cli_coordinator.go +++ b/bosh/cli_coordinator.go @@ -2,10 +2,13 @@ package bosh import ( "bytes" + "errors" + "fmt" "io" "io/ioutil" + "os" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" boshcmd "github.com/cloudfoundry/bosh-cli/cmd" cmdconf "github.com/cloudfoundry/bosh-cli/cmd/config" @@ -15,19 +18,26 @@ import ( goflags "github.com/jessevdk/go-flags" ) +type Proxy interface { + Start(string, string, string) error + Addr() (string, error) +} + type CLICoordinator struct { source concourse.Source out io.Writer + proxy Proxy } -func NewCLICoordinator(source concourse.Source, out io.Writer) CLICoordinator { +func NewCLICoordinator(source concourse.Source, out io.Writer, proxy Proxy) CLICoordinator { return CLICoordinator{ source: source, out: out, + proxy: proxy, } } -func (c CLICoordinator) GlobalOpts() boshcmd.BoshOpts { +func (c CLICoordinator) GlobalOpts(proxyAddr string) boshcmd.BoshOpts { globalOpts := &boshcmd.BoshOpts{ NonInteractiveOpt: true, CACertOpt: boshcmd.CACertArg{Content: c.source.CACert}, @@ -37,39 +47,70 @@ func (c CLICoordinator) GlobalOpts() boshcmd.BoshOpts { DeploymentOpt: c.source.Deployment, } + if proxyAddr != "" { + proxyAddr = fmt.Sprintf("socks5://%s", proxyAddr) + os.Setenv("BOSH_ALL_PROXY", proxyAddr) + globalOpts.SSH.GatewayFlags.SOCKS5Proxy = proxyAddr + globalOpts.SCP.GatewayFlags.SOCKS5Proxy = proxyAddr + globalOpts.Logs.GatewayFlags.SOCKS5Proxy = proxyAddr + } + setDefaults(globalOpts) return *globalOpts } -func (c CLICoordinator) StreamingBasicDeps() boshcmd.BasicDeps { +func (c CLICoordinator) BasicDeps(writer io.Writer) boshcmd.BasicDeps { logger := nullLogger() - parentUI := boshui.NewPaddingUI(boshui.NewWriterUI(c.out, c.out, logger)) - - ui := boshui.NewWrappingConfUI(parentUI, logger) - return boshcmd.NewBasicDeps(ui, logger) -} - -func (c CLICoordinator) CapturedBasicDeps() boshcmd.BasicDeps { - byteWriter := bytes.NewBufferString("") - logger := nullLogger() - - parentUI := boshui.NewNonTTYUI(boshui.NewWriterUI(byteWriter, c.out, logger)) + if writer == nil { + writer = c.out + } + parentUI := boshui.NewPaddingUI(boshui.NewWriterUI(writer, writer, logger)) ui := boshui.NewWrappingConfUI(parentUI, logger) return boshcmd.NewBasicDeps(ui, logger) } func (c CLICoordinator) Director() (boshdir.Director, error) { - globalOpts := c.GlobalOpts() - deps := c.CapturedBasicDeps() + addr, err := c.StartProxy() + if err != nil { + return nil, fmt.Errorf("start proxy: %s", err) // untested + } + globalOpts := c.GlobalOpts(addr) + deps := c.BasicDeps(bytes.NewBufferString("")) config, _ := cmdconf.NewFSConfigFromPath(globalOpts.ConfigPathOpt, deps.FS) session := boshcmd.NewSessionFromOpts(globalOpts, config, deps.UI, true, true, deps.FS, deps.Logger) return session.Director() } +func (c CLICoordinator) StartProxy() (string, error) { + if c.source.JumpboxSSHKey == "" && c.source.JumpboxURL == "" { + return "", nil + } + + if c.source.JumpboxSSHKey != "" && c.source.JumpboxURL != "" { + addr, err := c.proxy.Addr() + if err == nil { + return addr, nil + } + + err = c.proxy.Start(c.source.JumpboxUsername, c.source.JumpboxSSHKey, c.source.JumpboxURL) + if err != nil { + panic(err) + } + + addr, err = c.proxy.Addr() + if err != nil { + panic(err) + } + return addr, nil + } + + return "", errors.New("Jumpbox URL and Jumpbox SSH Key are both required to use a jumpbox") +} + func nullLogger() boshlog.Logger { return boshlog.NewWriterLogger(boshlog.LevelInfo, ioutil.Discard, ioutil.Discard) } diff --git a/bosh/command_runner.go b/bosh/command_runner.go index 4454205c4..91d7ba68e 100644 --- a/bosh/command_runner.go +++ b/bosh/command_runner.go @@ -1,12 +1,16 @@ package bosh import ( + "fmt" + + "io" + boshcmd "github.com/cloudfoundry/bosh-cli/cmd" ) type Runner interface { Execute(commandOpts interface{}) error - ExecuteWithDefaultOverride(commandOpts interface{}, override func(interface{}) (interface{}, error)) error + ExecuteWithDefaultOverride(commandOpts interface{}, override func(interface{}) (interface{}, error), writer io.Writer) error } type CommandRunner struct { @@ -20,15 +24,22 @@ func NewCommandRunner(cliCoordinator CLICoordinator) CommandRunner { } func (c CommandRunner) Execute(commandOpts interface{}) error { - return c.ExecuteWithDefaultOverride(commandOpts, func(opts interface{}) (interface{}, error) { return opts, nil }) + return c.ExecuteWithDefaultOverride(commandOpts, func(opts interface{}) (interface{}, error) { return opts, nil }, nil) } -func (c CommandRunner) ExecuteWithDefaultOverride(commandOpts interface{}, override func(interface{}) (interface{}, error)) error { - deps := c.cliCoordinator.StreamingBasicDeps() - globalOpts := c.cliCoordinator.GlobalOpts() +func (c CommandRunner) ExecuteWithDefaultOverride(commandOpts interface{}, override func(interface{}) (interface{}, error), writer io.Writer) error { + deps := c.cliCoordinator.BasicDeps(writer) + + addr, err := c.cliCoordinator.StartProxy() + if err != nil { + return fmt.Errorf("start proxy: %s", err) + } + + globalOpts := c.cliCoordinator.GlobalOpts(addr) + setDefaults(commandOpts) - commandOpts, err := override(commandOpts) + commandOpts, err = override(commandOpts) if err != nil { return err } diff --git a/bosh/deployment_manifest_test.go b/bosh/deployment_manifest_test.go index c8b8d5543..952e5e72b 100644 --- a/bosh/deployment_manifest_test.go +++ b/bosh/deployment_manifest_test.go @@ -4,7 +4,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" ) var _ = Describe("DeploymentManifest", func() { diff --git a/bosh/director.go b/bosh/director.go index e1ad3be54..257ce55f9 100644 --- a/bosh/director.go +++ b/bosh/director.go @@ -5,7 +5,7 @@ import ( "fmt" "io/ioutil" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" boshcmd "github.com/cloudfoundry/bosh-cli/cmd" boshdir "github.com/cloudfoundry/bosh-cli/director" @@ -155,7 +155,7 @@ func (d BoshDirector) ExportReleases(targetDirectory string, releases []string) err = d.commandRunner.ExecuteWithDefaultOverride(&boshcmd.ExportReleaseOpts{ Args: boshcmd.ExportReleaseArgs{ReleaseSlug: releaseSlug, OSVersionSlug: osVersionSlug}, Directory: directory, - }, directoryFixFunction) + }, directoryFixFunction, nil) if err != nil { return fmt.Errorf("could not export release %s: %s", deploymentRelease.Name(), err) } diff --git a/bosh/director_test.go b/bosh/director_test.go index f030402b7..a49de822b 100644 --- a/bosh/director_test.go +++ b/bosh/director_test.go @@ -7,10 +7,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh/boshfakes" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" "github.com/cppforlife/go-patch/patch" - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/bosh/boshfakes" - "github.com/starkandwayne/bosh2-errand-resource/concourse" boshcmd "github.com/cloudfoundry/bosh-cli/cmd" boshdir "github.com/cloudfoundry/bosh-cli/director" @@ -248,7 +248,7 @@ var _ = Describe("BoshDirector", func() { Expect(commandRunner.ExecuteWithDefaultOverrideCallCount()).To(Equal(2)) - opts, optFunc := commandRunner.ExecuteWithDefaultOverrideArgsForCall(0) + opts, optFunc, _ := commandRunner.ExecuteWithDefaultOverrideArgsForCall(0) exportReleaseOpts, _ := opts.(*boshcmd.ExportReleaseOpts) Expect(string(exportReleaseOpts.Args.ReleaseSlug.Name())).To(Equal("cool-release")) Expect(string(exportReleaseOpts.Args.ReleaseSlug.Version())).To(Equal("123.45")) @@ -259,7 +259,7 @@ var _ = Describe("BoshDirector", func() { Expect(err).ToNot(HaveOccurred()) Expect(fixedOpts.(*boshcmd.ExportReleaseOpts).Directory.Path).To(Equal("/tmp/foo")) - opts, optFunc = commandRunner.ExecuteWithDefaultOverrideArgsForCall(1) + opts, optFunc, _ = commandRunner.ExecuteWithDefaultOverrideArgsForCall(1) exportReleaseOpts, _ = opts.(*boshcmd.ExportReleaseOpts) Expect(string(exportReleaseOpts.Args.ReleaseSlug.Name())).To(Equal("awesome-release")) Expect(string(exportReleaseOpts.Args.ReleaseSlug.Version())).To(Equal("987.65")) diff --git a/bosh/release.go b/bosh/release.go index f232ce149..457a7c8c9 100644 --- a/bosh/release.go +++ b/bosh/release.go @@ -3,7 +3,7 @@ package bosh import ( "fmt" - "github.com/starkandwayne/bosh2-errand-resource/tools" + "github.com/cloudfoundry-community/bosh2-errand-resource/tools" "gopkg.in/yaml.v2" ) diff --git a/bosh/release_test.go b/bosh/release_test.go index 7be857868..b2afd3d50 100644 --- a/bosh/release_test.go +++ b/bosh/release_test.go @@ -3,7 +3,7 @@ package bosh_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" ) var _ = Describe("Release", func() { diff --git a/bosh/stemcell.go b/bosh/stemcell.go index 79ad1e020..fda31a5ee 100644 --- a/bosh/stemcell.go +++ b/bosh/stemcell.go @@ -3,7 +3,7 @@ package bosh import ( "fmt" - "github.com/starkandwayne/bosh2-errand-resource/tools" + "github.com/cloudfoundry-community/bosh2-errand-resource/tools" "gopkg.in/yaml.v2" ) diff --git a/bosh/stemcell_test.go b/bosh/stemcell_test.go index 3fcf19f15..94b8efefc 100644 --- a/bosh/stemcell_test.go +++ b/bosh/stemcell_test.go @@ -3,7 +3,7 @@ package bosh_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" ) var _ = Describe("Stemcell", func() { diff --git a/check/check_command.go b/check/check_command.go old mode 100644 new mode 100755 index a956b71ad..43bd39548 --- a/check/check_command.go +++ b/check/check_command.go @@ -1,8 +1,8 @@ package check import ( - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" ) type CheckCommand struct { diff --git a/check/check_command_test.go b/check/check_command_test.go old mode 100644 new mode 100755 index afd0d8f29..7690b609c --- a/check/check_command_test.go +++ b/check/check_command_test.go @@ -6,9 +6,9 @@ import ( "errors" - "github.com/starkandwayne/bosh2-errand-resource/bosh/boshfakes" - "github.com/starkandwayne/bosh2-errand-resource/check" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh/boshfakes" + "github.com/cloudfoundry-community/bosh2-errand-resource/check" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" ) var _ = Describe("CheckCommand", func() { diff --git a/check/check_suite_test.go b/check/check_suite_test.go old mode 100644 new mode 100755 diff --git a/ci/tasks/build.sh b/ci/tasks/build.sh index e7ea88272..483d34529 100755 --- a/ci/tasks/build.sh +++ b/ci/tasks/build.sh @@ -7,7 +7,7 @@ export GOPATH="${PWD}/gopath" export PATH="${GOPATH}/bin:${PATH}" go get github.com/onsi/ginkgo/ginkgo -cd gopath/src/github.com/starkandwayne/bosh2-errand-resource +cd gopath/src/github.com/cloudfoundry-community/bosh2-errand-resource go build -o "$BUILT_BINARIES_DIR/out" ./cmd/out go build -o "$BUILT_BINARIES_DIR/in" ./cmd/in diff --git a/ci/tasks/build.yml b/ci/tasks/build.yml index bc4876144..81dd25891 100644 --- a/ci/tasks/build.yml +++ b/ci/tasks/build.yml @@ -10,7 +10,7 @@ image_resource: inputs: - name: bosh2-errand-resource-ci - name: bosh2-errand-resource - path: gopath/src/github.com/starkandwayne/bosh2-errand-resource + path: gopath/src/github.com/cloudfoundry-community/bosh2-errand-resource outputs: - name: built-binaries diff --git a/ci/tasks/unit-test.sh b/ci/tasks/unit-test.sh index 1b059e856..07259d418 100755 --- a/ci/tasks/unit-test.sh +++ b/ci/tasks/unit-test.sh @@ -6,6 +6,6 @@ export GOPATH="${PWD}/gopath" export PATH="${GOPATH}/bin:${PATH}" go get github.com/onsi/ginkgo/ginkgo -cd gopath/src/github.com/starkandwayne/bosh2-errand-resource +cd gopath/src/github.com/cloudfoundry-community/bosh2-errand-resource ginkgo -r -race -p -randomizeAllSpecs -randomizeSuites . diff --git a/ci/tasks/unit-test.yml b/ci/tasks/unit-test.yml index c0e9abe15..eb97a27a6 100644 --- a/ci/tasks/unit-test.yml +++ b/ci/tasks/unit-test.yml @@ -10,7 +10,7 @@ image_resource: inputs: - name: bosh2-errand-resource-ci - name: bosh2-errand-resource - path: gopath/src/github.com/starkandwayne/bosh2-errand-resource + path: gopath/src/github.com/cloudfoundry-community/bosh2-errand-resource run: path: bosh2-errand-resource-ci/ci/tasks/unit-test.sh diff --git a/cmd/check/main.go b/cmd/check/main.go index 84cfdc6fc..d3ec76f11 100644 --- a/cmd/check/main.go +++ b/cmd/check/main.go @@ -3,13 +3,15 @@ package main import ( "encoding/json" "fmt" + "log" "os" "io/ioutil" - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/check" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/check" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry/socks5-proxy" ) func main() { @@ -25,7 +27,9 @@ func main() { os.Exit(1) } - cliCoordinator := bosh.NewCLICoordinator(checkRequest.Source, os.Stderr) + hostKeyGetter := proxy.NewHostKey() + socks5Proxy := proxy.NewSocks5Proxy(hostKeyGetter, log.New(ioutil.Discard, "", log.LstdFlags)) + cliCoordinator := bosh.NewCLICoordinator(checkRequest.Source, os.Stderr, socks5Proxy) commandRunner := bosh.NewCommandRunner(cliCoordinator) cliDirector, err := cliCoordinator.Director() if err != nil { diff --git a/cmd/in/main.go b/cmd/in/main.go index 5850dae42..0f3cd9dfb 100644 --- a/cmd/in/main.go +++ b/cmd/in/main.go @@ -4,11 +4,13 @@ import ( "encoding/json" "fmt" "io/ioutil" + "log" "os" - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/in" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/in" + proxy "github.com/cloudfoundry/socks5-proxy" ) func main() { @@ -40,7 +42,9 @@ func main() { os.Exit(0) } - cliCoordinator := bosh.NewCLICoordinator(inRequest.Source, os.Stderr) + hostKeyGetter := proxy.NewHostKey() + socks5Proxy := proxy.NewSocks5Proxy(hostKeyGetter, log.New(ioutil.Discard, "", log.LstdFlags)) + cliCoordinator := bosh.NewCLICoordinator(inRequest.Source, os.Stderr, socks5Proxy) commandRunner := bosh.NewCommandRunner(cliCoordinator) cliDirector, err := cliCoordinator.Director() if err != nil { diff --git a/cmd/out/main.go b/cmd/out/main.go index 1e28fa97b..7eae0a4f9 100644 --- a/cmd/out/main.go +++ b/cmd/out/main.go @@ -3,14 +3,16 @@ package main import ( "encoding/json" "fmt" + "log" "os" "io/ioutil" - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/out" - "github.com/starkandwayne/bosh2-errand-resource/storage" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/out" + "github.com/cloudfoundry-community/bosh2-errand-resource/storage" + "github.com/cloudfoundry/socks5-proxy" ) func main() { @@ -36,7 +38,9 @@ func main() { os.Exit(1) } - cliCoordinator := bosh.NewCLICoordinator(outRequest.Source, os.Stderr) + hostKeyGetter := proxy.NewHostKey() + socks5Proxy := proxy.NewSocks5Proxy(hostKeyGetter, log.New(ioutil.Discard, "", log.LstdFlags)) + cliCoordinator := bosh.NewCLICoordinator(outRequest.Source, os.Stderr, socks5Proxy) commandRunner := bosh.NewCommandRunner(cliCoordinator) cliDirector, err := cliCoordinator.Director() if err != nil { diff --git a/concourse/in_request_test.go b/concourse/in_request_test.go index 111971563..7979ee5f8 100644 --- a/concourse/in_request_test.go +++ b/concourse/in_request_test.go @@ -3,7 +3,7 @@ package concourse_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" ) var _ = Describe("InRequest", func() { diff --git a/concourse/out_request_test.go b/concourse/out_request_test.go index 72bba0643..36de9f3fd 100644 --- a/concourse/out_request_test.go +++ b/concourse/out_request_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" ) var _ = Describe("NewOutRequest", func() { diff --git a/concourse/source.go b/concourse/source.go index 9efa1dbbc..a6e1f3856 100644 --- a/concourse/source.go +++ b/concourse/source.go @@ -13,12 +13,15 @@ import ( ) type Source struct { - Deployment string `json:"deployment,omitempty" yaml:"deployment"` - Client string `json:"client,omitempty" yaml:"client"` - ClientSecret string `json:"client_secret,omitempty" yaml:"client_secret"` - Target string `json:"target,omitempty" yaml:"target"` - CACert string `json:"ca_cert,omitempty" yaml:"ca_cert"` - VarsStore VarsStore `json:"vars_store,omitempty" yaml:"vars_store"` + Deployment string `json:"deployment,omitempty" yaml:"deployment"` + Client string `json:"client,omitempty" yaml:"client"` + ClientSecret string `json:"client_secret,omitempty" yaml:"client_secret"` + Target string `json:"target,omitempty" yaml:"target"` + CACert string `json:"ca_cert,omitempty" yaml:"ca_cert"` + JumpboxSSHKey string `json:"jumpbox_ssh_key,omitempty" yaml:"jumpbox_ssh_key"` + JumpboxURL string `json:"jumpbox_url,omitempty" yaml:"jumpbox_url"` + JumpboxUsername string `json:"jumpbox_username,omitempty" yaml:"jumpbox_username"` + VarsStore VarsStore `json:"vars_store,omitempty" yaml:"vars_store"` } type sourceRequest struct { diff --git a/concourse/source_test.go b/concourse/source_test.go index 68c49a5c5..bb8c206dc 100644 --- a/concourse/source_test.go +++ b/concourse/source_test.go @@ -5,9 +5,9 @@ import ( "io/ioutil" "path/filepath" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/concourse" ) var _ = Describe("NewDynamicSource", func() { @@ -45,6 +45,9 @@ var _ = Describe("NewDynamicSource", func() { "target": "director.example.com", "client": "original_client", "client_secret": "foobar", + "jumpbox_ssh_key": "some-ssh-key", + "jumpbox_url": "jumpbox.example.com", + "jumpbox_username": "some-user", "vars_store": { "provider": "gcs", "config": { @@ -84,10 +87,13 @@ var _ = Describe("NewDynamicSource", func() { Expect(err).NotTo(HaveOccurred()) Expect(source).To(Equal(concourse.Source{ - Deployment: "fileDeployment", - Target: "fileDirector.com", - Client: "original_client", - ClientSecret: "fileSecret", + Deployment: "fileDeployment", + Target: "fileDirector.com", + Client: "original_client", + ClientSecret: "fileSecret", + JumpboxSSHKey: "some-ssh-key", + JumpboxURL: "jumpbox.example.com", + JumpboxUsername: "some-user", VarsStore: concourse.VarsStore{ Provider: "fileProvider", Config: map[string]interface{}{ diff --git a/concourse/version_test.go b/concourse/version_test.go index 9fdcb6f81..d567b7392 100644 --- a/concourse/version_test.go +++ b/concourse/version_test.go @@ -1,7 +1,7 @@ package concourse_test import ( - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/in/in_command.go b/in/in_command.go index 6e19a907c..319f87c5b 100644 --- a/in/in_command.go +++ b/in/in_command.go @@ -5,8 +5,8 @@ import ( "io/ioutil" "path/filepath" - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" ) type InCommand struct { diff --git a/in/in_command_test.go b/in/in_command_test.go index c0e0ef039..c051773ea 100644 --- a/in/in_command_test.go +++ b/in/in_command_test.go @@ -8,9 +8,9 @@ import ( "io/ioutil" "path/filepath" - "github.com/starkandwayne/bosh2-errand-resource/bosh/boshfakes" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/in" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh/boshfakes" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/in" ) var _ = Describe("InCommand", func() { diff --git a/out/out_command.go b/out/out_command.go old mode 100644 new mode 100755 index abd49a5a5..df3e8006a --- a/out/out_command.go +++ b/out/out_command.go @@ -1,9 +1,9 @@ package out import ( - "github.com/starkandwayne/bosh2-errand-resource/bosh" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/storage" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/storage" ) type OutResponse struct { diff --git a/out/out_command_test.go b/out/out_command_test.go old mode 100644 new mode 100755 index 5bd63b2e6..676432e6f --- a/out/out_command_test.go +++ b/out/out_command_test.go @@ -4,9 +4,9 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/bosh/boshfakes" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/out" + "github.com/cloudfoundry-community/bosh2-errand-resource/bosh/boshfakes" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/out" ) var _ = Describe("OutCommand", func() { diff --git a/out/out_suite_test.go b/out/out_suite_test.go old mode 100644 new mode 100755 diff --git a/storage/storage_client.go b/storage/storage_client.go index 9165d3d11..82983e0b3 100644 --- a/storage/storage_client.go +++ b/storage/storage_client.go @@ -3,8 +3,8 @@ package storage import ( "encoding/json" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/gcp" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/gcp" ) type GCSConfig struct { diff --git a/storage/storage_client_test.go b/storage/storage_client_test.go index b7269bf71..d92aee3a8 100644 --- a/storage/storage_client_test.go +++ b/storage/storage_client_test.go @@ -3,9 +3,9 @@ package storage_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/concourse" - "github.com/starkandwayne/bosh2-errand-resource/gcp" - "github.com/starkandwayne/bosh2-errand-resource/storage" + "github.com/cloudfoundry-community/bosh2-errand-resource/concourse" + "github.com/cloudfoundry-community/bosh2-errand-resource/gcp" + "github.com/cloudfoundry-community/bosh2-errand-resource/storage" ) var _ = Describe("StorageClient", func() { diff --git a/storage/storagefakes/fake_storage_client.go b/storage/storagefakes/fake_storage_client.go index e4d42792b..1611032fa 100644 --- a/storage/storagefakes/fake_storage_client.go +++ b/storage/storagefakes/fake_storage_client.go @@ -4,7 +4,7 @@ package storagefakes import ( "sync" - "github.com/starkandwayne/bosh2-errand-resource/storage" + "github.com/cloudfoundry-community/bosh2-errand-resource/storage" ) type FakeStorageClient struct { diff --git a/tools/glob_unfurler_test.go b/tools/glob_unfurler_test.go index 5da06361e..298323ca2 100644 --- a/tools/glob_unfurler_test.go +++ b/tools/glob_unfurler_test.go @@ -6,7 +6,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/tools" + "github.com/cloudfoundry-community/bosh2-errand-resource/tools" ) var _ = Describe("GlobUnfurler", func() { diff --git a/tools/tgz_file_detective_test.go b/tools/tgz_file_detective_test.go index 6601d68a6..14ddf9fde 100644 --- a/tools/tgz_file_detective_test.go +++ b/tools/tgz_file_detective_test.go @@ -7,7 +7,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/starkandwayne/bosh2-errand-resource/tools" + "github.com/cloudfoundry-community/bosh2-errand-resource/tools" ) var _ = Describe("ReadTgzFile", func() {