Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pingidentity/pingcli

go 1.24.5
go 1.24.6

tool (
github.com/golangci/golangci-lint/v2/cmd/golangci-lint
Expand All @@ -10,7 +10,7 @@ tool (
require (
github.com/fatih/color v1.18.0
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-plugin v1.6.3
github.com/hashicorp/go-plugin v1.7.0
github.com/hashicorp/go-uuid v1.0.3
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/confmap v1.0.0
Expand All @@ -26,9 +26,9 @@ require (
github.com/rs/zerolog v1.34.0
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.7
golang.org/x/mod v0.26.0
golang.org/x/mod v0.27.0
google.golang.org/grpc v1.74.2
google.golang.org/protobuf v1.36.6
google.golang.org/protobuf v1.36.7
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE=
github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE=
github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg=
github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s=
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/butuzov/ireturn v0.4.0 h1:+s76bF/PfeKEdbG8b54aCocxXmi0wvYdOVsWxVO7n8E=
github.com/butuzov/ireturn v0.4.0/go.mod h1:ghI0FrCmap8pDWZwfPisFD1vEc56VKH4NpQUxDHta70=
github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc=
Expand Down Expand Up @@ -334,8 +334,8 @@ github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB1
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo=
github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw=
github.com/hashicorp/go-plugin v1.6.3 h1:xgHB+ZUSYeuJi96WtxEjzi23uh7YQpznjGh0U0UUrwg=
github.com/hashicorp/go-plugin v1.6.3/go.mod h1:MRobyh+Wc/nYy1V4KAXUiYfzxoYhs7V1mlH1Z7iY2h0=
github.com/hashicorp/go-plugin v1.7.0 h1:YghfQH/0QmPNc/AZMTFE3ac8fipZyZECHdDPshfk+mA=
github.com/hashicorp/go-plugin v1.7.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
Expand All @@ -354,8 +354,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4=
github.com/jgautheron/goconst v1.8.2/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs=
github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c=
github.com/jjti/go-spancheck v0.6.5 h1:lmi7pKxa37oKYIMScialXUK6hP3iY5F1gu+mLBPgYB8=
Expand Down Expand Up @@ -761,8 +761,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1051,8 +1051,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
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.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
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=
Expand Down
8 changes: 7 additions & 1 deletion internal/commands/config/get_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ func RunInternalConfigGet(koanfKey string) (err error) {
msgStr := fmt.Sprintf("Configuration values for profile '%s' and key '%s':\n", pName, koanfKey)

for _, opt := range options.Options() {
if opt.KoanfKey == "" || !strings.Contains(opt.KoanfKey, koanfKey) {
// We only want options that have a key in the configuration file
if opt.KoanfKey == "" {
continue
}

// Match the koanfKey (which can be a "parent key". E.g 'service.pingOne' would match all options like 'service.pingone.authentication.type') to all options.
if !strings.HasPrefix(strings.ToLower(opt.KoanfKey), strings.ToLower(koanfKey)) {
continue
}

Expand Down
10 changes: 10 additions & 0 deletions internal/commands/config/get_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ func Test_RunInternalConfigGet_InvalidProfileName(t *testing.T) {
err := RunInternalConfigGet("service")
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test RunInternalConfigGet function with case-insensitive keys
func Test_RunInternalConfigGet_CaseInsensitiveKeys(t *testing.T) {
testutils_koanf.InitKoanfs(t)

err := RunInternalConfigGet("SeRvIcE")
if err != nil {
t.Errorf("RunInternalConfigGet returned error: %v", err)
}
}
10 changes: 10 additions & 0 deletions internal/commands/config/set_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,13 @@ func Test_RunInternalConfigSet_NoKeyValue(t *testing.T) {
err := RunInternalConfigSet("")
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test Test_RunInternalConfigSet function succeeds with case-insensitive keys
func Test_RunInternalConfigSet_CaseInsensitiveKeys(t *testing.T) {
testutils_koanf.InitKoanfs(t)

err := RunInternalConfigSet("NoCoLoR=true")
if err != nil {
t.Errorf("RunInternalConfigSet returned error: %v", err)
}
}
6 changes: 3 additions & 3 deletions internal/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func KoanfKeys() (keys []string) {
func ValidateKoanfKey(koanfKey string) error {
validKeys := KoanfKeys()
for _, vKey := range validKeys {
if vKey == koanfKey {
if strings.EqualFold(vKey, koanfKey) {
return nil
}
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func ExpandedKoanfKeys() (keys []string) {
func ValidateParentKoanfKey(koanfKey string) error {
validKeys := ExpandedKoanfKeys()
for _, vKey := range validKeys {
if vKey == koanfKey {
if strings.EqualFold(vKey, koanfKey) {
return nil
}
}
Expand All @@ -77,7 +77,7 @@ func ValidateParentKoanfKey(koanfKey string) error {

func OptionFromKoanfKey(koanfKey string) (opt options.Option, err error) {
for _, opt := range options.Options() {
if opt.KoanfKey == koanfKey {
if strings.EqualFold(opt.KoanfKey, koanfKey) {
return opt, nil
}
}
Expand Down
35 changes: 35 additions & 0 deletions internal/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/pingidentity/pingcli/internal/configuration"
"github.com/pingidentity/pingcli/internal/configuration/options"
"github.com/pingidentity/pingcli/internal/testing/testutils"
"github.com/pingidentity/pingcli/internal/testing/testutils_koanf"
)
Expand Down Expand Up @@ -38,6 +39,16 @@ func Test_ValidateKoanfKey_EmptyKey(t *testing.T) {
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test ValidateKoanfKey supports case-insensitive keys
func Test_ValidateKoanfKey_CaseInsensitive(t *testing.T) {
testutils_koanf.InitKoanfs(t)

err := configuration.ValidateKoanfKey("NoCoLoR")
if err != nil {
t.Errorf("ValidateKoanfKey returned error: %v", err)
}
}

// Test ValidateParentKoanfKey function
func Test_ValidateParentKoanfKey(t *testing.T) {
testutils_koanf.InitKoanfs(t)
Expand Down Expand Up @@ -66,6 +77,16 @@ func Test_ValidateParentKoanfKey_EmptyKey(t *testing.T) {
testutils.CheckExpectedError(t, err, &expectedErrorPattern)
}

// Test ValidateParentKoanfKey supports case-insensitive keys
func Test_ValidateParentKoanfKey_CaseInsensitive(t *testing.T) {
testutils_koanf.InitKoanfs(t)

err := configuration.ValidateParentKoanfKey("SeRvIcE")
if err != nil {
t.Errorf("ValidateParentKoanfKey returned error: %v", err)
}
}

// Test OptionFromKoanfKey function
func Test_OptionFromKoanfKey(t *testing.T) {
testutils_koanf.InitKoanfs(t)
Expand All @@ -79,3 +100,17 @@ func Test_OptionFromKoanfKey(t *testing.T) {
t.Errorf("OptionFromKoanfKey returned invalid option: %v", opt)
}
}

// Test OptionFromKoanfKey supports case-insensitive keys
func Test_OptionFromKoanfKey_CaseInsensitive(t *testing.T) {
testutils_koanf.InitKoanfs(t)

opt, err := configuration.OptionFromKoanfKey("NoCoLoR")
if err != nil {
t.Errorf("OptionFromKoanfKey returned error: %v", err)
}

if opt.KoanfKey != options.RootColorOption.KoanfKey {
t.Errorf("OptionFromKoanfKey returned invalid option: %v", opt)
}
}