Skip to content

Commit

Permalink
Fix deref for dataprotection resource
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Naren Pujari <rnarenpujari@gmail.com>
  • Loading branch information
rnarenpujari committed Mar 20, 2024
1 parent 73e4875 commit 7c1f28d
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@ func resourceEnableDataProtectionRead(ctx context.Context, data *schema.Resource

err := populateDataFromServer(ctx, config, scopedFullnameData, data)

// remove the existing cluster level resource from state if it is now
// managed at the cluster group level.
if scopedFullnameData.Scope == scope.ClusterScope {
metaData := data.Get(common.MetaKey).([]interface{})[0].(map[string]interface{})
annotations := metaData[common.AnnotationsKey].(map[string]interface{})
value, ok := data.GetOk(common.MetaKey)
if ok && len(value.([]interface{})) > 0 {
metaData := value.([]interface{})[0].(map[string]interface{})
annotations := metaData[common.AnnotationsKey].(map[string]interface{})

if _, ok := annotations[commonscope.BatchUIDAnnotationKey]; ok {
_ = schema.RemoveFromState(data, m)
if _, ok := annotations[commonscope.BatchUIDAnnotationKey]; ok {
_ = schema.RemoveFromState(data, m)

return diags
return diags
}
}
}

Expand Down

0 comments on commit 7c1f28d

Please sign in to comment.