Skip to content

Commit a24848d

Browse files
committed
use sets
1 parent 09fc81f commit a24848d

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

internal/provider/convert.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func FromStringSliceToList(slice []string) types.List {
4343
func FromStringList[T any, TMessage interface {
4444
*T
4545
GetValues() []string
46-
}](src TMessage) types.List {
46+
}](src TMessage) types.Set {
4747
if src == nil {
48-
return types.ListNull(types.StringType)
48+
return types.SetNull(types.StringType)
4949
}
5050
fields := make([]attr.Value, 0)
5151
for _, v := range (src).GetValues() {
5252
fields = append(fields, types.StringValue(v))
5353
}
54-
return types.ListValueMust(types.StringType, fields)
54+
return types.SetValueMust(types.StringType, fields)
5555
}
5656

5757
// FromStringListToSet converts a Settings_StringList to a types.List
@@ -329,7 +329,7 @@ func ToBearerTokenFormat(src types.String) *pb.BearerTokenFormat {
329329
}
330330
}
331331

332-
func ToRouteStringList(ctx context.Context, dst **pb.Route_StringList, src types.List, diagnostics *diag.Diagnostics) {
332+
func ToRouteStringList(ctx context.Context, dst **pb.Route_StringList, src types.Set, diagnostics *diag.Diagnostics) {
333333
if src.IsNull() || src.IsUnknown() {
334334
*dst = nil
335335
return
@@ -341,7 +341,7 @@ func ToRouteStringList(ctx context.Context, dst **pb.Route_StringList, src types
341341
}
342342
}
343343

344-
func ToSettingsStringList(ctx context.Context, dst **pb.Settings_StringList, src types.List, diagnostics *diag.Diagnostics) {
344+
func ToSettingsStringList(ctx context.Context, dst **pb.Settings_StringList, src types.Set, diagnostics *diag.Diagnostics) {
345345
if src.IsNull() || src.IsUnknown() {
346346
*dst = nil
347347
return

internal/provider/convert_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -701,22 +701,22 @@ func TestFromStringList(t *testing.T) {
701701
for _, tc := range []struct {
702702
name string
703703
in *pb.Route_StringList
704-
expect types.List
704+
expect types.Set
705705
}{
706706
{
707707
"null",
708708
nil,
709-
types.ListNull(types.StringType),
709+
types.SetNull(types.StringType),
710710
},
711711
{
712712
"empty",
713713
&pb.Route_StringList{},
714-
types.ListValueMust(types.StringType, []attr.Value{}),
714+
types.SetValueMust(types.StringType, []attr.Value{}),
715715
},
716716
{
717717
"entries",
718718
&pb.Route_StringList{Values: []string{"a", "b", "c"}},
719-
types.ListValueMust(types.StringType, []attr.Value{
719+
types.SetValueMust(types.StringType, []attr.Value{
720720
types.StringValue("a"), types.StringValue("b"), types.StringValue("c"),
721721
}),
722722
},
@@ -769,31 +769,31 @@ func TestToRouteStringList(t *testing.T) {
769769

770770
for _, tc := range []struct {
771771
name string
772-
in types.List
772+
in types.Set
773773
expect *pb.Route_StringList
774774
errorCount int
775775
}{
776776
{
777777
"null",
778-
types.ListNull(types.StringType),
778+
types.SetNull(types.StringType),
779779
nil,
780780
0,
781781
},
782782
{
783783
"invalid",
784-
types.ListValueMust(types.BoolType, []attr.Value{types.BoolValue(true)}),
784+
types.SetValueMust(types.BoolType, []attr.Value{types.BoolValue(true)}),
785785
nil,
786786
1,
787787
},
788788
{
789789
"empty",
790-
types.ListValueMust(types.StringType, []attr.Value{}),
790+
types.SetValueMust(types.StringType, []attr.Value{}),
791791
&pb.Route_StringList{Values: []string{}},
792792
0,
793793
},
794794
{
795795
"entries",
796-
types.ListValueMust(types.StringType, []attr.Value{
796+
types.SetValueMust(types.StringType, []attr.Value{
797797
types.StringValue("a"), types.StringValue("b"), types.StringValue("c"),
798798
}),
799799
&pb.Route_StringList{Values: []string{
@@ -816,31 +816,31 @@ func TestToSettingsStringList(t *testing.T) {
816816

817817
for _, tc := range []struct {
818818
name string
819-
in types.List
819+
in types.Set
820820
expect *pb.Settings_StringList
821821
errorCount int
822822
}{
823823
{
824824
"null",
825-
types.ListNull(types.StringType),
825+
types.SetNull(types.StringType),
826826
nil,
827827
0,
828828
},
829829
{
830830
"invalid",
831-
types.ListValueMust(types.BoolType, []attr.Value{types.BoolValue(true)}),
831+
types.SetValueMust(types.BoolType, []attr.Value{types.BoolValue(true)}),
832832
nil,
833833
1,
834834
},
835835
{
836836
"empty",
837-
types.ListValueMust(types.StringType, []attr.Value{}),
837+
types.SetValueMust(types.StringType, []attr.Value{}),
838838
&pb.Settings_StringList{Values: []string{}},
839839
0,
840840
},
841841
{
842842
"entries",
843-
types.ListValueMust(types.StringType, []attr.Value{
843+
types.SetValueMust(types.StringType, []attr.Value{
844844
types.StringValue("a"), types.StringValue("b"), types.StringValue("c"),
845845
}),
846846
&pb.Settings_StringList{Values: []string{

internal/provider/route_model.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type RouteModel struct {
2525
HostRewriteHeader types.String `tfsdk:"host_rewrite_header"`
2626
ID types.String `tfsdk:"id"`
2727
IdleTimeout timetypes.GoDuration `tfsdk:"idle_timeout"`
28-
IDPAccessTokenAllowedAudiences types.Set `tfsdk:"idp_access_token_allowed_audiences"`
28+
IDPAccessTokenAllowedAudiences types.Set `tfsdk:"idp_access_token_allowed_audiences"`
2929
IDPClientID types.String `tfsdk:"idp_client_id"`
3030
IDPClientSecret types.String `tfsdk:"idp_client_secret"`
3131
JWTGroupsFilter types.Object `tfsdk:"jwt_groups_filter"`

internal/provider/route_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestConvertRoute(t *testing.T) {
114114
KubernetesServiceAccountTokenFile: types.StringValue("/path/to/token"),
115115
JWTIssuerFormat: types.StringValue("IssuerURI"),
116116
BearerTokenFormat: types.StringValue("idp_access_token"),
117-
IDPAccessTokenAllowedAudiences: types.ListValueMust(types.StringType, []attr.Value{
117+
IDPAccessTokenAllowedAudiences: types.SetValueMust(types.StringType, []attr.Value{
118118
types.StringValue("a"), types.StringValue("b"), types.StringValue("c"),
119119
}),
120120
}
@@ -167,7 +167,7 @@ func TestConvertRoute(t *testing.T) {
167167
TLSCustomCAKeyPairID: types.StringValue("custom-ca-1"),
168168
KubernetesServiceAccountTokenFile: types.StringValue("/path/to/token"),
169169
BearerTokenFormat: types.StringValue("idp_access_token"),
170-
IDPAccessTokenAllowedAudiences: types.ListValueMust(types.StringType, []attr.Value{
170+
IDPAccessTokenAllowedAudiences: types.SetValueMust(types.StringType, []attr.Value{
171171
types.StringValue("X"), types.StringValue("Y"), types.StringValue("Z"),
172172
}),
173173
}

internal/provider/settings_model.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type SettingsModel struct {
5858
IdentityProviderPing types.Object `tfsdk:"identity_provider_ping"`
5959
IdentityProviderRefreshInterval timetypes.GoDuration `tfsdk:"identity_provider_refresh_interval"`
6060
IdentityProviderRefreshTimeout timetypes.GoDuration `tfsdk:"identity_provider_refresh_timeout"`
61-
IDPAccessTokenAllowedAudiences types.List `tfsdk:"idp_access_token_allowed_audiences"`
61+
IDPAccessTokenAllowedAudiences types.Set `tfsdk:"idp_access_token_allowed_audiences"`
6262
IdpClientID types.String `tfsdk:"idp_client_id"`
6363
IdpClientSecret types.String `tfsdk:"idp_client_secret"`
6464
IdpProvider types.String `tfsdk:"idp_provider"`

0 commit comments

Comments
 (0)