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

Improve Behavior definitions to allow complex Execution properties #1131

Merged
merged 34 commits into from
Aug 28, 2024

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Oct 11, 2023

Problem

With v3.10.0, the new resources vcd_rde_interface_behavior and vcd_rde_type_behavior allowed to define Behaviors for RDE Interfaces and RDE Types respectively.

The Behaviors could be defined with the generic map execution argument, but the problem is that Terraform only supports simple maps of string->string, where one could be able to define executions of more complex structures, like a WebHook type does:

{
      "type":"WebHook",
      "id":"testWebHook",
      "href":"https://hooks.slack.com:443/services/T07UZFN0N/B01EW5NC42D/rfjhHCGIwzuzQFrpPZiuLkIX",
      "key":"secretKey",
      "execution_properties": { <--- PROBLEM! This is not possible with a TypeMap!
         "template":{
            "content":"<template_content_string>"
         },
         "_secure_token":"secureToken",
         "invocation_timeout":7
      }
   }

Solution

Add a new attribute execution_json which is a plain string that represents a JSON. Both execution and execution_json will live together, the first one being now just syntactic sugar for the latter.

The challenge here is that the WebHook behavior type uses a special _secure_ and _internal_ prefixes for fields that are write-only. So once created, they're never recovered from VCD. This causes dirty plans all the time, where the Provider asks for updates all the time. To avoid that, a new DiffSuppressFunc has been implemented: hasBehaviorExecutionChanged, which ignores secure fields if the attribute always_update_secure_execution_properties is disabled.

Tests

☑️ Acceptance tests

go test -tags rde -v -timeout 0

☑️ Binary tests

make test-binary-prepare
cd vcd/test-artifacts
./test-binary.sh tags rde

☑️ Upgrade tests

make test-upgrade-prepare
cd vcd/test-artifacts
./test-binary.sh upgrade v3.13.0 v3.14.0

abarreiro added 5 commits October 11, 2023 10:33
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 Improve Behavior invocations Improve Behavior definitions to allow complex Execution Oct 11, 2023
@adambarreiro adambarreiro changed the title Improve Behavior definitions to allow complex Execution Improve Behavior definitions to allow complex Execution properties Oct 11, 2023
abarreiro added 6 commits July 30, 2024 12:12
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 self-assigned this Aug 2, 2024
abarreiro added 16 commits August 2, 2024 12:48
#
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>
fmt
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>
abarreiro added 4 commits August 6, 2024 09:38
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 August 6, 2024 12:47
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.

Tests pass on 10.6 and 10.4

vcd/resource_vcd_rde_interface_behavior.go Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro merged commit 50837be into vmware:main Aug 28, 2024
3 checks passed
@adambarreiro adambarreiro deleted the improve-behavior-invocation branch August 28, 2024 14:06
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.

3 participants