@@ -82,12 +82,12 @@ func (d *ProtocolsS3GroupsDataSource) Schema(ctx context.Context, req datasource
8282MarkdownDescription : "Additional information about the group" ,
8383Computed : true ,
8484},
85- "users" : schema.ListAttribute {
85+ "users" : schema.SetAttribute {
8686Computed : true ,
8787MarkdownDescription : "The list of users who belong to the group" ,
8888ElementType : types .StringType ,
8989},
90- "policies" : schema.ListAttribute {
90+ "policies" : schema.SetAttribute {
9191Computed : true ,
9292MarkdownDescription : "The list of policies that are attached to the group" ,
9393ElementType : types .StringType ,
@@ -154,44 +154,53 @@ func (d *ProtocolsS3GroupsDataSource) Read(ctx context.Context, req datasource.R
154154errorHandler .MakeAndReportError ("No SVM specified" , "either svm_name or filter must be specified" )
155155return
156156}
157- svmUUID , err := interfaces .GetSVMUUID (errorHandler , * client , data .Filter .SVMName .ValueString ())
157+
158+ // Get SVM info
159+ svm , err := interfaces .GetSvmByName (errorHandler , * client , data .Filter .SVMName .ValueString ())
158160if err != nil {
159- // error reporting done inside GetSVMUUID
160- return
161- }
162- if svmUUID == "" {
161+ // error reporting done inside GetSvmByName
163162errorHandler .MakeAndReportError ("No SVM found" , "SVM not found" )
164163return
165164}
166165
167- restInfo , err := interfaces .GetProtocolsS3Groups (errorHandler , * client , svmUUID , cluster .Version )
166+ restInfo , err := interfaces .GetProtocolsS3Groups (errorHandler , * client , svm . UUID , cluster .Version )
168167if err != nil {
169168// error reporting done inside GetProtocolsS3Groups
170169return
171170}
172171
173172data .S3Groups = make ([]ProtocolsS3GroupDataSourceModel , len (restInfo ))
174173for index , record := range restInfo {
175- // Users - map to simple string list
174+ // users - map to set
176175var users = make ([]string , len (record .Users ))
177176for i , user := range record .Users {
178177users [i ] = user .Name
179178}
180-
181- // Policies - map to simple string list
179+ usersSet , diags := types .SetValueFrom (ctx , types .StringType , users )
180+ resp .Diagnostics .Append (diags ... )
181+ if resp .Diagnostics .HasError () {
182+ return
183+ }
184+
185+ // policies - map to set
182186var policies = make ([]string , len (record .Policies ))
183187for i , policy := range record .Policies {
184188policies [i ] = policy .Name
185189}
190+ policiesSet , diags := types .SetValueFrom (ctx , types .StringType , policies )
191+ resp .Diagnostics .Append (diags ... )
192+ if resp .Diagnostics .HasError () {
193+ return
194+ }
186195
187196data .S3Groups [index ] = ProtocolsS3GroupDataSourceModel {
188- CxProfileName : types .String (data .CxProfileName ),
189- Name : types .StringValue (record .Name ),
190- Comment : types .StringValue (record .Comment ),
191- SVMName : types .StringValue (record .SVM .Name ),
192- Users : users ,
193- Policies : policies ,
194- ID : types .Int64Value (record .ID ),
197+ CxProfileName : types .String (data .CxProfileName ),
198+ Name : types .StringValue (record .Name ),
199+ Comment : types .StringValue (record .Comment ),
200+ SVMName : types .StringValue (record .SVM .Name ),
201+ Users : usersSet ,
202+ Policies : policiesSet ,
203+ ID : types .Int64Value (record .ID ),
195204}
196205}
197206
@@ -201,4 +210,4 @@ func (d *ProtocolsS3GroupsDataSource) Read(ctx context.Context, req datasource.R
201210
202211// Save data into Terraform state
203212resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
204- }
213+ }
0 commit comments