diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index 995549f22..22e399311 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -136,6 +136,12 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou return } + {{ if getDefaultValues .PkgName "parent_dn" $.Definitions}} + if data.ParentDn.IsNull() || data.ParentDn.IsUnknown(){ + data.ParentDn = basetypes.NewStringValue("{{getDefaultValues .PkgName "parent_dn" $.Definitions}}") + } + {{- end}} + set{{.ResourceClassName}}Id(ctx, data) // Create a copy of the Id for when not found during getAndSet{{.ResourceClassName}}Attributes @@ -145,12 +151,6 @@ func (d *{{.ResourceClassName}}DataSource) Read(ctx context.Context, req datasou getAndSet{{.ResourceClassName}}Attributes(ctx, &resp.Diagnostics, d.client, data) - {{ if getDefaultValues .PkgName "parent_dn" $.Definitions}} - if data.ParentDn.IsNull() || data.ParentDn.IsUnknown(){ - data.ParentDn = basetypes.NewStringValue("{{getDefaultValues .PkgName "parent_dn" $.Definitions}}") - } - {{- end}} - if data.Id.IsNull() { resp.Diagnostics.AddError( "Failed to read aci_{{.ResourceName}} data source", diff --git a/internal/provider/data_source_aci_netflow_monitor_policy.go b/internal/provider/data_source_aci_netflow_monitor_policy.go index b5aecc379..df3d82f21 100644 --- a/internal/provider/data_source_aci_netflow_monitor_policy.go +++ b/internal/provider/data_source_aci_netflow_monitor_policy.go @@ -175,6 +175,10 @@ func (d *NetflowMonitorPolDataSource) Read(ctx context.Context, req datasource.R return } + if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { + data.ParentDn = basetypes.NewStringValue("uni/infra") + } + setNetflowMonitorPolId(ctx, data) // Create a copy of the Id for when not found during getAndSetNetflowMonitorPolAttributes @@ -184,10 +188,6 @@ func (d *NetflowMonitorPolDataSource) Read(ctx context.Context, req datasource.R getAndSetNetflowMonitorPolAttributes(ctx, &resp.Diagnostics, d.client, data) - if data.ParentDn.IsNull() || data.ParentDn.IsUnknown() { - data.ParentDn = basetypes.NewStringValue("uni/infra") - } - if data.Id.IsNull() { resp.Diagnostics.AddError( "Failed to read aci_netflow_monitor_policy data source",