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 new argument to Provider configuration to ignore metadata entries #1057

Merged
merged 89 commits into from
Jul 17, 2023

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented May 17, 2023

Closes #959
Requires https://github.com/vmware/go-vcloud-director/pull/581/files

This PR adds a new argument to the Terraform VCD Provider configuration: ignore_metadata_changes, which accepts the following sub-arguments:

  • resource_type: Optional, specifies the resource type which metadata needs to be ignored. If set, the resource type must be one of:
    "vcd_catalog", "vcd_catalog_item", "vcd_catalog_media", "vcd_catalog_vapp_template", "vcd_independent_disk", "vcd_network_direct",
    "vcd_network_isolated", "vcd_network_isolated_v2", "vcd_network_routed", "vcd_network_routed_v2", "vcd_org", "vcd_org_vdc", "vcd_provider_vdc",
    "vcd_storage_profile", "vcd_vapp", "vcd_vapp_vm" or "vcd_vm", which are the resources compatible with metadata_entry.
    Any other resource type will not have effect.
  • resource_name: Optional, specifies the name of the object which metadata needs to be ignored. All object types are supported, except for vdcStorageProfile which cannot be filtered by name.
  • key_regex: Optional, it is a regular expression that can filter out metadata keys that match.
  • value_regex: Optional, it is a regular expression that can filter out metadata keys that match.
  • conflict_action: Optional, defines what to do if a conflict exists between a metadata_entry that is managed
    by Terraform, and it matches the criteria defined in the ignore_metadata_changes block, as the metadata will be stored in state but nothing will be done in VCD. If the value is error, when this happens, the Plan will fail. When the value is warn, it will just give a warning but the Plan will continue, and with the none value nothing will be shown. Defaults to error.

Either key_regex or value_regex are required on every ignore_metadata block.

Example

provider "vcd" {
  user                 = "administrator"
  password             = "SuperSecure123"
  auth_type            = "integrated"
  url                  = "https://my-awesome-vcd.com"
  sysorg               = "System"
  org                  = "myOrg"
  allow_unverified_ssl = true
  logging              = true

  # Filters all metadata with key "Environment" or "environment" in all VCD objects with any name.
  ignore_metadata_changes {
    key_regex   = "^[Ee]nvironment$"
  }

  # Filters all metadata with key "NiceMetadataKey" in all VCD objects named "SpecificName".
  ignore_metadata_changes {
    resource_name = "SpecificName"
    key_regex   = "^NiceMetadataKey$"
  }

  # Filters all metadata with values "Yes" in the Organization named "Tatooine".
  ignore_metadata_changes {
    resource_type = "org"
    resource_name = "Tatooine"
    value_regex = "^Yes$"
  }
}

Acceptance tests passed on VCD versions: TBD

abarreiro added 14 commits May 17, 2023 11:10
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 Add new attribute to resources to ignore metadata entries Add new argument to Provider configuration to ignore metadata entries Jun 15, 2023
abarreiro added 12 commits June 15, 2023 10:59
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 marked this pull request as ready for review July 12, 2023 14:23
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

I have reviewed the 26 commits done after my last review and it all feels right and further improved!

vcd/metadata.go Outdated Show resolved Hide resolved
vcd/metadata.go Outdated Show resolved Hide resolved
vcd/metadata.go Outdated Show resolved Hide resolved
vcd/metadata.go Outdated Show resolved Hide resolved
vcd/metadata.go Outdated Show resolved Hide resolved
vcd/resource_vcd_vapp.go Outdated Show resolved Hide resolved
website/docs/index.html.markdown Outdated Show resolved Hide resolved
website/docs/index.html.markdown Outdated Show resolved Hide resolved
abarreiro added 3 commits July 13, 2023 09:27
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Fix
Signed-off-by: abarreiro <abarreiro@vmware.com>
Fix
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
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.

2nd approval.
I have manually tested metadata conflict situation and double checked the origin field change.

To reiterate a note of caution about createcalling update. We do not want to do it because of how messy and painful it becomes to deal with it (#901). Yet we still have some places where it happens (and is needed) from a long long time ago.

vcd/metadata.go Outdated Show resolved Hide resolved
website/docs/index.html.markdown Outdated Show resolved Hide resolved
website/docs/index.html.markdown Outdated Show resolved Hide resolved
abarreiro added 2 commits July 14, 2023 11:18
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
abarreiro added 4 commits July 14, 2023 12:37
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>
Copy link

@adezxc adezxc left a comment

Choose a reason for hiding this comment

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

Thanks for the feature!

Signed-off-by: abarreiro <abarreiro@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ignore specific metadata_entries
6 participants