Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to ignore metadata to SDK client configuration #581

Merged
merged 36 commits into from
Jul 14, 2023

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Jun 19, 2023

Context

This PR implements the foundational logic to be able to implement metadata ignoring in the VCD Terraform Provider: vmware/terraform-provider-vcd#1057

Description

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.

Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro changed the title Ignore metadata Add ability to ignore metadata to SDK client configuration Jun 19, 2023
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro self-assigned this Jun 19, 2023
@adambarreiro adambarreiro marked this pull request as ready for review June 19, 2023 15:33
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Missing changelog
    I have a few queries and requests inline

govcd/api_vcd.go Outdated Show resolved Hide resolved
govcd/filter_helpers.go Outdated Show resolved Hide resolved
govcd/metadata.go Outdated Show resolved Hide resolved
govcd/metadata_v2.go Outdated Show resolved Hide resolved
govcd/metadata_v2.go Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
govcd/metadata_v2.go Outdated Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
.changes/v2.21.0/581-improvements.md Outdated Show resolved Hide resolved
govcd/metadata_v2.go Outdated Show resolved Hide resolved
govcd/metadata_v2_test.go Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
govcd/metadata_v2.go Outdated Show resolved Hide resolved
govcd/metadata_v2.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I am good in general.
I have left a few comments how to fix my own suggestion at it was more complicated than I though:)

Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro changed the title Add ability to ignore metadata to SDK client configuration WIP: Add ability to ignore metadata to SDK client configuration Jul 7, 2023
@adambarreiro adambarreiro marked this pull request as draft July 7, 2023 13:54
@adambarreiro adambarreiro changed the title WIP: Add ability to ignore metadata to SDK client configuration Add ability to ignore metadata to SDK client configuration Jul 11, 2023
@adambarreiro adambarreiro marked this pull request as ready for review July 11, 2023 14:20
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Collaborator

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I am just asking to do one small correction

govcd/api_vcd.go Outdated Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro merged commit 572755d into vmware:main Jul 14, 2023
2 checks passed
@adambarreiro adambarreiro deleted the ignore-metadata branch July 14, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants