The metadata to ignore lives inside the SDK Client as a slice of a new structure called IgnoredMetadata. This slice can be populated with the new WithIgnoredMetadata function.
The IgnoredMetadata slice is then read in all metadata_v2.go methods. There are three methods to filter metadata:
filterMetadata, in short it calls filterSingleMetadataEntry on every entry of the metadata slice given as an input.
filterSingleMetadataEntry filters a single metadata entry. Here, the way that it works is that it considers that a metadata entry should be always ignored if the IgnoredMetadata entries don't say the opposite. This allows to have all fields in IgnoredMetadata to be optional (they're pointers) and compute all rules with an AND.
filterMetadataToDelete controls the special case of metadata deletion, as we only have a Key here, we need to retrieve the Value if the entry is a good candidate to be removed.
Context
This PR implements the foundational logic to be able to implement metadata ignoring in the VCD Terraform Provider: https://github.com/vmware/terraform-provider-vcd/pull/1057
Description
The metadata to ignore lives inside the SDK
Client
as a slice of a new structure calledIgnoredMetadata
. This slice can be populated with the newWithIgnoredMetadata
function.The
IgnoredMetadata
slice is then read in all metadata_v2.go methods. There are three methods to filter metadata:filterMetadata
, in short it callsfilterSingleMetadataEntry
on every entry of the metadata slice given as an input.filterSingleMetadataEntry
filters a single metadata entry. Here, the way that it works is that it considers that a metadata entry should be always ignored if theIgnoredMetadata
entries don't say the opposite. This allows to have all fields inIgnoredMetadata
to be optional (they're pointers) and compute all rules with an AND.filterMetadataToDelete
controls the special case of metadata deletion, as we only have a Key here, we need to retrieve the Value if the entry is a good candidate to be removed.