From e7f09766a64a4e065d885acc509112a7a65f8fe8 Mon Sep 17 00:00:00 2001 From: tyler-ball Date: Mon, 9 Mar 2020 22:41:12 -0700 Subject: [PATCH 1/4] Pinning bundler to 1.17 because 2.x breaks our builds Signed-off-by: tyler-ball --- .expeditor/update_dep.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.expeditor/update_dep.sh b/.expeditor/update_dep.sh index 35e32a5fe..92c50e4dc 100755 --- a/.expeditor/update_dep.sh +++ b/.expeditor/update_dep.sh @@ -25,10 +25,10 @@ sleep 120 gem install $EXPEDITOR_GEM_NAME pushd components/gems -bundle install +bundle _1.17.3_ install tries=12 for (( i=1; i<=$tries; i+=1 )); do - bundle exec rake update + bundle _1.17.3_ exec rake update new_gem_included && break || sleep 20 if [ $i -eq $tries ]; then echo "Searching for '${EXPEDITOR_GEM_NAME} (${EXPEDITOR_VERSION})' ${i} times and did not find it" From b97eba36ac68fd3da02595850a9e91f77f7d85be Mon Sep 17 00:00:00 2001 From: tyler-ball Date: Mon, 9 Mar 2020 22:41:32 -0700 Subject: [PATCH 2/4] Updating to the latest go-libs Signed-off-by: tyler-ball --- components/main-chef-wrapper/go.mod | 5 ++++- components/main-chef-wrapper/go.sum | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/main-chef-wrapper/go.mod b/components/main-chef-wrapper/go.mod index 23b00ce6c..175108211 100644 --- a/components/main-chef-wrapper/go.mod +++ b/components/main-chef-wrapper/go.mod @@ -2,4 +2,7 @@ module github.com/chef/chef-workstation/components/main-chef-wrapper go 1.13 -require github.com/chef/go-libs v0.0.0-20191216182352-aa2fc405b05f +require ( + github.com/chef/go-libs v0.2.0 + github.com/pkg/errors v0.9.1 // indirect +) diff --git a/components/main-chef-wrapper/go.sum b/components/main-chef-wrapper/go.sum index dba073b9e..9cdf9b7c8 100644 --- a/components/main-chef-wrapper/go.sum +++ b/components/main-chef-wrapper/go.sum @@ -8,8 +8,10 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/chef/go-libs v0.0.0-20191216182352-aa2fc405b05f h1:kBujwkOBM7smuh1xCKHrUTdkZbNC0IH30zzDmTNYp8U= -github.com/chef/go-libs v0.0.0-20191216182352-aa2fc405b05f/go.mod h1:aGHwP5PXYdD0hVq+jodILnSqB/b04EhS/XCoqhE2PrA= +github.com/chef/go-libs v0.1.0 h1:ljwMsGhp0tjnsjn7g9aZSTQgjzjn+vfVZpkzJh0wmOQ= +github.com/chef/go-libs v0.1.0/go.mod h1:aGHwP5PXYdD0hVq+jodILnSqB/b04EhS/XCoqhE2PrA= +github.com/chef/go-libs v0.2.0 h1:9/YU0CFKpN8PvlVJGo8E3XfzPc+AU3lpmm/ziR54FrQ= +github.com/chef/go-libs v0.2.0/go.mod h1:aGHwP5PXYdD0hVq+jodILnSqB/b04EhS/XCoqhE2PrA= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -65,6 +67,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= From 381616daca930d1c07b114a69f40baf04f67bccb Mon Sep 17 00:00:00 2001 From: tyler-ball Date: Mon, 9 Mar 2020 22:45:42 -0700 Subject: [PATCH 3/4] Bumping deps to latest version Signed-off-by: tyler-ball --- components/gems/Gemfile.lock | 2 +- omnibus_overrides.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/gems/Gemfile.lock b/components/gems/Gemfile.lock index de24d2abf..90de7f3a3 100644 --- a/components/gems/Gemfile.lock +++ b/components/gems/Gemfile.lock @@ -624,7 +624,7 @@ GEM mixlib-cli (2.1.5) mixlib-config (3.0.6) tomlrb - mixlib-install (3.11.28) + mixlib-install (3.11.29) mixlib-shellout mixlib-versioning thor diff --git a/omnibus_overrides.rb b/omnibus_overrides.rb index dc4f2bec1..a911b08e1 100644 --- a/omnibus_overrides.rb +++ b/omnibus_overrides.rb @@ -4,9 +4,9 @@ # Expeditor takes that version, runs a script to replace it here and pushes a new # commit / build through. -override "chef-analyze", version: "0.1.76" +override "chef-analyze", version: "0.1.77" override "delivery-cli", version: "0.0.54" -override "chef-workstation-app", version: "v0.1.74" +override "chef-workstation-app", version: "v0.1.77" # /DO NOT MODIFY override :rubygems, version: "3.0.3" # rubygems ships its own bundler which may differ from bundler defined below and then we get double bundler which results in performance issues / CLI warnings. Make sure these versions match before bumping either. From 53a4d512068896ac749215361b157a42cb2b82a6 Mon Sep 17 00:00:00 2001 From: tyler-ball Date: Mon, 9 Mar 2020 22:49:22 -0700 Subject: [PATCH 4/4] Must remember to vendor go deps Signed-off-by: tyler-ball --- .../github.com/chef/go-libs/config/config.go | 19 ++++++ .../chef/go-libs/config/dist_gen.go | 20 +++++++ .../github.com/chef/go-libs/config/errors.go | 35 ++++++----- .../github.com/chef/go-libs/config/finder.go | 2 +- .../github.com/chef/go-libs/config/global.go | 27 +++++++++ .../chef/go-libs/config/workstation.go | 2 +- .../chef/go-libs/featflag/dist_gen.go | 20 +++++++ .../chef/go-libs/featflag/features.go | 37 ++++++------ .../chef/go-libs/featflag/global.go | 27 +++++++++ .../vendor/github.com/pkg/errors/.travis.yml | 11 +--- .../vendor/github.com/pkg/errors/Makefile | 44 ++++++++++++++ .../vendor/github.com/pkg/errors/README.md | 11 +++- .../vendor/github.com/pkg/errors/errors.go | 8 ++- .../vendor/github.com/pkg/errors/go113.go | 38 ++++++++++++ .../vendor/github.com/pkg/errors/stack.go | 58 ++++++++++++++----- .../main-chef-wrapper/vendor/modules.txt | 4 +- 16 files changed, 301 insertions(+), 62 deletions(-) create mode 100644 components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/dist_gen.go create mode 100644 components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/global.go create mode 100644 components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/dist_gen.go create mode 100644 components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/global.go create mode 100644 components/main-chef-wrapper/vendor/github.com/pkg/errors/Makefile create mode 100644 components/main-chef-wrapper/vendor/github.com/pkg/errors/go113.go diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/config.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/config.go index 88a7fc375..aa3338d15 100644 --- a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/config.go +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/config.go @@ -15,6 +15,25 @@ // limitations under the License. // +// An abstraction of the Chef Workstation configuration file (config.toml). +// +// Basic usage +// +// This example is loading the Chef Workstation configuration file located by default at +// $HOME/.chef-workstation/config.toml and printing the log level: +// package main +// +// import "github.com/chef/go-libs/config" +// +// func main() { +// cfg, err := config.New() +// if err != nil { +// fmt.Println("unable to read the config", err) +// } +// +// fmt.Println("the log level of my config is: ", cfg.Log.Level) +// } +// package config import ( diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/dist_gen.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/dist_gen.go new file mode 100644 index 000000000..e417ff95b --- /dev/null +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/dist_gen.go @@ -0,0 +1,20 @@ +// +// Copyright 2020 Chef Software, Inc. +// Author: Salim Afiune +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package config + +//go:generate go run github.com/chef/go-libs/distgen global.go config diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/errors.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/errors.go index 6ee93d884..571641cfe 100644 --- a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/errors.go +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/errors.go @@ -17,33 +17,38 @@ package config +import "fmt" + // // The intend of this file is to have a single place where we can easily // visualize the list of all error messages that we present to users. // -const ( - UserConfigTomlNotFoundErr = ` - ` + DefaultChefWSUserConfigFile + ` file not found. (default: $HOME/.chef-workstation/` + DefaultChefWSUserConfigFile + `) +var ( + UserConfigTomlNotFoundErr = fmt.Sprintf(` + %[1]s file not found. (default: $HOME/%[2]s/%[1]s) setup your local configuration file by following this documentation: - https://www.chef.sh/docs/reference/config/ -` - UserConfigTomlMalformedErr = ` - unable to parse ` + DefaultChefWSUserConfigFile + ` file. +`, DefaultChefWSUserConfigFile, WorkstationDir) + + UserConfigTomlMalformedErr = fmt.Sprintf(` + unable to parse %s file. verify the format of the configuration file by following this documentation: - https://www.chef.sh/docs/reference/config/ -` - AppConfigTomlNotFoundErr = ` - ` + DefaultChefWSAppConfigFile + ` file not found. (default: $HOME/.chef-workstation/` + DefaultChefWSAppConfigFile + `) +`, DefaultChefWSUserConfigFile) + + AppConfigTomlNotFoundErr = fmt.Sprintf(` + %[1]s file not found. (default: $HOME/%[2]s/%[1]s) + + verify that the %[3]s App is runnig on your local workstation. +`, DefaultChefWSUserConfigFile, WorkstationDir, WorkstationProduct) - verify that the Chef Workstation App is runnig on your local workstation. -` - AppConfigTomlMalformedErr = ` - unable to parse ` + DefaultChefWSAppConfigFile + ` file. + AppConfigTomlMalformedErr = fmt.Sprintf(` + unable to parse %s file. - there must be a problem with the Chef Workstation App, verify the format of the configuration by following this documentation: + there must be a problem with the %s App, verify the format of the configuration by following this documentation: - https://www.chef.sh/docs/reference/config/ -` +`, DefaultChefWSAppConfigFile, WorkstationProduct) ) diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/finder.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/finder.go index 5eb5646a7..8c22028bb 100644 --- a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/finder.go +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/finder.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" ) -const DefaultChefDirectory = ".chef" +const DefaultChefDirectory = UserConfDir // finds the user configuration file (default .chef-workstation/config.toml) inside the // current directory and recursively, plus inside the $HOME directory diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/global.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/global.go new file mode 100644 index 000000000..64e5c9694 --- /dev/null +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/global.go @@ -0,0 +1,27 @@ +// Code generated by go generate; DO NOT EDIT. +// +// file generated at: 2020-01-28 22:30:38.4258058 +0000 UTC m=+0.403111301 +// using data from: https://raw.github.com/chef/go-libs/master/distgen/glob_dist.json +// and generator: https://github.com/chef/go-libs/distgen +// + +package config + +const ( + ApplyExec = "chef-apply" + AutomateProduct = "Chef Automate" + ClientExec = "chef-client" + ClientProduct = "Chef Infra Client" + CompanyName = "Chef Software" + DirSuffix = "chef" + DocsWebsite = "https://docs.chef.io" + MainWebsite = "https://chef.io" + ServerProduct = "Chef Infra Server" + ShellExec = "chef-shell" + SoloExec = "chef-solo" + SoloProduct = "Chef Infra Solo" + UserConfDir = ".chef" + WorkstationDir = ".chef-workstation" + WorkstationProduct = "Chef Workstation" + ZeroExec = "chef-zero" +) diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/workstation.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/workstation.go index bd1c2d276..08b6bc148 100644 --- a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/workstation.go +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/config/workstation.go @@ -25,7 +25,7 @@ import ( ) const ( - DefaultChefWorkstationDirectory = ".chef-workstation" + DefaultChefWorkstationDirectory = WorkstationDir DefaultChefWSUserConfigFile = "config.toml" DefaultChefWSAppConfigFile = ".app-managed-config.toml" ) diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/dist_gen.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/dist_gen.go new file mode 100644 index 000000000..d93074626 --- /dev/null +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/dist_gen.go @@ -0,0 +1,20 @@ +// +// Copyright 2020 Chef Software, Inc. +// Author: Salim Afiune +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package featflag + +//go:generate go run github.com/chef/go-libs/distgen global.go featflag diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/features.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/features.go index 094ed29e3..9fc3f4773 100644 --- a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/features.go +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/features.go @@ -15,6 +15,25 @@ // limitations under the License. // +// An abstraction to manipulate feature flags through environment variables +// and a configuration file. By default it contains global flags that can be +// used in multiple go packages. +// +// Global Feature Flag +// +// This example is using a predefined global feature flag: +// if featflag.ChefFeatAnalyze.Enabled() { +// // the analyze feature is enabled, act upon it +// } +// +// Define A Local Feature Flag +// +// This example is defining a local feature flag: +// chefFeatXYZ := featflag.New("CHEF_FEAT_XYZ", "xyz") +// if chefFeatXYZ.Enabled() { +// // the XYZ feature is enabled, act upon it +// } +// package featflag import ( @@ -25,24 +44,6 @@ import ( "github.com/chef/go-libs/config" ) -// this go library is an abstraction that manipulates feature flags through -// environment variables and a configuration file, by default it contains -// global flags that can be used in multiple go packages. -// -// example 1: use a global feature flag -// ```go -// if featflag.ChefFeatAnalyze.Enabled() { -// // the analyze feature is enabled, act upon it -// } -// ``` -// -// example 2: define a local feature flag -// ```go -// chefFeatXYZ := featflag.New("CHEF_FEAT_XYZ", "xyz") -// if chefFeatXYZ.Enabled() { -// // the XYZ feature is enabled, act upon it -// } -// ``` type Feature struct { // the key associated to the feature flag defined inside the configuration file (config.toml) // diff --git a/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/global.go b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/global.go new file mode 100644 index 000000000..9275e89b8 --- /dev/null +++ b/components/main-chef-wrapper/vendor/github.com/chef/go-libs/featflag/global.go @@ -0,0 +1,27 @@ +// Code generated by go generate; DO NOT EDIT. +// +// file generated at: 2020-01-28 22:30:41.8092658 +0000 UTC m=+0.108647001 +// using data from: https://raw.github.com/chef/go-libs/master/distgen/glob_dist.json +// and generator: https://github.com/chef/go-libs/distgen +// + +package featflag + +const ( + ApplyExec = "chef-apply" + AutomateProduct = "Chef Automate" + ClientExec = "chef-client" + ClientProduct = "Chef Infra Client" + CompanyName = "Chef Software" + DirSuffix = "chef" + DocsWebsite = "https://docs.chef.io" + MainWebsite = "https://chef.io" + ServerProduct = "Chef Infra Server" + ShellExec = "chef-shell" + SoloExec = "chef-solo" + SoloProduct = "Chef Infra Solo" + UserConfDir = ".chef" + WorkstationDir = ".chef-workstation" + WorkstationProduct = "Chef Workstation" + ZeroExec = "chef-zero" +) diff --git a/components/main-chef-wrapper/vendor/github.com/pkg/errors/.travis.yml b/components/main-chef-wrapper/vendor/github.com/pkg/errors/.travis.yml index d4b92663b..9159de03e 100644 --- a/components/main-chef-wrapper/vendor/github.com/pkg/errors/.travis.yml +++ b/components/main-chef-wrapper/vendor/github.com/pkg/errors/.travis.yml @@ -1,15 +1,10 @@ language: go go_import_path: github.com/pkg/errors go: - - 1.4.x - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - 1.11.x + - 1.12.x + - 1.13.x - tip script: - - go test -v ./... + - make check diff --git a/components/main-chef-wrapper/vendor/github.com/pkg/errors/Makefile b/components/main-chef-wrapper/vendor/github.com/pkg/errors/Makefile new file mode 100644 index 000000000..ce9d7cded --- /dev/null +++ b/components/main-chef-wrapper/vendor/github.com/pkg/errors/Makefile @@ -0,0 +1,44 @@ +PKGS := github.com/pkg/errors +SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) +GO := go + +check: test vet gofmt misspell unconvert staticcheck ineffassign unparam + +test: + $(GO) test $(PKGS) + +vet: | test + $(GO) vet $(PKGS) + +staticcheck: + $(GO) get honnef.co/go/tools/cmd/staticcheck + staticcheck -checks all $(PKGS) + +misspell: + $(GO) get github.com/client9/misspell/cmd/misspell + misspell \ + -locale GB \ + -error \ + *.md *.go + +unconvert: + $(GO) get github.com/mdempsky/unconvert + unconvert -v $(PKGS) + +ineffassign: + $(GO) get github.com/gordonklaus/ineffassign + find $(SRCDIRS) -name '*.go' | xargs ineffassign + +pedantic: check errcheck + +unparam: + $(GO) get mvdan.cc/unparam + unparam ./... + +errcheck: + $(GO) get github.com/kisielk/errcheck + errcheck $(PKGS) + +gofmt: + @echo Checking code is gofmted + @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" diff --git a/components/main-chef-wrapper/vendor/github.com/pkg/errors/README.md b/components/main-chef-wrapper/vendor/github.com/pkg/errors/README.md index 6483ba2af..54dfdcb12 100644 --- a/components/main-chef-wrapper/vendor/github.com/pkg/errors/README.md +++ b/components/main-chef-wrapper/vendor/github.com/pkg/errors/README.md @@ -41,11 +41,18 @@ default: [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). +## Roadmap + +With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: + +- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) +- 1.0. Final release. + ## Contributing -We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. +Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. -Before proposing a change, please discuss your change by raising an issue. +Before sending a PR, please discuss your change by raising an issue. ## License diff --git a/components/main-chef-wrapper/vendor/github.com/pkg/errors/errors.go b/components/main-chef-wrapper/vendor/github.com/pkg/errors/errors.go index 7421f326f..161aea258 100644 --- a/components/main-chef-wrapper/vendor/github.com/pkg/errors/errors.go +++ b/components/main-chef-wrapper/vendor/github.com/pkg/errors/errors.go @@ -82,7 +82,7 @@ // // if err, ok := err.(stackTracer); ok { // for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d", f) +// fmt.Printf("%+s:%d\n", f, f) // } // } // @@ -159,6 +159,9 @@ type withStack struct { func (w *withStack) Cause() error { return w.error } +// Unwrap provides compatibility for Go 1.13 error chains. +func (w *withStack) Unwrap() error { return w.error } + func (w *withStack) Format(s fmt.State, verb rune) { switch verb { case 'v': @@ -241,6 +244,9 @@ type withMessage struct { func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } func (w *withMessage) Cause() error { return w.cause } +// Unwrap provides compatibility for Go 1.13 error chains. +func (w *withMessage) Unwrap() error { return w.cause } + func (w *withMessage) Format(s fmt.State, verb rune) { switch verb { case 'v': diff --git a/components/main-chef-wrapper/vendor/github.com/pkg/errors/go113.go b/components/main-chef-wrapper/vendor/github.com/pkg/errors/go113.go new file mode 100644 index 000000000..be0d10d0c --- /dev/null +++ b/components/main-chef-wrapper/vendor/github.com/pkg/errors/go113.go @@ -0,0 +1,38 @@ +// +build go1.13 + +package errors + +import ( + stderrors "errors" +) + +// Is reports whether any error in err's chain matches target. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error is considered to match a target if it is equal to that target or if +// it implements a method Is(error) bool such that Is(target) returns true. +func Is(err, target error) bool { return stderrors.Is(err, target) } + +// As finds the first error in err's chain that matches target, and if so, sets +// target to that error value and returns true. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error matches target if the error's concrete value is assignable to the value +// pointed to by target, or if the error has a method As(interface{}) bool such that +// As(target) returns true. In the latter case, the As method is responsible for +// setting target. +// +// As will panic if target is not a non-nil pointer to either a type that implements +// error, or to any interface type. As returns false if err is nil. +func As(err error, target interface{}) bool { return stderrors.As(err, target) } + +// Unwrap returns the result of calling the Unwrap method on err, if err's +// type contains an Unwrap method returning error. +// Otherwise, Unwrap returns nil. +func Unwrap(err error) error { + return stderrors.Unwrap(err) +} diff --git a/components/main-chef-wrapper/vendor/github.com/pkg/errors/stack.go b/components/main-chef-wrapper/vendor/github.com/pkg/errors/stack.go index 2874a048c..779a8348f 100644 --- a/components/main-chef-wrapper/vendor/github.com/pkg/errors/stack.go +++ b/components/main-chef-wrapper/vendor/github.com/pkg/errors/stack.go @@ -5,10 +5,13 @@ import ( "io" "path" "runtime" + "strconv" "strings" ) // Frame represents a program counter inside a stack frame. +// For historical reasons if Frame is interpreted as a uintptr +// its value represents the program counter + 1. type Frame uintptr // pc returns the program counter for this frame; @@ -37,6 +40,15 @@ func (f Frame) line() int { return line } +// name returns the name of this function, if known. +func (f Frame) name() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + return fn.Name() +} + // Format formats the frame according to the fmt.Formatter interface. // // %s source file @@ -54,22 +66,16 @@ func (f Frame) Format(s fmt.State, verb rune) { case 's': switch { case s.Flag('+'): - pc := f.pc() - fn := runtime.FuncForPC(pc) - if fn == nil { - io.WriteString(s, "unknown") - } else { - file, _ := fn.FileLine(pc) - fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) - } + io.WriteString(s, f.name()) + io.WriteString(s, "\n\t") + io.WriteString(s, f.file()) default: io.WriteString(s, path.Base(f.file())) } case 'd': - fmt.Fprintf(s, "%d", f.line()) + io.WriteString(s, strconv.Itoa(f.line())) case 'n': - name := runtime.FuncForPC(f.pc()).Name() - io.WriteString(s, funcname(name)) + io.WriteString(s, funcname(f.name())) case 'v': f.Format(s, 's') io.WriteString(s, ":") @@ -77,6 +83,16 @@ func (f Frame) Format(s fmt.State, verb rune) { } } +// MarshalText formats a stacktrace Frame as a text string. The output is the +// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. +func (f Frame) MarshalText() ([]byte, error) { + name := f.name() + if name == "unknown" { + return []byte(name), nil + } + return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil +} + // StackTrace is stack of Frames from innermost (newest) to outermost (oldest). type StackTrace []Frame @@ -94,16 +110,30 @@ func (st StackTrace) Format(s fmt.State, verb rune) { switch { case s.Flag('+'): for _, f := range st { - fmt.Fprintf(s, "\n%+v", f) + io.WriteString(s, "\n") + f.Format(s, verb) } case s.Flag('#'): fmt.Fprintf(s, "%#v", []Frame(st)) default: - fmt.Fprintf(s, "%v", []Frame(st)) + st.formatSlice(s, verb) } case 's': - fmt.Fprintf(s, "%s", []Frame(st)) + st.formatSlice(s, verb) + } +} + +// formatSlice will format this StackTrace into the given buffer as a slice of +// Frame, only valid when called with '%s' or '%v'. +func (st StackTrace) formatSlice(s fmt.State, verb rune) { + io.WriteString(s, "[") + for i, f := range st { + if i > 0 { + io.WriteString(s, " ") + } + f.Format(s, verb) } + io.WriteString(s, "]") } // stack represents a stack of program counters. diff --git a/components/main-chef-wrapper/vendor/modules.txt b/components/main-chef-wrapper/vendor/modules.txt index 9ffc973b8..b1b53ea82 100644 --- a/components/main-chef-wrapper/vendor/modules.txt +++ b/components/main-chef-wrapper/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml -# github.com/chef/go-libs v0.0.0-20191216182352-aa2fc405b05f +# github.com/chef/go-libs v0.2.0 github.com/chef/go-libs/config github.com/chef/go-libs/featflag -# github.com/pkg/errors v0.8.1 +# github.com/pkg/errors v0.9.1 github.com/pkg/errors