Skip to content

Commit 1af662b

Browse files
erkasahidvelji
andauthored
chore(prefab): bump minimum Go requirement to 1.24 and modernize (#768)
Signed-off-by: Roman Dmytrenko <[email protected]> Co-authored-by: Sahid Velji <[email protected]>
1 parent a3443bc commit 1af662b

File tree

6 files changed

+30
-45
lines changed

6 files changed

+30
-45
lines changed

providers/prefab/go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/open-feature/go-sdk-contrib/providers/prefab
22

3-
go 1.23.0
4-
5-
toolchain go1.24.4
3+
go 1.24.0
64

75
require (
86
github.com/open-feature/go-sdk v1.15.1
@@ -20,7 +18,6 @@ require (
2018
github.com/sosodev/duration v1.3.1 // indirect
2119
github.com/spaolacci/murmur3 v1.1.0 // indirect
2220
go.uber.org/mock v0.5.2 // indirect
23-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
2421
golang.org/x/net v0.38.0 // indirect
2522
google.golang.org/protobuf v1.34.2 // indirect
2623
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect

providers/prefab/go.sum

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5-
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
6-
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
75
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
86
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
9-
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
10-
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
117
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
128
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
139
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@@ -19,8 +15,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1915
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2016
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
2117
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
22-
github.com/open-feature/go-sdk v1.12.0 h1:V0MAG3lC9o7Pmq0gxlqtKpoasDTm3to9vuvZKyUhhPk=
23-
github.com/open-feature/go-sdk v1.12.0/go.mod h1:UDNuwVrwY5FRHIluVRYzvxuS3nBkhjE6o4tlwFuHxiI=
2418
github.com/open-feature/go-sdk v1.15.1 h1:TC3FtHtOKlGlIbSf3SEpxXVhgTd/bCbuc39XHIyltkw=
2519
github.com/open-feature/go-sdk v1.15.1/go.mod h1:2WAFYzt8rLYavcubpCoiym3iSCXiHdPB6DxtMkv2wyo=
2620
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -41,24 +35,18 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
4135
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
4236
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
4337
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
44-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
45-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4638
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4739
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4840
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
4941
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
5042
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
51-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
52-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
5343
golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
54-
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
55-
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
5644
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
5745
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
5846
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5947
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
60-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
61-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
48+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
49+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
6250
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
6351
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
6452
gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y=

providers/prefab/internal/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func ToPrefabContext(evalCtx of.FlattenedContext) (prefab.ContextSet, error) {
2121
}
2222
key, subkey := parts[0], parts[1]
2323
if _, exists := prefabContext.Data[key]; !exists {
24-
prefabContext.WithNamedContextValues(key, map[string]interface{}{
24+
prefabContext.WithNamedContextValues(key, map[string]any{
2525
subkey: v,
2626
})
2727
} else {

providers/prefab/pkg/provider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func verifyStateString(p *Provider, defaultValue string) (bool, of.StringResolut
259259
return false, of.StringResolutionDetail{}
260260
}
261261

262-
func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue interface{}, evalCtx of.FlattenedContext) of.InterfaceResolutionDetail {
262+
func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue any, evalCtx of.FlattenedContext) of.InterfaceResolutionDetail {
263263
shouldReturn, returnValue := verifyStateObject(p, defaultValue)
264264
if shouldReturn {
265265
return returnValue
@@ -276,9 +276,9 @@ func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultVal
276276
}
277277
}
278278

279-
var value interface{}
279+
var value any
280280
switch castedDefaultValue := defaultValue.(type) {
281-
case map[string]interface{}:
281+
case map[string]any:
282282
value, _ = p.PrefabClient.GetJSONValueWithDefault(flag, prefabContext, castedDefaultValue)
283283
case []string:
284284
value, _ = p.PrefabClient.GetStringSliceValueWithDefault(flag, prefabContext, castedDefaultValue)
@@ -294,7 +294,7 @@ func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultVal
294294
}
295295
}
296296

297-
func verifyStateObject(p *Provider, defaultValue interface{}) (bool, of.InterfaceResolutionDetail) {
297+
func verifyStateObject(p *Provider, defaultValue any) (bool, of.InterfaceResolutionDetail) {
298298
if p.status != of.ReadyState {
299299
if p.status == of.NotReadyState {
300300
return true, of.InterfaceResolutionDetail{

providers/prefab/pkg/provider_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package prefab
22

33
type ProviderConfig struct {
4-
Configs map[string]interface{}
4+
Configs map[string]any
55
APIKey string
66
APIURLs []string
77
Sources []string

providers/prefab/pkg/provider_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121
)
2222

2323
func TestBooleanEvaluation(t *testing.T) {
24-
flattenedContext := map[string]interface{}{}
24+
flattenedContext := map[string]any{}
2525

2626
resolution := provider.BooleanEvaluation(context.Background(), "sample_bool", false, flattenedContext)
2727
if resolution.Value != true {
@@ -35,7 +35,7 @@ func TestBooleanEvaluation(t *testing.T) {
3535

3636
evalCtx := of.NewEvaluationContext(
3737
"",
38-
map[string]interface{}{},
38+
map[string]any{},
3939
)
4040
enabled, err := ofClient.BooleanValue(context.Background(), "sample_bool", false, evalCtx)
4141
require.Nil(t, err)
@@ -78,7 +78,7 @@ func TestBooleanEvaluation(t *testing.T) {
7878
// }
7979

8080
func TestFloatEvaluation(t *testing.T) {
81-
flattenedContext := map[string]interface{}{}
81+
flattenedContext := map[string]any{}
8282

8383
resolution := provider.FloatEvaluation(context.Background(), "sample_double", 1.2, flattenedContext)
8484
if resolution.Value != 12.12 {
@@ -92,15 +92,15 @@ func TestFloatEvaluation(t *testing.T) {
9292

9393
evalCtx := of.NewEvaluationContext(
9494
"",
95-
map[string]interface{}{},
95+
map[string]any{},
9696
)
9797
value, err := ofClient.FloatValue(context.Background(), "sample_double", 1.2, evalCtx)
9898
require.Nil(t, err)
9999
require.Equal(t, 12.12, value)
100100
}
101101

102102
func TestIntEvaluation(t *testing.T) {
103-
flattenedContext := map[string]interface{}{}
103+
flattenedContext := map[string]any{}
104104

105105
resolution := provider.IntEvaluation(context.Background(), "sample_int", 1, flattenedContext)
106106
if resolution.Value != 123 {
@@ -114,15 +114,15 @@ func TestIntEvaluation(t *testing.T) {
114114

115115
evalCtx := of.NewEvaluationContext(
116116
"",
117-
map[string]interface{}{},
117+
map[string]any{},
118118
)
119119
value, err := ofClient.IntValue(context.Background(), "sample_int", 1, evalCtx)
120120
require.Nil(t, err)
121121
require.Equal(t, int64(123), value)
122122
}
123123

124124
func TestStringEvaluation(t *testing.T) {
125-
flattenedContext := map[string]interface{}{}
125+
flattenedContext := map[string]any{}
126126

127127
resolution := provider.StringEvaluation(context.Background(), "sample", "default", flattenedContext)
128128
if resolution.Value != "test sample value" {
@@ -136,7 +136,7 @@ func TestStringEvaluation(t *testing.T) {
136136

137137
evalCtx := of.NewEvaluationContext(
138138
"",
139-
map[string]interface{}{},
139+
map[string]any{},
140140
)
141141
value, err := ofClient.StringValue(context.Background(), "sample", "default", evalCtx)
142142
require.Nil(t, err)
@@ -145,7 +145,7 @@ func TestStringEvaluation(t *testing.T) {
145145

146146
// TODO test and enable when json/yaml parsing is implemented
147147
func TestObjectEvaluation(t *testing.T) {
148-
flattenedContext := map[string]interface{}{}
148+
flattenedContext := map[string]any{}
149149

150150
t.Run("example.nested.path", func(t *testing.T) {
151151
resolution := provider.ObjectEvaluation(context.Background(), "example.nested.path", "default", flattenedContext)
@@ -154,7 +154,7 @@ func TestObjectEvaluation(t *testing.T) {
154154

155155
evalCtx := of.NewEvaluationContext(
156156
"",
157-
map[string]interface{}{},
157+
map[string]any{},
158158
)
159159

160160
t.Run("example.nested.path", func(t *testing.T) {
@@ -187,11 +187,11 @@ func TestConvertsNonEmptyFlattenedContextToContextSet(t *testing.T) {
187187
"device.type": "mobile",
188188
}
189189
expected := prefab.NewContextSet()
190-
expected.WithNamedContextValues("user", map[string]interface{}{
190+
expected.WithNamedContextValues("user", map[string]any{
191191
"name": "John",
192192
"age": 30,
193193
})
194-
expected.WithNamedContextValues("device", map[string]interface{}{
194+
expected.WithNamedContextValues("device", map[string]any{
195195
"type": "mobile",
196196
})
197197

@@ -204,7 +204,7 @@ func TestConvertsNonEmptyFlattenedContextToContextSet(t *testing.T) {
204204
}
205205

206206
func TestUninitializedProviderStates(t *testing.T) {
207-
flattenedContext := map[string]interface{}{}
207+
flattenedContext := map[string]any{}
208208

209209
providerConfig := prefabProvider.ProviderConfig{
210210
Sources: []string{"datafile://enabled.yaml"},
@@ -228,7 +228,7 @@ func TestUninitializedProviderStates(t *testing.T) {
228228
}
229229

230230
func TestErrorProviderStates(t *testing.T) {
231-
flattenedContext := map[string]interface{}{}
231+
flattenedContext := map[string]any{}
232232

233233
providerConfig := prefabProvider.ProviderConfig{
234234
Sources: []string{"datafile://non-existing.yaml"},
@@ -264,16 +264,16 @@ func TestEvaluationMethods(t *testing.T) {
264264

265265
evalCtx := of.NewEvaluationContext(
266266
"",
267-
map[string]interface{}{
267+
map[string]any{
268268
"user.id": "123",
269269
},
270270
)
271271

272272
tests := []struct {
273273
flag string
274-
defaultValue interface{}
274+
defaultValue any
275275
evalCtx of.EvaluationContext
276-
expected interface{}
276+
expected any
277277
expectedErrorCode of.ErrorCode
278278
}{
279279
{"sample_bool", false, evalCtx, true, ""},
@@ -285,25 +285,25 @@ func TestEvaluationMethods(t *testing.T) {
285285
{"sample_list", []string{"fallback1", "fallback2"}, evalCtx, []string{"a", "b"}, ""},
286286
{"invalid_user_context_bool", false, of.NewEvaluationContext(
287287
"",
288-
map[string]interface{}{
288+
map[string]any{
289289
"invalid": "123",
290290
},
291291
), false, of.InvalidContextCode},
292292
{"invalid_user_context_int", int64(43), of.NewEvaluationContext(
293293
"",
294-
map[string]interface{}{
294+
map[string]any{
295295
"invalid": "123",
296296
},
297297
), int64(43), of.InvalidContextCode},
298298
{"invalid_user_context_float", 1.2, of.NewEvaluationContext(
299299
"",
300-
map[string]interface{}{
300+
map[string]any{
301301
"invalid": "123",
302302
},
303303
), 1.2, of.InvalidContextCode},
304304
{"invalid_user_context_string", "a", of.NewEvaluationContext(
305305
"",
306-
map[string]interface{}{
306+
map[string]any{
307307
"invalid": "123",
308308
},
309309
), "a", of.InvalidContextCode},

0 commit comments

Comments
 (0)