Skip to content

Commit

Permalink
Merge pull request #388 from vmware/rnarenpujari/dp-fix
Browse files Browse the repository at this point in the history
Fix deref for dataprotection resource
  • Loading branch information
rnarenpujari authored Mar 21, 2024
2 parents 73e4875 + 7c1f28d commit 3681696
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 3681696

Please sign in to comment.