Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump github.com/urfave/cli/v2 from 2.4.8 to 2.8.1 #139

Merged
merged 2 commits into from May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
255 changes: 0 additions & 255 deletions fileutil/map_input_source.go

This file was deleted.

21 changes: 20 additions & 1 deletion fileutil/properties_file_loader.go
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"
"os"
"runtime"
"strconv"
"strings"

"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -50,9 +51,27 @@ func readPropertiesFile(filename string) (map[interface{}]interface{}, error) {
return nil, err
}

// Other file formats would provide more type information, and unmarshalling would
// create correct types. Properties files aren't that useful, so we have to enforce
// some types by ourselves. We have to keep an eye on other types beside boolean,
// but this one seems good enough for now.
coerceBooleanValues(config)

return config, nil
}

func coerceBooleanValues(m map[interface{}]interface{}) {
for k, v := range m {
switch v := v.(type) {
case string:
parsed, err := strconv.ParseBool(v)
if err == nil {
m[k] = parsed
}
}
}
}

type propertiesSourceContext struct {
FilePath string
}
Expand All @@ -66,7 +85,7 @@ func NewPropertiesSourceFromFile(file string) (altsrc.InputSourceContext, error)
return nil, fmt.Errorf("Unable to load Properties file '%s': inner error: \n'%v'", ysc.FilePath, err.Error())
}

return &MapInputSource{valueMap: results}, nil
return altsrc.NewMapInputSource(file, results), nil
}

// NewPropertiesSourceFromFlagFunc creates a new Properties InputSourceContext from a provided flag name and source context.
Expand Down
2 changes: 1 addition & 1 deletion fileutil/properties_file_loader_test.go
Expand Up @@ -14,7 +14,7 @@ func TestReadPropertiesFile(t *testing.T) {
t.FailNow()
}

if props["host"] != "localhost" || props["proxyHost"] != "test" || props["protocol"] != "https://" || props["chunk"] != "" || props["boolean"] != "true" {
if props["host"] != "localhost" || props["proxyHost"] != "test" || props["protocol"] != "https://" || props["chunk"] != "" || props["boolean"] != true {
fmt.Printf("props: %q", props)
t.Error("Error properties not loaded correctly")
t.Fail()
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Expand Up @@ -11,7 +11,7 @@ require (
github.com/prometheus/client_model v0.2.0
github.com/prometheus/exporter-toolkit v0.7.1
github.com/stretchr/testify v1.7.1
github.com/urfave/cli/v2 v2.4.8
github.com/urfave/cli/v2 v2.8.1
k8s.io/klog/v2 v2.60.1
)

Expand All @@ -32,6 +32,7 @@ require (
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20211015174653-db2dff38ab41 // indirect
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Expand Up @@ -218,8 +218,10 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/cli/v2 v2.4.8 h1:9HuvvddU3oEJr1tJlwUVVsk3snVWMuKSpyAO+SzTNuI=
github.com/urfave/cli/v2 v2.4.8/go.mod h1:oDzoM7pVwz6wHn5ogWgFUU1s4VJayeQS+aEZDqXIEJs=
github.com/urfave/cli/v2 v2.8.1 h1:CGuYNZF9IKZY/rfBe3lJpccSoIY1ytfvmgQT90cNOl4=
github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down