From a2a4c6ee2775b7d960ef2578d82c6d0bd611f601 Mon Sep 17 00:00:00 2001 From: Mark James Hender Date: Fri, 10 Aug 2018 13:31:20 +0100 Subject: [PATCH] Add option to skip check [Fixes #53] Signed-off-by: Akshay Mankar --- README.md | 1 + cmd/check/main.go | 47 ++++++++++++++++++++++++++------------------- concourse/source.go | 1 + 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d865951a9..c7ab0575e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ resource_types: 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`. +* `skip_check`: *Optional* Setting this will avoid failing checks when using this resource in dynamic configuration. If not set, will default to `false`. * `vars_store`: *Optional.* Configuration for a persisted variables store. Currently only the Google Cloud Storage (GCS) provider is supported. `json_key` must be the the JSON key for your service account. Example: diff --git a/cmd/check/main.go b/cmd/check/main.go index ceaf533d2..fa90a313b 100644 --- a/cmd/check/main.go +++ b/cmd/check/main.go @@ -27,28 +27,35 @@ func main() { os.Exit(1) } - 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 { - fmt.Fprint(os.Stderr, err) - os.Exit(1) - } + var checkResponse []concourse.Version - director := bosh.NewBoshDirector( - checkRequest.Source, - commandRunner, - cliDirector, - os.Stderr, - ) + if checkRequest.Source.SkipCheck { + checkResponse = []concourse.Version{} + } else { - checkCommand := check.NewCheckCommand(director) - checkResponse, err := checkCommand.Run(checkRequest) - if err != nil { - fmt.Fprint(os.Stderr, err) - os.Exit(1) + 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 { + fmt.Fprint(os.Stderr, err) + os.Exit(1) + } + + director := bosh.NewBoshDirector( + checkRequest.Source, + commandRunner, + cliDirector, + os.Stderr, + ) + + checkCommand := check.NewCheckCommand(director) + checkResponse, err = checkCommand.Run(checkRequest) + if err != nil { + fmt.Fprint(os.Stderr, err) + os.Exit(1) + } } concourseOutputFormatted, err := json.MarshalIndent(checkResponse, "", " ") diff --git a/concourse/source.go b/concourse/source.go index a6e1f3856..34a5c0206 100644 --- a/concourse/source.go +++ b/concourse/source.go @@ -22,6 +22,7 @@ type Source struct { 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"` + SkipCheck bool `json:"skip_check,omitempty" yaml:"skip_check"` } type sourceRequest struct {