From 75b2a9bdb3a92953ecab6948ab058cdfaeba1158 Mon Sep 17 00:00:00 2001 From: Anupam Pokharel Date: Mon, 9 Oct 2023 12:32:24 -0500 Subject: [PATCH 1/7] changes to support motd --- bluemix/api/utils.go | 126 +++++++++++++++++++ bluemix/configuration/core_config/helpers.go | 37 ++++++ bluemix/motd/motd.go | 105 ++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 bluemix/api/utils.go create mode 100644 bluemix/configuration/core_config/helpers.go create mode 100644 bluemix/motd/motd.go diff --git a/bluemix/api/utils.go b/bluemix/api/utils.go new file mode 100644 index 0000000..469f6cf --- /dev/null +++ b/bluemix/api/utils.go @@ -0,0 +1,126 @@ +package api + +import ( + "fmt" + "net/url" + "path" + "regexp" + "strings" + + "github.com/Masterminds/semver" +) + +const ( + ConstraintAllVersions = "*" +) + +var coercableSemver = regexp.MustCompile(`^\d+(\.\d+)?$`) + +func GetFullURL(base string, path string) string { + if base == "" { + return path + } + + return base + CleanPath(path) +} + +func CleanPath(p string) string { + if p == "" { + return "/" + } + if !strings.HasPrefix(p, "/") { + p = "/" + p + } + return path.Clean(p) +} + +type SemverConstraintInvalidError struct { + Constraint string + Err error +} + +func (e SemverConstraintInvalidError) Error() string { + return "Invalid version constraint" + // return i18n.T("Version constraint {{.Constraint}} is invalid:\n", + // map[string]interface{}{"Constraint": e.Constraint}) + e.Err.Error() +} + +type SemverConstraint interface { + Satisfied(string) bool + IsRange() bool + + fmt.Stringer +} + +func NewSemverConstraint(versionOrRange string) (SemverConstraint, error) { + versionOrRange = strings.TrimPrefix(versionOrRange, "v") + versionOrRange = coerce(versionOrRange) + + if _, err := semver.NewVersion(versionOrRange); err == nil { + return semverVersion(versionOrRange), nil + } + + constraints, err := semver.NewConstraint(versionOrRange) + if err != nil { + return nil, SemverConstraintInvalidError{Constraint: versionOrRange, Err: err} + } + + return semverRange{repr: versionOrRange, constraints: constraints}, nil +} + +type semverVersion string + +func (v semverVersion) Satisfied(version string) bool { + return strings.EqualFold(string(v), version) +} + +func (v semverVersion) IsRange() bool { + return false +} + +func (v semverVersion) String() string { + return string(v) +} + +type semverRange struct { + repr string // user-provided string representation + constraints *semver.Constraints +} + +func (r semverRange) Satisfied(version string) bool { + sv, err := semver.NewVersion(version) + if err != nil { + return false + } + + return r.constraints.Check(sv) +} + +func (r semverRange) IsRange() bool { + return true +} + +func (r semverRange) String() string { + return r.repr +} + +// coerce takes an incomplete semver range (e.g. '1' or '1.2') and turns them into a valid constraint. github.com/mastermind/semver's +// default behavior will fill any a missing minor/patch with 0's, so we bypass that to create ranges; e.g. +// +// '1' -> '1.x' +// '1.2' -> '1.2.x' +func coerce(semverRange string) string { + if !coercableSemver.MatchString(semverRange) { + return semverRange + } + return semverRange + ".x" +} + +func ParametrizeQuery(path string, params map[string]string) string { + urlParsed, _ := url.Parse(path) + urlValues := urlParsed.Query() + for k, v := range params { + urlValues.Add(k, v) + } + return path + "?" + urlValues.Encode() +} diff --git a/bluemix/configuration/core_config/helpers.go b/bluemix/configuration/core_config/helpers.go new file mode 100644 index 0000000..b2a7fac --- /dev/null +++ b/bluemix/configuration/core_config/helpers.go @@ -0,0 +1,37 @@ +package core_config + +import "runtime" + +func DeterminePlatform() string { + arch := runtime.GOARCH + + switch runtime.GOOS { + case "windows": + if arch == "386" { + return "win32" + } else { + return "win64" + } + case "linux": + switch arch { + case "386": + return "linux32" + case "amd64": + return "linux64" + case "ppc64le": + return "ppc64le" + case "s390x": + return "s390x" + case "arm64": + return "linux-arm64" + } + case "darwin": + switch arch { + case "arm64": + return "osx-arm64" + default: + return "osx" + } + } + return "unknown" +} diff --git a/bluemix/motd/motd.go b/bluemix/motd/motd.go new file mode 100644 index 0000000..ed6ece4 --- /dev/null +++ b/bluemix/motd/motd.go @@ -0,0 +1,105 @@ +package motd + +import ( + "strconv" + "strings" + "time" + + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix" + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/api" + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/configuration/core_config" + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/terminal" + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/common/rest" + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin" +) + +type MODMessages struct { + VersionRange string `json:"versionRange"` + Region string `json:"region"` + OS string `json:"os"` + Message string `json:"message"` +} + +type MODResponse struct { + Messages []MODMessages `json:"messages"` +} + +func CheckMessageOftheDayForPlugin(pluginConfig plugin.PluginConfig) bool { + currentMessagOfTheDay := pluginConfig.Get("MessageOfTheDay") + if currentMessagOfTheDay == nil { + return false + } + if currentMessagOfTheDayTimestamp, ok := currentMessagOfTheDay.(string); ok { + lastCheckTime, parseErr := strconv.ParseInt(currentMessagOfTheDayTimestamp, 10, 64) + if parseErr != nil { + return false + } + return time.Since(time.Unix(lastCheckTime, 0)).Hours() < 24 + } + return false +} + +func DisplayMessageOfTheDay(client *rest.Client, config core_config.ReadWriter, pluginConfig plugin.PluginConfig, modURL string, ui terminal.UI, version string) { + // the pluginConfig variable will be cast-able to a pointer to a plugin config type if the display is for a plugin + + if config != nil { + if !config.CheckMessageOfTheDay() { + return + } + defer config.SetMessageOfTheDayTime() + } else { + if !CheckMessageOftheDayForPlugin(pluginConfig) { + return + } + defer pluginConfig.Set("MessageOfTheDayTime", time.Now().Unix()) + } + + var mod MODResponse + + _, err := client.Do(rest.GetRequest(modURL), &mod, nil) + if err != nil { + return + } + + for _, mes := range mod.Messages { + + if mes.VersionRange != "" { + constraint, err := api.NewSemverConstraint(mes.VersionRange) + if err != nil || !constraint.Satisfied(bluemix.Version.String()) { + continue + } + } + + // Only print message if targeted region matches or if message region is empty(print for all regions) + if mes.Region != "" { + skip := true + for _, region := range strings.Split(mes.Region, ",") { + region = strings.TrimSpace(region) + if strings.EqualFold(region, config.CurrentRegion().Name) { + skip = false + break + } + } + if skip { + continue + } + } + + // Only print message if matching OS or if message's OS is empty(print for all platforms) + if mes.OS != "" { + skip := true + for _, platform := range strings.Split(mes.OS, ",") { + platform = strings.TrimSpace(platform) + if strings.EqualFold(platform, core_config.DeterminePlatform()) { + skip = false + break + } + } + if skip { + continue + } + } + + ui.Warn(mes.Message) + } +} From fd4520086d745b210009710c713ce51f7fd0e101 Mon Sep 17 00:00:00 2001 From: Anupam Pokharel Date: Thu, 12 Oct 2023 15:30:53 -0500 Subject: [PATCH 2/7] reducing code translocated to public sdk --- bluemix/api/utils.go | 35 ++----------------- .../configuration/core_config/bx_config.go | 2 ++ go.mod | 3 +- go.sum | 2 ++ 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/bluemix/api/utils.go b/bluemix/api/utils.go index 469f6cf..25a8c20 100644 --- a/bluemix/api/utils.go +++ b/bluemix/api/utils.go @@ -2,11 +2,10 @@ package api import ( "fmt" - "net/url" - "path" "regexp" "strings" + "github.com/IBM-Cloud/ibm-cloud-cli-sdk/i18n" "github.com/Masterminds/semver" ) @@ -16,33 +15,14 @@ const ( var coercableSemver = regexp.MustCompile(`^\d+(\.\d+)?$`) -func GetFullURL(base string, path string) string { - if base == "" { - return path - } - - return base + CleanPath(path) -} - -func CleanPath(p string) string { - if p == "" { - return "/" - } - if !strings.HasPrefix(p, "/") { - p = "/" + p - } - return path.Clean(p) -} - type SemverConstraintInvalidError struct { Constraint string Err error } func (e SemverConstraintInvalidError) Error() string { - return "Invalid version constraint" - // return i18n.T("Version constraint {{.Constraint}} is invalid:\n", - // map[string]interface{}{"Constraint": e.Constraint}) + e.Err.Error() + return i18n.T("Version constraint {{.Constraint}} is invalid:\n", + map[string]interface{}{"Constraint": e.Constraint}) + e.Err.Error() } type SemverConstraint interface { @@ -115,12 +95,3 @@ func coerce(semverRange string) string { } return semverRange + ".x" } - -func ParametrizeQuery(path string, params map[string]string) string { - urlParsed, _ := url.Parse(path) - urlValues := urlParsed.Query() - for k, v := range params { - urlValues.Add(k, v) - } - return path + "?" + urlValues.Encode() -} diff --git a/bluemix/configuration/core_config/bx_config.go b/bluemix/configuration/core_config/bx_config.go index 31f8707..0c82875 100644 --- a/bluemix/configuration/core_config/bx_config.go +++ b/bluemix/configuration/core_config/bx_config.go @@ -9,6 +9,8 @@ import ( "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix" "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/configuration" "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/models" + + // "github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin" "github.com/fatih/structs" ) diff --git a/go.mod b/go.mod index cf7dc1d..e712b0f 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,9 @@ module github.com/IBM-Cloud/ibm-cloud-cli-sdk -go 1.20 +go 1.19 require ( + github.com/Masterminds/semver v1.5.0 github.com/fatih/color v1.7.1-0.20180516100307-2d684516a886 github.com/fatih/structs v1.0.1-0.20171020064819-f5faa72e7309 github.com/gofrs/flock v0.8.1 diff --git a/go.sum b/go.sum index 7c96db4..73de16e 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= 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= From d064a0c4b78f560ba2fe38cb11ea45d51524c401 Mon Sep 17 00:00:00 2001 From: Anupam Pokharel Date: Thu, 12 Oct 2023 15:39:09 -0500 Subject: [PATCH 3/7] restoring former name for function that checks on mod --- bluemix/motd/motd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluemix/motd/motd.go b/bluemix/motd/motd.go index ed6ece4..4cdbf3b 100644 --- a/bluemix/motd/motd.go +++ b/bluemix/motd/motd.go @@ -39,7 +39,7 @@ func CheckMessageOftheDayForPlugin(pluginConfig plugin.PluginConfig) bool { return false } -func DisplayMessageOfTheDay(client *rest.Client, config core_config.ReadWriter, pluginConfig plugin.PluginConfig, modURL string, ui terminal.UI, version string) { +func CheckMessageOfTheDay(client *rest.Client, config core_config.ReadWriter, pluginConfig plugin.PluginConfig, modURL string, ui terminal.UI, version string) { // the pluginConfig variable will be cast-able to a pointer to a plugin config type if the display is for a plugin if config != nil { From 7fac58703de572a8ce97f7b8143c14cf3a7a6d85 Mon Sep 17 00:00:00 2001 From: Anupam Pokharel Date: Tue, 17 Oct 2023 11:34:42 -0500 Subject: [PATCH 4/7] transferring unit tests for semantic versioning from cli core suite to sdk --- .../configuration/core_config/cf_config.json | 0 bluemix/configuration/core_config/config.json | 63 ++++++ bluemix/motd/motd_test.go | 202 ++++++++++++++++++ go.mod | 10 +- go.sum | 54 +++++ 5 files changed, 325 insertions(+), 4 deletions(-) create mode 100644 bluemix/configuration/core_config/cf_config.json create mode 100644 bluemix/configuration/core_config/config.json create mode 100644 bluemix/motd/motd_test.go diff --git a/bluemix/configuration/core_config/cf_config.json b/bluemix/configuration/core_config/cf_config.json new file mode 100644 index 0000000..e69de29 diff --git a/bluemix/configuration/core_config/config.json b/bluemix/configuration/core_config/config.json new file mode 100644 index 0000000..9c46bfd --- /dev/null +++ b/bluemix/configuration/core_config/config.json @@ -0,0 +1,63 @@ +{ + "APIEndpoint": "", + "IsPrivate": false, + "IsAccessFromVPC": false, + "ConsoleEndpoint": "", + "ConsolePrivateEndpoint": "", + "ConsolePrivateVPCEndpoint": "", + "CloudType": "", + "CloudName": "", + "CRIType": "", + "Region": "", + "RegionID": "", + "IAMEndpoint": "", + "IAMPrivateEndpoint": "", + "IAMPrivateVPCEndpoint": "", + "IAMToken": "", + "IAMRefreshToken": "", + "IsLoggedInAsCRI": false, + "Account": { + "GUID": "", + "Name": "", + "Owner": "" + }, + "Profile": { + "ID": "", + "Name": "", + "ComputeResource": { + "Name": "", + "ID": "" + }, + "User": { + "Name": "", + "ID": "" + } + }, + "ResourceGroup": { + "GUID": "", + "Name": "", + "State": "", + "Default": false, + "QuotaID": "" + }, + "LoginAt": "0001-01-01T00:00:00Z", + "CFEETargeted": false, + "CFEEEnvID": "", + "PluginRepos": null, + "SSLDisabled": false, + "Locale": "", + "MessageOfTheDayTime": 0, + "LastSessionUpdateTime": 1697560381, + "Trace": "", + "ColorEnabled": "", + "HTTPTimeout": 0, + "CLIInfoEndpoint": "", + "CheckCLIVersionDisabled": false, + "UsageStatsDisabled": false, + "UsageStatsEnabled": false, + "UsageStatsEnabledLastUpdate": "0001-01-01T00:00:00Z", + "SDKVersion": "1.1.1", + "UpdateCheckInterval": 0, + "UpdateRetryCheckInterval": 0, + "UpdateNotificationInterval": 0 +} \ No newline at end of file diff --git a/bluemix/motd/motd_test.go b/bluemix/motd/motd_test.go new file mode 100644 index 0000000..e4521d1 --- /dev/null +++ b/bluemix/motd/motd_test.go @@ -0,0 +1,202 @@ +package motd_test + +import ( + "fmt" + + . "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/api" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Versioning utils", func() { + Describe("SemverConstraint", func() { + + type constraintChecks struct { + prints string + satisfies []string + unsatisfies []string + } + + Context("When constraint is a specific version", func() { + for version, checks := range map[string]constraintChecks{ + "0.1.1": { + satisfies: []string{"0.1.1"}, + unsatisfies: []string{"1.2.3", "999.0.0"}, + }, + "1.2.3": { + satisfies: []string{"1.2.3"}, + unsatisfies: []string{"0.1.1", "999.0.0"}, + }, + "999.0.0": { + satisfies: []string{"999.0.0"}, + unsatisfies: []string{"0.1.1", "1.2.3"}, + }, + } { + It(version, func() { + version, checks := version, checks // gotcha + + sv, err := NewSemverConstraint(version) + Expect(err).ToNot(HaveOccurred()) + Expect(sv).ToNot(BeNil()) + Expect(sv.IsRange()).To(BeFalse(), "should return a version SemverConstraint") + Expect(sv.String()).To(Equal(version), "should print itself") + + Expect(sv.Satisfied(checks.satisfies[0])).To(BeTrue(), "should be satisfied by itself") + for _, v := range checks.unsatisfies { + Expect(sv.Satisfied(v)).To(BeFalse(), "should be unsatisfied by other version '%s'") + } + + }) + } + }) + + Context("When constraint is a range", func() { + for constraint, checks := range map[string]constraintChecks{ + /* catch all range */ + ConstraintAllVersions: { + satisfies: []string{"0.1.1", "1.2.3", "999.0.0"}, + }, + + /* tilde ranges */ + "~1": { + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + "~1.2": { + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999"}, + unsatisfies: []string{"0.9999.9999", "1.3.0", "1.1.9999", "2.0.0", "12.1.2"}, + }, + "~1.2.3": { + satisfies: []string{"1.2.3", "1.2.9999"}, + unsatisfies: []string{"0.9999.9999", "1.3.0", "1.1.9999", "2.0.0", "12.1.2"}, + }, + + /* caret ranges */ + "^1": { + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + "^1.2": { + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999", "1.3.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.0", "12.1.2"}, + }, + "^1.2.3": { + satisfies: []string{"1.2.3", "1.2.9999", "1.3.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.0", "12.1.2"}, + }, + + /* comparison ranges */ + ">=1.0.0, <2.0.0": { + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + ">=1.2.0, <2.0.0": { + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999", "1.3.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.0", "12.1.2"}, + }, + ">=1.2.3, <2.0.0": { + satisfies: []string{"1.2.3", "1.2.9999", "1.3.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.0", "12.1.2"}, + }, + ">=1.2.3, <=2.0.0": { + satisfies: []string{"1.2.3", "1.2.9999", "1.3.0", "2.0.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.1", "12.1.2"}, + }, + + /* dash ranges */ + "1 - 1.9999.9999": { + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + "1.2 - 1.9999.9999": { + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999", "1.3.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.0", "12.1.2"}, + }, + "1.2.3 - 1.9999.9999": { + satisfies: []string{"1.2.3", "1.2.9999", "1.3.0"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "2.0.0", "12.1.2"}, + }, + "1.2.3 - 2": { + satisfies: []string{"1.2.3", "1.2.9999", "1.3.0", "2.0.0", "2.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "12.1.2"}, + }, + + /* wildcard ranges */ + "1.x": { + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + "1.2.X": { + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "1.3.0", "2.0.0", "12.1.2"}, + }, + + /* hybrid */ + ">=1.2.*": { + satisfies: []string{"1.2.3", "1.2.9999", "1.3.0", "2.0.0", "2.0.1", "12.1.2"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999"}, + }, + + /* coercion */ + "1": { + prints: "1.x", + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + "1.2": { + prints: "1.2.x", + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "1.3.0", "2.0.0", "12.1.2"}, + }, + "v1": { + prints: "1.x", + satisfies: []string{"1.2.3", "1.0.0", "1.9999.9999"}, + unsatisfies: []string{"0.9999.9999", "2.0.0", "12.1.2"}, + }, + "v1.2": { + prints: "1.2.x", + satisfies: []string{"1.2.0", "1.2.3", "1.2.9999"}, + unsatisfies: []string{"0.9999.9999", "1.1.9999", "1.3.0", "2.0.0", "12.1.2"}, + }, + } { + It(constraint, func(constraint string, checks constraintChecks) func() { + return func() { + sv, err := NewSemverConstraint(constraint) + Expect(err).ToNot(HaveOccurred()) + Expect(sv).ToNot(BeNil()) + + fmt.Printf("constraint is range: %T\n", sv) + Expect(sv.IsRange()).To(BeTrue(), "should return a range SemverConstraint") + + if checks.prints == "" { + checks.prints = constraint + } + Expect(sv.String()).To(Equal(checks.prints), "should print itself") + + for _, v := range checks.satisfies { + Expect(sv.Satisfied(v)).To(BeTrue(), "should be satisfied by '%s'", v) + } + + for _, v := range checks.unsatisfies { + Expect(sv.Satisfied(v)).To(BeFalse(), "should not be satisfied by '%s'", v) + } + } + }(constraint, checks)) + } + }) + + Context("Invalid constraint", func() { + for _, constraint := range []string{ + "not-a-version", "1.2.3.4", "a.b.c", + } { + It("Returns an error", func() { + constraint := constraint // gotcha + sv, err := NewSemverConstraint(constraint) + Expect(err).To(HaveOccurred()) + Expect(sv).To(BeNil()) + }) + } + }) + + }) +}) diff --git a/go.mod b/go.mod index e712b0f..38cd0d7 100644 --- a/go.mod +++ b/go.mod @@ -10,11 +10,11 @@ require ( github.com/mattn/go-colorable v0.0.0-20160210001857-9fdad7c47650 github.com/mattn/go-runewidth v0.0.0-20151118072159-d96d1bd051f2 github.com/nicksnyder/go-i18n/v2 v2.2.0 - github.com/onsi/ginkgo v1.6.0 - github.com/onsi/gomega v1.10.0 + github.com/onsi/ginkgo v1.16.5 + github.com/onsi/gomega v1.10.1 github.com/spf13/cobra v1.0.0 github.com/spf13/pflag v1.0.3 - github.com/stretchr/testify v1.2.2 + github.com/stretchr/testify v1.5.1 golang.org/x/crypto v0.12.0 golang.org/x/text v0.12.0 gopkg.in/cheggaaa/pb.v1 v1.0.15 @@ -24,15 +24,17 @@ require ( require ( github.com/BurntSushi/toml v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/hpcloud/tail v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035 // indirect + github.com/nxadm/tail v1.4.8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.11.0 // indirect - golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect diff --git a/go.sum b/go.sum index 73de16e..a04dc0c 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee 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/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= @@ -29,11 +30,14 @@ github.com/fatih/structs v1.0.1-0.20171020064819-f5faa72e7309 h1:e3z/5nE0uPKuqOc github.com/fatih/structs v1.0.1-0.20171020064819-f5faa72e7309/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= 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/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 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= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -43,11 +47,20 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 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.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 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/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -83,11 +96,20 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nicksnyder/go-i18n/v2 v2.2.0 h1:MNXbyPvd141JJqlU6gJKrczThxJy+kdCNivxZpBQFkw= github.com/nicksnyder/go-i18n/v2 v2.2.0/go.mod h1:4OtLfzqyAxsscyCb//3gfqSvBc81gImX91LrZzczN1o= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.0 h1:Gwkk+PTu/nfOwNMtUB/mRUv0X7ewW5dO4AERT1ThVKo= github.com/onsi/gomega v1.10.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -115,46 +137,67 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6 github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +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/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= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 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-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/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-20181220203305-927f97764cc3/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-20190522155817-f3200d17e092/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/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 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-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-20180909124046-d0be0721c37e/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= @@ -163,13 +206,24 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm 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-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= From a7f4e426ad67cc6d3e1620b0eb8bfea27feb33cd Mon Sep 17 00:00:00 2001 From: Anupam Pokharel Date: Tue, 17 Oct 2023 12:12:59 -0500 Subject: [PATCH 5/7] adding an exception for the resource exhaustion vulnerability --- .nancy-ignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.nancy-ignore b/.nancy-ignore index 024ccbc..ee1c078 100644 --- a/.nancy-ignore +++ b/.nancy-ignore @@ -1 +1,2 @@ CVE-2022-32149 # No upgrade path for github.com/Xuanwo/go-locale, github.com/onsi/gomega and github.com/onsi/ginkgo/v2 at this time +CVE-2023-39325 # The CLI SDK does not host a server (and the network clients made available here will not behave maliciously as described in the issue), so this vulnerability is not a concern \ No newline at end of file From 861cf2b312b4c802c7f89b88dc02b494ca5a27c2 Mon Sep 17 00:00:00 2001 From: Anupam Pokharel Date: Thu, 11 Jul 2024 09:31:26 -0500 Subject: [PATCH 6/7] aerex comments --- bluemix/configuration/core_config/bx_config.go | 1 - bluemix/motd/motd.go | 2 +- go.mod | 4 +--- go.sum | 8 -------- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/bluemix/configuration/core_config/bx_config.go b/bluemix/configuration/core_config/bx_config.go index 0c82875..588c444 100644 --- a/bluemix/configuration/core_config/bx_config.go +++ b/bluemix/configuration/core_config/bx_config.go @@ -10,7 +10,6 @@ import ( "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/configuration" "github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/models" - // "github.com/IBM-Cloud/ibm-cloud-cli-sdk/plugin" "github.com/fatih/structs" ) diff --git a/bluemix/motd/motd.go b/bluemix/motd/motd.go index 4cdbf3b..db90df6 100644 --- a/bluemix/motd/motd.go +++ b/bluemix/motd/motd.go @@ -39,7 +39,7 @@ func CheckMessageOftheDayForPlugin(pluginConfig plugin.PluginConfig) bool { return false } -func CheckMessageOfTheDay(client *rest.Client, config core_config.ReadWriter, pluginConfig plugin.PluginConfig, modURL string, ui terminal.UI, version string) { +func CheckMessageOfTheDay(client *rest.Client, config core_config.ReadWriter, pluginConfig plugin.PluginConfig, modURL string, ui terminal.UI) { // the pluginConfig variable will be cast-able to a pointer to a plugin config type if the display is for a plugin if config != nil { diff --git a/go.mod b/go.mod index 38cd0d7..8e6ad0b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/IBM-Cloud/ibm-cloud-cli-sdk -go 1.19 +go 1.22.4 require ( github.com/Masterminds/semver v1.5.0 @@ -26,7 +26,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/hpcloud/tail v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035 // indirect github.com/nxadm/tail v1.4.8 // indirect @@ -36,6 +35,5 @@ require ( golang.org/x/term v0.11.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/protobuf v1.30.0 // indirect - gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect ) diff --git a/go.sum b/go.sum index a04dc0c..68c2082 100644 --- a/go.sum +++ b/go.sum @@ -28,7 +28,6 @@ github.com/fatih/color v1.7.1-0.20180516100307-2d684516a886 h1:NAFoy+QgUpERgK3y1 github.com/fatih/color v1.7.1-0.20180516100307-2d684516a886/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.0.1-0.20171020064819-f5faa72e7309 h1:e3z/5nE0uPKuqOc75vXcdV513niF/KDgDddVC8eF9MM= github.com/fatih/structs v1.0.1-0.20171020064819-f5faa72e7309/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -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/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -68,7 +67,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg 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/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -100,14 +98,11 @@ github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.0 h1:Gwkk+PTu/nfOwNMtUB/mRUv0X7ewW5dO4AERT1ThVKo= -github.com/onsi/gomega v1.10.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -139,7 +134,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -210,7 +204,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -234,7 +227,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.15 h1:1WP0I1XIkfylrOuo3YeOAt4QXsvESM1enkg3vH6FDmI= gopkg.in/cheggaaa/pb.v1 v1.0.15/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= From d80258103216b4c94c5a696dc937d1ed29ed88d1 Mon Sep 17 00:00:00 2001 From: Anupam Pokharel <120498245+tonystarkjr3@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:05:28 -0500 Subject: [PATCH 7/7] add error-handling on deferred function Co-authored-by: Aerex --- bluemix/motd/motd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bluemix/motd/motd.go b/bluemix/motd/motd.go index db90df6..c40b544 100644 --- a/bluemix/motd/motd.go +++ b/bluemix/motd/motd.go @@ -51,7 +51,12 @@ func CheckMessageOfTheDay(client *rest.Client, config core_config.ReadWriter, pl if !CheckMessageOftheDayForPlugin(pluginConfig) { return } - defer pluginConfig.Set("MessageOfTheDayTime", time.Now().Unix()) + defer func() error { + if err := pluginConfig.Set("MessageOfTheDayTime", time.Now().Unix()); err != nil { + return err + } + return nil + }() } var mod MODResponse