diff --git a/README.md b/README.md index b91e3c6..927a761 100644 --- a/README.md +++ b/README.md @@ -113,11 +113,14 @@ Usage: Available Commands: chase chase is used for auditing projects with OSS Index + config Setup credentials to use when connecting to services help Help about any command iq iq is used for auditing your projects with Nexus IQ Server Flags: - -h, --help help for ahab + -h, --help help for ahab + -t, --token string Specify your OSS Index API Token + -u, --username string Specify your OSS Index Username Use "ahab [command] --help" for more information about a command. ``` @@ -125,19 +128,9 @@ Use "ahab [command] --help" for more information about a command. #### OSS Index usage ``` -$ ahab chase - ______ __ __ -/\ _ \ /\ \ /\ \ -\ \ \L\ \ \ \ \___ __ \ \ \____ - \ \ __ \ \ \ _ `\ /'__`\ \ \ '__`\ - \ \ \/\ \ \ \ \ \ \ /\ \L\.\_ \ \ \L\ \ - \ \_\ \_\ \ \_\ \_\\ \__/.\_\ \ \_,__/ - \/_/\/_/ \/_/\/_/ \/__/\/_/ \/___/ - _ _ _ _ - /_) /_` _ _ _ _/_ _ _ (/ /_` _ . _ _ _/ _ -/_) /_/ ._/ /_// //_|/ /_/ /_//_' (_X / / / /_'/ //_/ _\ - _/ _/ / -Ahab version: development +$ ahab chase -h +chase is used for auditing projects with OSS Index + Usage: ahab chase [flags] @@ -145,7 +138,9 @@ Examples: dpkg-query --show --showformat='${Package} ${Version}\n' | ./ahab chase yum list installed | ./ahab chase + dnf list installed | ./ahab chase apk info -vv | sort | ./ahab chase + Flags: -v, -- count Set log level, higher is more verbose @@ -158,9 +153,11 @@ Flags: --os string Specify a value for the operating system type you want to scan (alpine, debian, fedora). Useful if autodetection fails and/or you want to explicitly set it. (DEPRECATED: use package-manager) --output string Specify the output type you want (json, text, csv) (default "text") --package-manager string Specify package manager type you want to scan (apk, dnf, dpkg or yum). Useful if autodetection fails and/or you want to explicitly set it. - --quiet Quiet removes the header from being printed - --token string Specify your OSS Index API Token - --user string Specify your OSS Index Username + --quiet Quiet removes the header from being printed (default true) + +Global Flags: + -t, --token string Specify your OSS Index API Token + -u, --username string Specify your OSS Index Username ``` #### Exclude vulnerabilities @@ -204,43 +201,36 @@ CVN-543 until=2018-02-12 #Waiting on release from third party. Should be out bef #### Nexus IQ Server Usage ``` -$ ahab iq - ______ __ __ -/\ _ \ /\ \ /\ \ -\ \ \L\ \ \ \ \___ __ \ \ \____ - \ \ __ \ \ \ _ `\ /'__`\ \ \ '__`\ - \ \ \/\ \ \ \ \ \ \ /\ \L\.\_ \ \ \L\ \ - \ \_\ \_\ \ \_\ \_\\ \__/.\_\ \ \_,__/ - \/_/\/_/ \/_/\/_/ \/__/\/_/ \/___/ - _ _ _ _ - /_) /_` _ _ _ _/_ _ _ (/ /_` _ . _ _ _/ _ -/_) /_/ ._/ /_// //_|/ /_/ /_//_' (_X / / / /_'/ //_/ _\ - _/ _/ / -Ahab version: development +$ ahab iq -h +iq is used for auditing your projects with Nexus IQ Server + Usage: ahab iq [flags] Examples: - dpkg-query --show --showformat='${Package} ${Version}\n' | ./ahab iq --application testapp - yum list installed | ./ahab iq --application testapp - apk info -vv | sort | ./ahab iq --application testapp - + dpkg-query --show --showformat='${Package} ${Version}\n' | ./ahab iq --iq-application testapp + yum list installed | ./ahab iq --iq-application testapp + dnf list installed | ./ahab iq --iq-application testapp + apk info -vv | sort | ./ahab iq --iq-application testapp + Flags: - -v, -- count Set log level, higher is more verbose - --clean-cache Flag to clean the database cache for OSS Index - -e, --exclude-vulnerability CveListFlag Comma separated list of CVEs to exclude (default []) - -x, --exclude-vulnerability-file string Path to a file containing newline separated CVEs to be excluded (default "./.ahab-ignore") - -h, --help help for chase - --loud Specify if you want non vulnerable packages included in your output - --no-color Specify if you want no color in your results - --os string Specify a value for the operating system type you want to scan (alpine, debian, fedora). Useful if autodetection fails and/or you want to explicitly set it. (DEPRECATED: use package-manager) - --output string Specify the output type you want (json, text, csv) (default "text") - --package-manager string Specify package manager type you want to scan (apk, dnf, dpkg or yum). Useful if autodetection fails and/or you want to explicitly set it. - --quiet Quiet removes the header from being printed - --token string Specify your OSS Index API Token - --user string Specify your OSS Index Username + -v, -- count Set log level, higher is more verbose + -h, --help help for iq + -a, --iq-application string Specify public application ID for request (required) + -x, --iq-server-url string Specify Nexus IQ Server URL (default "http://localhost:8070") + -s, --iq-stage string Specify stage for application (default "develop") + -k, --iq-token string Specify Nexus IQ Token/Password for request (default "admin123") + -l, --iq-username string Specify Nexus IQ Username for request (default "admin") + --max-retries int Specify maximum number of tries to poll Nexus IQ Server (default 300) + --os string Specify a value for the operating system type you want to scan (alpine, debian, fedora). Useful if autodetection fails and/or you want to explicitly set it. (DEPRECATED: use package-manager) + --package-manager string Specify package manager type you want to scan (apk, dnf, dpkg or yum). Useful if autodetection fails and/or you want to explicitly set it. + --quiet Quiet removes the header from being printed (default true) + +Global Flags: + -t, --token string Specify your OSS Index API Token + -u, --username string Specify your OSS Index Username ``` ## Why Ahab? diff --git a/audit/audit.go b/audit/audit.go index a423793..6aaaa4a 100644 --- a/audit/audit.go +++ b/audit/audit.go @@ -158,6 +158,7 @@ func outputText(noColor bool, loud bool, projects []types.Coordinate) (int, stri t.AppendSeparator() t.AppendRow([]interface{}{"Vulnerable Dependencies", au.Bold(au.Red(strconv.Itoa(len(vulnerablePackages))))}) sb.WriteString(t.Render()) + sb.WriteString("\n") return len(vulnerablePackages), sb.String(), nil } diff --git a/cmd/chase.go b/cmd/chase.go index e565555..8947eb2 100644 --- a/cmd/chase.go +++ b/cmd/chase.go @@ -19,6 +19,9 @@ package cmd import ( "bufio" "fmt" + "github.com/sonatype-nexus-community/go-sona-types/configuration" + "github.com/spf13/pflag" + "github.com/spf13/viper" "os" "regexp" "strings" @@ -28,6 +31,7 @@ import ( "github.com/sirupsen/logrus" "github.com/sonatype-nexus-community/ahab/audit" "github.com/sonatype-nexus-community/ahab/buildversion" + "github.com/sonatype-nexus-community/ahab/internal/customerrors" "github.com/sonatype-nexus-community/ahab/logger" "github.com/sonatype-nexus-community/ahab/packages" "github.com/sonatype-nexus-community/ahab/parse" @@ -56,8 +60,10 @@ func (cve *CveListFlag) Set(value string) error { func (cve *CveListFlag) Type() string { return "CveListFlag" } var ( + cfgFile string packageManager string cleanCache bool + ossIndexURL string ossIndexUser string ossIndexToken string output string @@ -78,11 +84,9 @@ func init() { pf.StringVar(&packageManager, "os", "", "Specify a value for the operating system type you want to scan (alpine, debian, fedora). Useful if autodetection fails and/or you want to explicitly set it.") pf.StringVar(&packageManager, "package-manager", "", "Specify package manager type you want to scan (apk, dnf, dpkg or yum). Useful if autodetection fails and/or you want to explicitly set it.") pf.BoolVar(&cleanCache, "clean-cache", false, "Flag to clean the database cache for OSS Index") - pf.StringVar(&ossIndexUser, "user", "", "Specify your OSS Index Username") - pf.StringVar(&ossIndexToken, "token", "", "Specify your OSS Index API Token") pf.StringVar(&output, "output", "text", "Specify the output type you want (json, text, csv)") pf.BoolVar(&loud, "loud", false, "Specify if you want non vulnerable packages included in your output") - pf.BoolVar(&quiet, "quiet", false, "Quiet removes the header from being printed") + pf.BoolVar(&quiet, "quiet", true, "Quiet removes the header from being printed") pf.BoolVar(&noColor, "no-color", false, "Specify if you want no color in your results") pf.CountVarP(&verbose, "", "v", "Set log level, higher is more verbose") @@ -101,8 +105,7 @@ var chaseCmd = &cobra.Command{ dnf list installed | ./ahab chase apk info -vv | sort | ./ahab chase `, - SilenceErrors: true, - SilenceUsage: true, + PreRun: func(cmd *cobra.Command, args []string) { bindViperRootCmd() }, RunE: func(cmd *cobra.Command, args []string) (err error) { defer func() { if r := recover(); r != nil { @@ -111,8 +114,7 @@ var chaseCmd = &cobra.Command{ if !ok { err = fmt.Errorf("pkg: %v", r) } - _ = cmd.Usage() - logger.PrintErrorAndLogLocation(err) + err = customerrors.ErrorShowLogPath{Err: err} } }() @@ -131,10 +133,21 @@ var chaseCmd = &cobra.Command{ TTL: time.Now().Local().Add(time.Hour * 12), Tool: "ahab-client", Version: buildversion.BuildVersion, - Username: ossIndexUser, - Token: ossIndexToken, + OSSIndexURL: ossIndexURL, + Username: viper.GetString(configuration.ViperKeyUsername), + Token: viper.GetString(configuration.ViperKeyToken), }) + logLady.WithField("ossiServer", types.Options{ + OSSIndexURL: ossi.Options.OSSIndexURL, + Username: cleanUserName(ossi.Options.Username), + Token: "***hidden***", + Tool: ossi.Options.Tool, + Version: ossi.Options.Version, + DBCacheName: ossi.Options.DBCacheName, + TTL: ossi.Options.TTL, + }).Debug("Created ossiIndex server") + if cleanCache { err = ossi.NoCacheNoProblems() if err != nil { @@ -190,6 +203,32 @@ var chaseCmd = &cobra.Command{ }, } +const ( + flagNameOssiUsername = "username" + flagNameOssiToken = "token" +) + +func bindViperRootCmd() { + // need to defer bind call until command is run. see: https://github.com/spf13/viper/issues/233 + + // Bind viper to the flags passed in via the command line, so it will override config from file + if err := viper.BindPFlag(configuration.ViperKeyUsername, lookupPersistentFlagNotNil(flagNameOssiUsername, rootCmd)); err != nil { + panic(err) + } + if err := viper.BindPFlag(configuration.ViperKeyToken, lookupPersistentFlagNotNil(flagNameOssiToken, rootCmd)); err != nil { + panic(err) + } +} + +func lookupPersistentFlagNotNil(flagName string, cmd *cobra.Command) *pflag.Flag { + // see: https://github.com/spf13/viper/pull/949 + foundFlag := cmd.PersistentFlags().Lookup(flagName) + if foundFlag == nil { + panic(fmt.Errorf("persisent flag lookup for name: '%s' returned nil", flagName)) + } + return foundFlag +} + func getLogger(level int) (*logrus.Logger, error) { switch level { case 1: @@ -244,14 +283,23 @@ func parseStdInList(list []string, packageManager *string) (packages.IPackage, e } } +const MsgMissingStdIn = "nothing passed in to standard in" + +func checkStdIn() (err error) { + stat, _ := os.Stdin.Stat() + if (stat.Mode() & os.ModeCharDevice) == 0 { + logLady.Info("StdIn is valid") + } else { + err = fmt.Errorf(MsgMissingStdIn) + logLady.Error(err) + } + return +} + func parseStdIn(packageManager *string) (packages.IPackage, error) { - fi, err := os.Stdin.Stat() - if err != nil { + if err := checkStdIn(); err != nil { return nil, err } - if (fi.Mode() & os.ModeNamedPipe) == 0 { - return nil, fmt.Errorf("Nothing passed in to standard in") - } var list []string scanner := bufio.NewScanner(os.Stdin) diff --git a/cmd/chase_test.go b/cmd/chase_test.go new file mode 100644 index 0000000..01cfe96 --- /dev/null +++ b/cmd/chase_test.go @@ -0,0 +1,154 @@ +package cmd + +import ( + "encoding/json" + "github.com/sonatype-nexus-community/go-sona-types/ossindex/types" + "github.com/stretchr/testify/assert" + "net/http" + "net/http/httptest" + "os" + "testing" +) + +func TestChaseCommandNoArgs(t *testing.T) { + // pass a specific package manager to avoid test behavior changes on different OSs. + _, err := executeCommand(rootCmd, chaseCmd.Use, "--os", "apk") + assert.NotNil(t, err) + assert.Contains(t, err.Error(), MsgMissingStdIn) +} + +func TestChaseCommandApkInvalidStdInText(t *testing.T) { + oldStdIn, tmpFile := createFakeStdIn(t) + defer func() { + os.Stdin = oldStdIn + _ = tmpFile.Close() + _ = os.Remove(tmpFile.Name()) + }() + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodPost, r.Method) + assert.Equal(t, "/", r.URL.EscapedPath()) + + w.WriteHeader(http.StatusBadRequest) + })) + defer ts.Close() + origOssIndexURL := ossIndexURL + ossIndexURL = ts.URL + defer func() { + ossIndexURL = origOssIndexURL + }() + + _, err := executeCommand(rootCmd, chaseCmd.Use, "--os", "apk") + assert.NotNil(t, err) + assert.Contains(t, err.Error(), "An error occurred: [400 Bad Request] error accessing OSS Index") +} + +func TestChaseCommandBadUserAndToken(t *testing.T) { + // FAKE alpine package should avoid test failure due to cached package + oldStdIn, tmpFile := createFakeStdInWithString(t, "FAKE__alpine-baselayout-3.1.2-r0 - Alpine base dir structure and init scripts") + defer func() { + os.Stdin = oldStdIn + _ = tmpFile.Close() + _ = os.Remove(tmpFile.Name()) + }() + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodPost, r.Method) + assert.Equal(t, "/", r.URL.EscapedPath()) + + assert.Equal(t, "Basic YmFkdXNlcjpiYWR0b2tlbg==", r.Header.Get("Authorization"), r) + + w.WriteHeader(http.StatusUnauthorized) + })) + defer ts.Close() + origOssIndexURL := ossIndexURL + ossIndexURL = ts.URL + defer func() { + ossIndexURL = origOssIndexURL + }() + + // pass a specific package manager to avoid test behavior changes on different OSs. + _, err := executeCommand(rootCmd, chaseCmd.Use, "-u", "baduser", "-t", "badtoken", "--os", "apk") + assert.NotNil(t, err) // if this fails, make sure the cache is cleaned first + assert.Contains(t, err.Error(), "An error occurred: [401 Unauthorized] error accessing OSS Index") +} + +func TestChaseCommandEmptyUserAndToken(t *testing.T) { + oldStdIn, tmpFile := createFakeStdInWithString(t, "alpine-baselayout-3.1.2-r0 - Alpine base dir structure and init scripts") + defer func() { + os.Stdin = oldStdIn + _ = tmpFile.Close() + _ = os.Remove(tmpFile.Name()) + }() + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodPost, r.Method) + assert.Equal(t, "/", r.URL.EscapedPath()) + + assert.Equal(t, "", r.Header.Get("Authorization"), r) + + w.WriteHeader(http.StatusOK) + coordinates := []types.Coordinate{expectedCoordinate} + jsonCoordinates, _ := json.Marshal(coordinates) + _, _ = w.Write(jsonCoordinates) + })) + defer ts.Close() + origOssIndexURL := ossIndexURL + ossIndexURL = ts.URL + defer func() { + ossIndexURL = origOssIndexURL + }() + + // pass a specific package manager to avoid test behavior changes on different OSs. + _, err := executeCommand(rootCmd, chaseCmd.Use, "-u", "", "-t", "", "--os", "apk") + assert.Nil(t, err) +} + +var expectedCoordinate types.Coordinate + +// TODO: Figure out why this test works when run by itself, but fails as part of test suite. +// Manual testing confirms correct behavior +/*func TestChaseCommandViperUserAndToken(t *testing.T) { + oldStdIn, tmpFile := createFakeStdInWithString(t, "alpine-baselayout-3.1.2-r0 - Alpine base dir structure and init scripts") + defer func() { + os.Stdin = oldStdIn + _ = tmpFile.Close() + _ = os.Remove(tmpFile.Name()) + }() + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodPost, r.Method) + assert.Equal(t, "/", r.URL.EscapedPath()) + + assert.Equal(t, "ossiUsernameValue", ossi.Options.Username) + assert.Equal(t, "ossiTokenValue", ossi.Options.Token) + assert.Equal(t, "Basic b3NzaVVzZXJuYW1lVmFsdWU6b3NzaVRva2VuVmFsdWU=", r.Header.Get("Authorization"), r) + + w.WriteHeader(http.StatusOK) + coordinates := []types.Coordinate{expectedCoordinate} + jsonCoordinates, _ := json.Marshal(coordinates) + _, _ = w.Write(jsonCoordinates) + })) + defer ts.Close() + origOssIndexURL := ossIndexURL + ossIndexURL = ts.URL + defer func() { + ossIndexURL = origOssIndexURL + }() + + viper.Reset() + defer viper.Reset() + + tempDir := setupConfig(t) + defer resetConfig(t, tempDir) + + setupTestOSSIConfigFileValues(t, tempDir) + defer func() { + resetOSSIConfigFile() + }() + + // pass a specific package manager to avoid test behavior changes on different OSs. + _, err := executeCommand(rootCmd, chaseCmd.Use, "--os", "apk") + assert.Nil(t, err) +} +*/ diff --git a/cmd/config.go b/cmd/config.go new file mode 100644 index 0000000..91ac9f3 --- /dev/null +++ b/cmd/config.go @@ -0,0 +1,68 @@ +// +// Copyright 2018-present Sonatype Inc. +// +// 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 cmd + +import ( + "fmt" + "os" + + "github.com/sonatype-nexus-community/ahab/logger" + "github.com/sonatype-nexus-community/go-sona-types/configuration" + + "github.com/spf13/cobra" +) + +var configCmd = &cobra.Command{ + Use: "config", + Short: "Setup credentials to use when connecting to services", + Long: `Save credentials for reuse in connecting to various backend services. +The config command will prompt for the type of credentials to save.`, + RunE: doConfig, +} + +//noinspection GoUnusedParameter +func doConfig(cmd *cobra.Command, args []string) (err error) { + defer func() { + if r := recover(); r != nil { + var ok bool + err, ok = r.(error) + if !ok { + err = fmt.Errorf("pkg: %v", r) + } + logger.PrintErrorAndLogLocation(err) + } + }() + + logLady, err = getLogger(verbose) + if err != nil { + panic(err) + } + + var configSet *configuration.ConfigSet + if configSet, err = configuration.New(logLady); err != nil { + panic(err) + } + + if err = configSet.GetConfigFromCommandLine(os.Stdin); err != nil { + panic(err) + } + return +} + +func init() { + rootCmd.AddCommand(configCmd) +} diff --git a/cmd/iq.go b/cmd/iq.go index 1ebf2c2..11aae55 100644 --- a/cmd/iq.go +++ b/cmd/iq.go @@ -18,10 +18,15 @@ package cmd import ( "fmt" + "github.com/mitchellh/go-homedir" + "github.com/sonatype-nexus-community/ahab/internal/customerrors" + "github.com/sonatype-nexus-community/go-sona-types/configuration" + "github.com/sonatype-nexus-community/go-sona-types/ossindex/types" + "github.com/spf13/viper" "os" + "path" "github.com/sonatype-nexus-community/ahab/buildversion" - "github.com/sonatype-nexus-community/ahab/logger" "github.com/sonatype-nexus-community/ahab/packages" "github.com/sonatype-nexus-community/go-sona-types/iq" "github.com/spf13/cobra" @@ -29,6 +34,7 @@ import ( ) var ( + cfgFileIQ string iqUsername string iqToken string iqHost string @@ -38,37 +44,49 @@ var ( lifecycle *iq.Server ) +const ( + flagNameIqUsername = "iq-username" + flagNameIqToken = "iq-token" + flagNameIqStage = "iq-stage" + flagNameIqApplication = "iq-application" + flagNameIqServerUrl = "iq-server-url" +) + func init() { - rootCmd.AddCommand(iqCmd) + cobra.OnInitialize(initIQConfig) pf := iqCmd.PersistentFlags() pf.StringVar(&packageManager, "os", "", "Specify a value for the operating system type you want to scan (alpine, debian, fedora). Useful if autodetection fails and/or you want to explicitly set it.") pf.StringVar(&packageManager, "package-manager", "", "Specify package manager type you want to scan (apk, dnf, dpkg or yum). Useful if autodetection fails and/or you want to explicitly set it.") - pf.StringVar(&iqUsername, "user", "admin", "Specify Nexus IQ Username for request") - pf.StringVar(&iqToken, "token", "admin123", "Specify Nexus IQ Token/Password for request") - pf.StringVar(&ossIndexUser, "oss-index-user", "", "Specify your OSS Index Username") - pf.StringVar(&ossIndexToken, "oss-index-token", "", "Specify your OSS Index API Token") - pf.StringVar(&iqHost, "host", "http://localhost:8070", "Specify Nexus IQ Server URL") - pf.BoolVar(&quiet, "quiet", false, "Quiet removes the header from being printed") - pf.StringVar(&application, "application", "", "Specify public application ID for request (required)") - pf.StringVar(&stage, "stage", "develop", "Specify stage for application") + pf.StringVarP(&iqUsername, flagNameIqUsername, "l", "admin", "Specify Nexus IQ Username for request") + pf.StringVarP(&iqToken, flagNameIqToken, "k", "admin123", "Specify Nexus IQ Token/Password for request") + pf.StringVarP(&iqHost, flagNameIqServerUrl, "x", "http://localhost:8070", "Specify Nexus IQ Server URL") + pf.BoolVar(&quiet, "quiet", true, "Quiet removes the header from being printed") + + pf.StringVarP(&application, flagNameIqApplication, "a", "", "Specify public application ID for request (required)") + if err := iqCmd.MarkPersistentFlagRequired(flagNameIqApplication); err != nil { + panic(err) + } + + pf.StringVarP(&stage, flagNameIqStage, "s", "develop", "Specify stage for application") pf.IntVar(&maxRetries, "max-retries", 300, "Specify maximum number of tries to poll Nexus IQ Server") pf.CountVarP(&verbose, "", "v", "Set log level, higher is more verbose") iqCmd.Flag("os").Deprecated = "use package-manager" + + rootCmd.AddCommand(iqCmd) } var iqCmd = &cobra.Command{ Use: "iq", Short: "iq is used for auditing your projects with Nexus IQ Server", Example: ` - dpkg-query --show --showformat='${Package} ${Version}\n' | ./ahab iq --application testapp - yum list installed | ./ahab iq --application testapp - dnf list installed | ./ahab iq --application testapp - apk info -vv | sort | ./ahab iq --application testapp + dpkg-query --show --showformat='${Package} ${Version}\n' | ./ahab iq --` + flagNameIqApplication + ` testapp + yum list installed | ./ahab iq --` + flagNameIqApplication + ` testapp + dnf list installed | ./ahab iq --` + flagNameIqApplication + ` testapp + apk info -vv | sort | ./ahab iq --` + flagNameIqApplication + ` testapp `, - SilenceErrors: true, - SilenceUsage: true, + PreRun: func(cmd *cobra.Command, args []string) { bindViperIq(cmd) }, RunE: func(cmd *cobra.Command, args []string) (err error) { defer func() { if r := recover(); r != nil { @@ -77,8 +95,7 @@ var iqCmd = &cobra.Command{ if !ok { err = fmt.Errorf("pkg: %v", r) } - _ = cmd.Usage() - logger.PrintErrorAndLogLocation(err) + err = customerrors.ErrorShowLogPath{Err: err} } }() @@ -91,33 +108,38 @@ var iqCmd = &cobra.Command{ panic(err) } - fflags := cmd.Flags() - - err = checkRequiredFlags(fflags) - if err != nil { - logLady.Error(err) - panic(err) - } - lifecycle, err = iq.New(logLady, iq.Options{ - User: iqUsername, - Token: iqToken, - Server: iqHost, + User: viper.GetString(configuration.ViperKeyIQUsername), + Token: viper.GetString(configuration.ViperKeyIQToken), + Server: viper.GetString(configuration.ViperKeyIQServer), Application: application, Stage: stage, Tool: "ahab-client", Version: buildversion.BuildVersion, - OSSIndexToken: ossIndexToken, - OSSIndexUser: ossIndexUser, + OSSIndexToken: viper.GetString(configuration.ViperKeyToken), + OSSIndexUser: viper.GetString(configuration.ViperKeyUsername), DBCacheName: "ahab-cache", MaxRetries: maxRetries, }) if err != nil { - logLady.Error(err) panic(err) } + logLady.WithField("lifecycle", iq.Options{ + User: cleanUserName(lifecycle.Options.User), + Token: "***hidden***", + Server: lifecycle.Options.Server, + Application: lifecycle.Options.Application, + Stage: lifecycle.Options.Stage, + Tool: lifecycle.Options.Tool, + Version: lifecycle.Options.Version, + OSSIndexUser: cleanUserName(lifecycle.Options.OSSIndexUser), + OSSIndexToken: "***hidden***", + DBCacheName: lifecycle.Options.DBCacheName, + MaxRetries: lifecycle.Options.MaxRetries, + }).Debug("Created iq server") + if packageManager == "" { logLady.Trace("Attempting to detect package manager for you") manager, err := packages.DetectPackageManager(logLady) @@ -163,9 +185,58 @@ var iqCmd = &cobra.Command{ }, } -func checkRequiredFlags(flags *pflag.FlagSet) error { - if !flags.Changed("application") { - return fmt.Errorf("Application not set, see usage for more information") +func bindViperIq(cmd *cobra.Command) { + // need to defer bind call until command is run. see: https://github.com/spf13/viper/issues/233 + + // need to ensure ossi CLI flags will override ossi config file values when running IQ command + bindViperRootCmd() + + // Bind viper to the flags passed in via the command line, so it will override config from file + if err := viper.BindPFlag(configuration.ViperKeyIQUsername, lookupFlagNotNil(flagNameIqUsername, cmd)); err != nil { + panic(err) + } + if err := viper.BindPFlag(configuration.ViperKeyIQToken, lookupFlagNotNil(flagNameIqToken, cmd)); err != nil { + panic(err) + } + if err := viper.BindPFlag(configuration.ViperKeyIQServer, lookupFlagNotNil(flagNameIqServerUrl, cmd)); err != nil { + panic(err) + } +} + +func lookupFlagNotNil(flagName string, cmd *cobra.Command) *pflag.Flag { + // see: https://github.com/spf13/viper/pull/949 + foundFlag := cmd.Flags().Lookup(flagName) + if foundFlag == nil { + panic(fmt.Errorf("flag lookup for name: '%s' returned nil", flagName)) + } + return foundFlag +} + +func initIQConfig() { + var cfgFileToCheck string + if cfgFileIQ != "" { + viper.SetConfigFile(cfgFileIQ) + viper.SetConfigType(configuration.ConfigTypeYaml) + cfgFileToCheck = cfgFileIQ + } else { + home, err := homedir.Dir() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + configPath := path.Join(home, types.IQServerDirName) + + viper.AddConfigPath(configPath) + viper.SetConfigType(configuration.ConfigTypeYaml) + viper.SetConfigName(types.IQServerConfigFileName) + + cfgFileToCheck = path.Join(configPath, types.IQServerConfigFileName) + } + + if fileExists(cfgFileToCheck) { + // 'merge' IQ config here, since we also need OSSI config, and load order is not guaranteed + if err := viper.MergeInConfig(); err != nil { + panic(err) + } } - return nil } diff --git a/cmd/iq_test.go b/cmd/iq_test.go new file mode 100644 index 0000000..58f9530 --- /dev/null +++ b/cmd/iq_test.go @@ -0,0 +1,128 @@ +// +// Copyright 2018-present Sonatype Inc. +// +// 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 cmd + +import ( + "fmt" + "github.com/sonatype-nexus-community/go-sona-types/configuration" + "github.com/sonatype-nexus-community/go-sona-types/ossindex/types" + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" + "io/ioutil" + "os" + "path" + "testing" +) + +func TestIqApplicationFlagMissing(t *testing.T) { + _, err := executeCommand(rootCmd, iqCmd.Use) + //output, err := executeCommand(rootCmd, iqCmd.Use) + //assert.Contains(t, output, "Error: \""+flagNameIqApplication+"\" not set, see usage for more information") + assert.NotNil(t, err) + assert.Contains(t, err.Error(), "required flag(s) \""+flagNameIqApplication+"\" not set") +} + +func TestIqHelp(t *testing.T) { + output, err := executeCommand(rootCmd, iqCmd.Use, "--help") + assert.Contains(t, output, "\tyum list installed | ./ahab iq --"+flagNameIqApplication+" testapp") + assert.Nil(t, err) +} + +func setupIQConfigFile(t *testing.T, tempDir string) { + cfgDirIQ := path.Join(tempDir, types.IQServerDirName) + assert.Nil(t, os.Mkdir(cfgDirIQ, 0700)) + + cfgFileIQ = path.Join(tempDir, types.IQServerDirName, types.IQServerConfigFileName) +} +func resetIQConfigFile() { + cfgFileIQ = "" +} + +func TestInitIQConfig(t *testing.T) { + viper.Reset() + defer viper.Reset() + + tempDir := setupConfig(t) + defer resetConfig(t, tempDir) + + setupTestOSSIConfigFileValues(t, tempDir) + defer func() { + resetOSSIConfigFile() + }() + + setupIQConfigFile(t, tempDir) + defer func() { + resetIQConfigFile() + }() + + credentials := fmt.Sprintf("%s: %s\n%s: %s\n%s: %s\n", + configuration.ViperKeyIQUsername, "iqUsernameValue", + configuration.ViperKeyIQToken, "iqTokenValue", + configuration.ViperKeyIQServer, "iqServerValue") + assert.Nil(t, ioutil.WriteFile(cfgFileIQ, []byte(credentials), 0644)) + + // init order is not guaranteed + initIQConfig() + initConfig() + + // verify the OSSI stuff, since we will call both OSSI and IQ + assert.Equal(t, "ossiUsernameValue", viper.GetString(configuration.ViperKeyUsername)) + assert.Equal(t, "ossiTokenValue", viper.GetString(configuration.ViperKeyToken)) + // verify the IQ stuff + assert.Equal(t, "iqUsernameValue", viper.GetString(configuration.ViperKeyIQUsername)) + assert.Equal(t, "iqTokenValue", viper.GetString(configuration.ViperKeyIQToken)) + assert.Equal(t, "iqServerValue", viper.GetString(configuration.ViperKeyIQServer)) +} + +func TestInitIQConfigWithNoConfigFile(t *testing.T) { + viper.Reset() + defer viper.Reset() + + tempDir := setupConfig(t) + defer resetConfig(t, tempDir) + + setupTestOSSIConfigFileValues(t, tempDir) + defer func() { + resetOSSIConfigFile() + }() + + setupIQConfigFile(t, tempDir) + defer func() { + resetIQConfigFile() + }() + credentials := fmt.Sprintf("%s: %s\n%s: %s\n%s: %s\n", + configuration.ViperKeyIQUsername, "iqUsernameValue", + configuration.ViperKeyIQToken, "iqTokenValue", + configuration.ViperKeyIQServer, "iqServerValue") + assert.Nil(t, ioutil.WriteFile(cfgFileIQ, []byte(credentials), 0644)) + + // delete the config files + assert.NoError(t, os.Remove(cfgFile)) + assert.NoError(t, os.Remove(cfgFileIQ)) + + // init order is not guaranteed + initIQConfig() + initConfig() + + // verify the OSSI stuff, since we will call both OSSI and IQ + assert.Equal(t, "", viper.GetString(configuration.ViperKeyUsername)) + assert.Equal(t, "", viper.GetString(configuration.ViperKeyToken)) + // verify the IQ stuff + assert.Equal(t, "", viper.GetString(configuration.ViperKeyIQUsername)) + assert.Equal(t, "", viper.GetString(configuration.ViperKeyIQToken)) + assert.Equal(t, "", viper.GetString(configuration.ViperKeyIQServer)) +} diff --git a/cmd/root.go b/cmd/root.go index 1ed48ae..61d1705 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,13 @@ package cmd import ( + "fmt" + "github.com/mitchellh/go-homedir" + "github.com/sonatype-nexus-community/go-sona-types/configuration" + "github.com/sonatype-nexus-community/go-sona-types/ossindex/types" + "github.com/spf13/viper" "os" + "path" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -42,3 +48,59 @@ func Execute() { os.Exit(1) } } + +func init() { + cobra.OnInitialize(initConfig) + + pf := rootCmd.PersistentFlags() + pf.StringVarP(&ossIndexUser, flagNameOssiUsername, "u", "", "Specify your OSS Index Username") + pf.StringVarP(&ossIndexToken, flagNameOssiToken, "t", "", "Specify your OSS Index API Token") +} + +func initConfig() { + var cfgFileToCheck string + if cfgFile != "" { + viper.SetConfigFile(cfgFile) + viper.SetConfigType(configuration.ConfigTypeYaml) + cfgFileToCheck = cfgFile + } else { + home, err := homedir.Dir() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + configPath := path.Join(home, types.OssIndexDirName) + + viper.AddConfigPath(configPath) + viper.SetConfigType(configuration.ConfigTypeYaml) + viper.SetConfigName(types.OssIndexConfigFileName) + + cfgFileToCheck = path.Join(configPath, types.OssIndexConfigFileName) + } + + if fileExists(cfgFileToCheck) { + // 'merge' OSSI config here, since IQ cmd also need OSSI config, and init order is not guaranteed + if err := viper.MergeInConfig(); err != nil { + panic(err) + } + } +} + +func fileExists(filename string) bool { + info, err := os.Stat(filename) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} + +func cleanUserName(origUsername string) string { + runes := []rune(origUsername) + cleanUsername := "***hidden***" + if len(runes) > 0 { + first := string(runes[0]) + last := string(runes[len(runes)-1]) + cleanUsername = first + "***hidden***" + last + } + return cleanUsername +} diff --git a/cmd/root_test.go b/cmd/root_test.go new file mode 100644 index 0000000..c260506 --- /dev/null +++ b/cmd/root_test.go @@ -0,0 +1,150 @@ +// +// Copyright 2018-present Sonatype Inc. +// +// 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 cmd + +import ( + "bytes" + "github.com/sonatype-nexus-community/go-sona-types/configuration" + "github.com/sonatype-nexus-community/go-sona-types/ossindex/types" + "github.com/spf13/viper" + "io/ioutil" + "os" + "path" + "testing" + + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" +) + +func executeCommand(root *cobra.Command, args ...string) (output string, err error) { + buf := new(bytes.Buffer) + root.SetOut(buf) + root.SetErr(buf) + root.SetArgs(args) + + err = root.Execute() + + return buf.String(), err +} + +func TestRootCommandNoArgs(t *testing.T) { + _, err := executeCommand(rootCmd, "") + assert.Nil(t, err) +} + +func TestRootCommandUnknownCommand(t *testing.T) { + output, err := executeCommand(rootCmd, "one", "two") + assert.Contains(t, output, "Error: unknown command \"one\" for \"ahab\"") + + assert.NotNil(t, err) + assert.Contains(t, err.Error(), "unknown command \"one\" for \"ahab\"") +} + +func setupConfig(t *testing.T) (tempDir string) { + tempDir, err := ioutil.TempDir("", "config-test") + assert.NoError(t, err) + return tempDir +} + +func resetConfig(t *testing.T, tempDir string) { + var err error + assert.NoError(t, err) + _ = os.RemoveAll(tempDir) +} + +func TestInitConfig(t *testing.T) { + viper.Reset() + defer viper.Reset() + + tempDir := setupConfig(t) + defer resetConfig(t, tempDir) + + setupTestOSSIConfigFileValues(t, tempDir) + defer func() { + resetOSSIConfigFile() + }() + + initConfig() + + assert.Equal(t, "ossiUsernameValue", viper.GetString(configuration.ViperKeyUsername)) + assert.Equal(t, "ossiTokenValue", viper.GetString(configuration.ViperKeyToken)) +} + +func TestInitConfigWithNoConfigFile(t *testing.T) { + viper.Reset() + defer viper.Reset() + + tempDir := setupConfig(t) + defer resetConfig(t, tempDir) + + setupTestOSSIConfigFileValues(t, tempDir) + defer func() { + resetOSSIConfigFile() + }() + // delete the config file + assert.NoError(t, os.Remove(cfgFile)) + + initConfig() + + assert.Equal(t, "", viper.GetString(configuration.ViperKeyUsername)) + assert.Equal(t, "", viper.GetString(configuration.ViperKeyToken)) +} + +func setupTestOSSIConfigFile(t *testing.T, tempDir string) { + cfgDir := path.Join(tempDir, types.OssIndexDirName) + assert.Nil(t, os.Mkdir(cfgDir, 0700)) + + cfgFile = path.Join(tempDir, types.OssIndexDirName, types.OssIndexConfigFileName) +} + +func resetOSSIConfigFile() { + cfgFile = "" +} + +func setupTestOSSIConfigFileValues(t *testing.T, tempDir string) { + setupTestOSSIConfigFile(t, tempDir) + + const credentials = "ossi:\n" + + " Username: ossiUsernameValue\n" + + " Token: ossiTokenValue" + assert.Nil(t, ioutil.WriteFile(cfgFile, []byte(credentials), 0644)) +} + +func createFakeStdIn(t *testing.T) (oldStdIn *os.File, tmpFile *os.File) { + return createFakeStdInWithString(t, "Testing") +} + +func createFakeStdInWithString(t *testing.T, inputString string) (oldStdIn *os.File, tmpFile *os.File) { + content := []byte(inputString) + tmpFile, err := ioutil.TempFile("", "tempfile") + if err != nil { + t.Error(err) + } + + if _, err := tmpFile.Write(content); err != nil { + t.Error(err) + } + + if _, err := tmpFile.Seek(0, 0); err != nil { + t.Error(err) + } + + oldStdIn = os.Stdin + + os.Stdin = tmpFile + return oldStdIn, tmpFile +} diff --git a/go.mod b/go.mod index bfc9ba5..aa39289 100644 --- a/go.mod +++ b/go.mod @@ -6,11 +6,13 @@ require ( github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2 github.com/jedib0t/go-pretty/v6 v6.0.5 github.com/logrusorgru/aurora v2.0.3+incompatible + github.com/mitchellh/go-homedir v1.1.0 github.com/shopspring/decimal v1.2.0 github.com/sirupsen/logrus v1.7.0 - github.com/sonatype-nexus-community/go-sona-types v0.0.7 + github.com/sonatype-nexus-community/go-sona-types v0.0.8 github.com/spf13/cobra v1.0.0 github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.6.1 golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect ) diff --git a/go.sum b/go.sum index bd21367..49b18f2 100644 --- a/go.sum +++ b/go.sum @@ -1,37 +1,54 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= 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/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/common-nighthawk/go-figure v0.0.0-20200604155835-c37800f1341b h1:Wj3So8inj17r6TT2dTYElAkLlpFMhJUiXFgSjC8R1zs= -github.com/common-nighthawk/go-figure v0.0.0-20200604155835-c37800f1341b/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2 h1:tjT4Jp4gxECvsJcYpAMtW2I3YqzBTPuB67OejxXs86s= github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= 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= github.com/coreos/etcd v3.3.24+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -42,27 +59,59 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jarcoal/httpmock v1.0.5 h1:cHtVEcTxRSX4J0je7mWPfc9BpDpqzXSJ5HbymZmyHck= github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= -github.com/jedib0t/go-pretty/v6 v6.0.3 h1:CyQyeQRuiFEji13SbKFfSKsbfyykD1j0Y0+zYazPQZU= -github.com/jedib0t/go-pretty/v6 v6.0.3/go.mod h1:MTr6FgcfNdnN5wPVBzJ6mhJeDyiF0yBvS2TMXEV/XSU= -github.com/jedib0t/go-pretty/v6 v6.0.4 h1:7WaHUeKo5yc2vABlsh30p4VWxQoXaWktBY/nR/2qnPg= -github.com/jedib0t/go-pretty/v6 v6.0.4/go.mod h1:MTr6FgcfNdnN5wPVBzJ6mhJeDyiF0yBvS2TMXEV/XSU= github.com/jedib0t/go-pretty/v6 v6.0.5 h1:oOo0/jSb3NEYKT6l1hhFXoX2UZnkanMuCE2DVT1mqnE= github.com/jedib0t/go-pretty/v6 v6.0.5/go.mod h1:MTr6FgcfNdnN5wPVBzJ6mhJeDyiF0yBvS2TMXEV/XSU= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -75,34 +124,46 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/package-url/packageurl-go v0.1.0 h1:efWBc98O/dBZRg1pw2xiDzovnlMjCa9NPnfaiBduh8I= github.com/package-url/packageurl-go v0.1.0/go.mod h1:C/ApiuWpmbpni4DIOECf6WCjFUZV7O1Fx7VAzrZHgBw= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -115,7 +176,10 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/recoilme/pudge v1.0.3 h1:h/9dEv5fRqtzM4lnO69kUoN+k7ukxxrW9NGb9ug0grM= github.com/recoilme/pudge v1.0.3/go.mod h1:VMvxBLVkrSStldckzCsETBXox3pfovfrnEchafXk8qA= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -124,11 +188,13 @@ github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/sonatype-nexus-community/go-sona-types v0.0.2 h1:F6dq9gVBTH+E86PJUuh7gptRu0nnaVLiWdYenD1/n0w= -github.com/sonatype-nexus-community/go-sona-types v0.0.2/go.mod h1:voGD7LEwz9TSvjZWNxST56pFPa0hdNQ71WsuMwBki3k= -github.com/sonatype-nexus-community/go-sona-types v0.0.7 h1:ZH00KCTlLnI0LBIs+Juv9WBCtamKKdoFeryp1p5UB6s= -github.com/sonatype-nexus-community/go-sona-types v0.0.7/go.mod h1:voGD7LEwz9TSvjZWNxST56pFPa0hdNQ71WsuMwBki3k= +github.com/sonatype-nexus-community/go-sona-types v0.0.8 h1:6xb9BIC2w3y4kF/xQA25Zs6Yrl8ZqFkfH77AKPaG4RA= +github.com/sonatype-nexus-community/go-sona-types v0.0.8/go.mod h1:uou8FGf9R5Nz1c6BfSM3v9K7g0R6faTYoxLh9Ybeht8= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -144,76 +210,156 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= +github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= -golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200928205150-006507a75852 h1:sXxgOAXy8JwHhZnPuItAlUtwIlxrlEqi28mKhUR+zZY= -golang.org/x/sys v0.0.0-20200928205150-006507a75852/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/internal/customerrors/error.go b/internal/customerrors/error.go new file mode 100644 index 0000000..d9de46c --- /dev/null +++ b/internal/customerrors/error.go @@ -0,0 +1,49 @@ +// +// Copyright 2018-present Sonatype Inc. +// +// 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 customerrors + +import ( + "fmt" + "github.com/sonatype-nexus-community/ahab/buildversion" + "github.com/sonatype-nexus-community/ahab/logger" +) + +type ErrorShowLogPath struct { + Err error +} + +func (es ErrorShowLogPath) Error() string { + var errString string + if es.Err != nil { + errString = es.Err.Error() + } else { + errString = "" + } + + return errString + "\n\n" + getLogFileMessage() +} + +func getLogFileMessage() string { + var logFile string + var logFileErr error + if logFile, logFileErr = logger.LogFileLocation(); logFileErr != nil { + logFile = "unknown" + } + + return fmt.Sprintf("For more information, check the log file at %s\n"+ + "nancy version: %s\n", logFile, buildversion.BuildVersion) +} diff --git a/internal/customerrors/error_test.go b/internal/customerrors/error_test.go new file mode 100644 index 0000000..c639a8c --- /dev/null +++ b/internal/customerrors/error_test.go @@ -0,0 +1,30 @@ +// +// Copyright 2018-present Sonatype Inc. +// +// 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 customerrors + +import ( + "fmt" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestErrorShowLogPath(t *testing.T) { + assert.Equal(t, "MyError\n\n"+getLogFileMessage(), + ErrorShowLogPath{Err: fmt.Errorf("MyError")}.Error()) + assert.Equal(t, "\n\n"+getLogFileMessage(), + ErrorShowLogPath{}.Error()) +}