in internal/provider/architecture_data_source.go [433:489]
func convertPolicyAssignmentResourceSelectorsToSdkType(ctx context.Context, input []gen.ResourceSelectorsValue, resp *datasource.ReadResponse) []*armpolicy.ResourceSelector {
if len(input) == 0 {
return nil
}
res := make([]*armpolicy.ResourceSelector, len(input))
for i, rs := range input {
selectors := make([]*armpolicy.Selector, len(rs.ResourceSelectorSelectors.Elements()))
for j, s := range rs.ResourceSelectorSelectors.Elements() {
rssv, ok := s.(gen.ResourceSelectorSelectorsValue)
if !ok {
resp.Diagnostics.AddError(
"convertPolicyAssignmentResourceSelectorsToSdkType: error",
"unable to convert resource selector selectors attr.Value to concrete type",
)
}
// Convert In to a go slice, start off from an uninitialized slice so that the value is nil if the input is empty.
var in []*string
if len(rssv.In.Elements()) != 0 {
var err error
in, err = frameworktype.SliceOfPrimitiveToGo[string](ctx, rssv.In.Elements())
if err != nil {
resp.Diagnostics.AddError(
"convertPolicyAssignmentResourceSelectorsToSdkType: error",
fmt.Sprintf("unable to convert ResourceSelectorSelectorsValue.In elements to Go slice: %s", err.Error()),
)
return nil
}
}
// Convert NotIn to a go slice, start off from an uninitialized slice so that the value is nil if the input is empty.
var notIn []*string
if len(rssv.NotIn.Elements()) != 0 {
var err error
notIn, err = frameworktype.SliceOfPrimitiveToGo[string](ctx, rssv.NotIn.Elements())
if err != nil {
resp.Diagnostics.AddError(
"convertPolicyAssignmentResourceSelectorsToSdkType: error",
fmt.Sprintf("unable to convert ResourceSelectorSelectorsValue.NotIn elements to Go slice: %s", err.Error()),
)
return nil
}
}
selectors[j] = &armpolicy.Selector{
Kind: to.Ptr(armpolicy.SelectorKind(rssv.Kind.ValueString())),
In: in,
NotIn: notIn,
}
}
res[i] = &armpolicy.ResourceSelector{
Name: to.Ptr(rs.Name.ValueString()),
Selectors: selectors,
}
}
return res
}